the effect can be played and clear some memory leak
This commit is contained in:
natural-law 2010-09-30 03:25:15 +00:00
parent 683596a023
commit 6d658b341c
2 changed files with 7 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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;