diff --git a/CocosDenshion/SimpleAudioEngine/SimpleAudioEngine.cpp b/CocosDenshion/SimpleAudioEngine/SimpleAudioEngine.cpp index cdd471357b..190b07fe2e 100644 --- a/CocosDenshion/SimpleAudioEngine/SimpleAudioEngine.cpp +++ b/CocosDenshion/SimpleAudioEngine/SimpleAudioEngine.cpp @@ -205,6 +205,7 @@ void SimpleAudioEngine::unloadEffect(int nSoundId) delete [] (pElement->pDataBuffer); HASH_DEL(m_pEffects, pElement); + free(pElement); } while (0); } @@ -235,6 +236,9 @@ void SimpleAudioEngine::playPreloadedEffect(int nSoundId) { pPlayer = new SoundPlayer(); m_EffectPlayers.push_back(pPlayer); + + // set the player volume + pPlayer->SetVolumeValue(m_nEffectsVolume); } } @@ -248,9 +252,9 @@ void SimpleAudioEngine::removeAllEffects() { for (tHashElement *pElement = m_pEffects; pElement != NULL; ) { - unsigned char* pData = pElement->pDataBuffer; - delete [] pData; + int nSoundID = pElement->nSoundID; pElement = (tHashElement*)pElement->hh.next; + unloadEffect(nSoundID); } } diff --git a/TestAudioEngine/TestAudioEngineMainForm.cpp b/TestAudioEngine/TestAudioEngineMainForm.cpp index 9fc992c0a3..8970a31c3c 100644 --- a/TestAudioEngine/TestAudioEngineMainForm.cpp +++ b/TestAudioEngine/TestAudioEngineMainForm.cpp @@ -92,7 +92,7 @@ Boolean TMainForm::CtrlSelected(TApplication * pApp, EventType * pEvent) case TESTAU_ID_Form1002_LoadEffect: // load effect1 - m_nEffect1ID = pAudioEngine->preloadEffect(/*s_Effect1File*/s_BackgroundFile); + m_nEffect1ID = pAudioEngine->preloadEffect(s_Effect1File); assert(m_nEffect1ID > 0); bHandled = TRUE; break;