Merge branch 'master' into XMLHttpRequest_Demo

# By Darragh Coy (1) and minggo (1)
# Via minggo
* master:
  Update AUTHORS
  Fix a potential crash SimpleAudioEngineOpenSL::playEffect Fix a crash in SimpleAudioEngineOpenSL::playEffect which would occur when OpenSLEngine::preloadEffect returned FILE_NOT_FOUND. In the case where the sound fails to preload, we should not attempt to call OpenSLEngine::setEffectLooping on that sound.
This commit is contained in:
Carsten Sandtner 2013-05-15 13:53:31 +02:00
commit 7cece145af
2 changed files with 22 additions and 18 deletions

View File

@ -12,6 +12,9 @@ Developers:
Rolando Abarca Rolando Abarca
Javascript Binding and testjs Javascript Binding and testjs
DarraghCoy
Fix a potential crash SimpleAudioEngineOpenSL::playEffect
silverscania silverscania
Pass correct parameter to glPixelStorei when creating a texture Pass correct parameter to glPixelStorei when creating a texture

View File

@ -88,24 +88,25 @@ void SimpleAudioEngineOpenSL::setEffectsVolume(float volume)
unsigned int SimpleAudioEngineOpenSL::playEffect(const char* pszFilePath, bool bLoop) unsigned int SimpleAudioEngineOpenSL::playEffect(const char* pszFilePath, bool bLoop)
{ {
unsigned int soundID; unsigned int soundID = s_pOpenSL->preloadEffect(pszFilePath);
do
{ if (soundID != FILE_NOT_FOUND)
soundID = s_pOpenSL->preloadEffect(pszFilePath); {
if (soundID != FILE_NOT_FOUND) if (s_pOpenSL->getEffectState(soundID) == PLAYSTATE_PLAYING)
{ {
if (s_pOpenSL->getEffectState(soundID) == PLAYSTATE_PLAYING) // recreate an effect player
{ s_pOpenSL->recreatePlayer(pszFilePath);
// recreate an effect player }
s_pOpenSL->recreatePlayer(pszFilePath); else
break; {
} s_pOpenSL->setEffectState(soundID, PLAYSTATE_STOPPED);
s_pOpenSL->setEffectState(soundID, PLAYSTATE_STOPPED); s_pOpenSL->setEffectState(soundID, PLAYSTATE_PLAYING);
s_pOpenSL->setEffectState(soundID, PLAYSTATE_PLAYING); }
}
} while (0); s_pOpenSL->setEffectLooping(soundID, bLoop);
s_pOpenSL->setEffectLooping(soundID, bLoop); }
return soundID;
return soundID;
} }
void SimpleAudioEngineOpenSL::pauseEffect(unsigned int nSoundId) void SimpleAudioEngineOpenSL::pauseEffect(unsigned int nSoundId)