From 7b67794826bcaffa4c0fc8a3accc3efa3ddc0328 Mon Sep 17 00:00:00 2001 From: Darragh Coy Date: Tue, 14 May 2013 17:48:50 +0100 Subject: [PATCH 1/2] 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. --- .../opensl/SimpleAudioEngineOpenSL.cpp | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/CocosDenshion/android/opensl/SimpleAudioEngineOpenSL.cpp b/CocosDenshion/android/opensl/SimpleAudioEngineOpenSL.cpp index 78323e9f00..b65ed58f1c 100644 --- a/CocosDenshion/android/opensl/SimpleAudioEngineOpenSL.cpp +++ b/CocosDenshion/android/opensl/SimpleAudioEngineOpenSL.cpp @@ -88,24 +88,25 @@ void SimpleAudioEngineOpenSL::setEffectsVolume(float volume) unsigned int SimpleAudioEngineOpenSL::playEffect(const char* pszFilePath, bool bLoop) { - unsigned int soundID; - do - { - soundID = s_pOpenSL->preloadEffect(pszFilePath); - if (soundID != FILE_NOT_FOUND) - { - if (s_pOpenSL->getEffectState(soundID) == PLAYSTATE_PLAYING) - { - // recreate an effect player - s_pOpenSL->recreatePlayer(pszFilePath); - break; - } - s_pOpenSL->setEffectState(soundID, PLAYSTATE_STOPPED); - s_pOpenSL->setEffectState(soundID, PLAYSTATE_PLAYING); - } - } while (0); - s_pOpenSL->setEffectLooping(soundID, bLoop); - return soundID; + unsigned int soundID = s_pOpenSL->preloadEffect(pszFilePath); + + if (soundID != FILE_NOT_FOUND) + { + if (s_pOpenSL->getEffectState(soundID) == PLAYSTATE_PLAYING) + { + // recreate an effect player + s_pOpenSL->recreatePlayer(pszFilePath); + } + else + { + s_pOpenSL->setEffectState(soundID, PLAYSTATE_STOPPED); + s_pOpenSL->setEffectState(soundID, PLAYSTATE_PLAYING); + } + + s_pOpenSL->setEffectLooping(soundID, bLoop); + } + + return soundID; } void SimpleAudioEngineOpenSL::pauseEffect(unsigned int nSoundId) From 392c33cb7a869ce3e8d7c43033996df42db095f8 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 15 May 2013 09:53:53 +0800 Subject: [PATCH 2/2] Update AUTHORS --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index e3ed3d54a6..9410a76307 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,6 +11,9 @@ Developers: Ricardo Quesada Rolando Abarca Javascript Binding and testjs + + DarraghCoy + Fix a potential crash SimpleAudioEngineOpenSL::playEffect silverscania Pass correct parameter to glPixelStorei when creating a texture