From 376e0ae2a38f50b5d3479b8b2c2e57e2a7d452be Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Thu, 3 Feb 2011 13:25:05 +0000 Subject: Audio Bugfixes: * [#25638] 'Insufficient thread locking' for sounds - Actually a workaround for an msvc bug, msvc STL containers are buggy * [#25922] Sound does not play in BlenderPlayer(r34579) - Windows OpenAL doesn't seem to have clear context error state on initialising --- intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'intern/audaspace/OpenAL') diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index 5df7ec4fb0c..6a9f2c40d92 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -129,6 +129,9 @@ void AUD_OpenALDevice::updateStreams() ALint info; AUD_DeviceSpecs specs = m_specs; ALCenum cerr; + std::list stopSounds; + std::list pauseSounds; + AUD_HandleIterator it; while(1) { @@ -139,7 +142,7 @@ void AUD_OpenALDevice::updateStreams() if(cerr == ALC_NO_ERROR) { // for all sounds - for(AUD_HandleIterator it = m_playingSounds->begin(); it != m_playingSounds->end(); it++) + for(it = m_playingSounds->begin(); it != m_playingSounds->end(); it++) { sound = *it; @@ -234,21 +237,12 @@ void AUD_OpenALDevice::updateStreams() if(sound->stop) sound->stop(sound->stop_data); - // increment the iterator to the next value, - // because the sound gets deleted in the list here. - ++it; // pause or if(sound->keep) - pause(sound); + pauseSounds.push_back(sound); // stop else - stop(sound); - // decrement again, so that we get the next sound in the - // next loop run - if(m_playingSounds->empty()) - break; - else - --it; + stopSounds.push_back(sound); } // continue playing else @@ -256,6 +250,15 @@ void AUD_OpenALDevice::updateStreams() } } + for(it = pauseSounds.begin(); it != pauseSounds.end(); it++) + pause(*it); + + for(it = stopSounds.begin(); it != stopSounds.end(); it++) + stop(*it); + + pauseSounds.clear(); + stopSounds.clear(); + alcProcessContext(m_context); } @@ -340,6 +343,7 @@ AUD_OpenALDevice::AUD_OpenALDevice(AUD_DeviceSpecs specs, int buffersize) m_useMC = alIsExtensionPresent("AL_EXT_MCFORMATS") == AL_TRUE; alGetError(); + alcGetError(m_device); m_specs = specs; m_buffersize = buffersize; -- cgit v1.2.3