From a77aa5e4be6f90155d6db21620102fc69aeb796d Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sun, 24 Apr 2011 15:34:53 +0000 Subject: [PATCH] - attempt to correct possible openal issues --- .../sources/sound/openal/sound_player_openal.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/shared_lib/sources/sound/openal/sound_player_openal.cpp b/source/shared_lib/sources/sound/openal/sound_player_openal.cpp index 315e0ec4c..898bad94b 100644 --- a/source/shared_lib/sources/sound/openal/sound_player_openal.cpp +++ b/source/shared_lib/sources/sound/openal/sound_player_openal.cpp @@ -49,6 +49,9 @@ void SoundSource::unQueueBuffers() { ALint queued=0; alGetSourcei(source, AL_BUFFERS_QUEUED, &queued); + SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__)); + + alSourcei(source, AL_LOOPING, AL_FALSE); SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__)); ALint processed=0; @@ -148,6 +151,7 @@ void StaticSoundSource::play(StaticSound* sound) { if(bufferAllocated) { stop(); alDeleteBuffers(1, &buffer); + SoundPlayerOpenAL::checkAlError(string(__FILE__) + string(" ") + string(__FUNCTION__) + string(" ") + intToStr(__LINE__)); } ALenum format = getFormat(sound); @@ -548,14 +552,20 @@ StaticSoundSource* SoundPlayerOpenAL::findStaticSoundSource() { if(initOk == false) return NULL; // try to find a stopped source + int playingCount = 0; for(StaticSoundSources::iterator i = staticSources.begin(); i != staticSources.end(); ++i) { StaticSoundSource* source = *i; if(! source->playing()) { return source; } + else { + playingCount++; + } } + if(SystemFlags::getSystemSettingType(SystemFlags::debugSound).enabled) SystemFlags::OutputDebug(SystemFlags::debugSound,"In [%s::%s %d] playingCount = %d, staticSources.size() = %lu, params.staticBufferCount = %u\n",__FILE__,__FUNCTION__,__LINE__,playingCount,(unsigned long)staticSources.size(),params.staticBufferCount); + // create a new source if(staticSources.size() >= params.staticBufferCount) { return 0;