diff options
author | Paul Gilbert | 2016-09-02 23:40:25 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-09-02 23:40:25 -0400 |
commit | d971dbea406925760e74e17ffe329d637ad962d6 (patch) | |
tree | ed354cef81144a3824d0621f4d259c30f417b5ef /engines/titanic/sound/sound.cpp | |
parent | 375fb60ff812b9d0dd9bd9f435613fab54907bc0 (diff) | |
download | scummvm-rg350-d971dbea406925760e74e17ffe329d637ad962d6.tar.gz scummvm-rg350-d971dbea406925760e74e17ffe329d637ad962d6.tar.bz2 scummvm-rg350-d971dbea406925760e74e17ffe329d637ad962d6.zip |
TITANIC: Fix and cleanup for sound freeing
Diffstat (limited to 'engines/titanic/sound/sound.cpp')
-rw-r--r-- | engines/titanic/sound/sound.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp index 39c8d04769..998a0a9827 100644 --- a/engines/titanic/sound/sound.cpp +++ b/engines/titanic/sound/sound.cpp @@ -68,15 +68,16 @@ void CSound::setVolume(uint handle, uint volume, uint seconds) { _soundManager.setVolume(handle, volume, seconds); } -void CSound::activateSound(CWaveFile *waveFile, bool freeFlag) { +void CSound::activateSound(CWaveFile *waveFile, DisposeAfterUse::Flag disposeAfterUse) { for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) { CSoundItem *sound = *i; if (sound->_waveFile == waveFile) { sound->_active = true; - sound->_freeFlag = freeFlag; + sound->_disposeAfterUse = disposeAfterUse; - if (!freeFlag && waveFile->size() > 51200) - sound->_freeFlag = true; + // Anything bigger than 50Kb is automatically flagged to be free when finished + if (waveFile->size() > (50 * 1024)) + sound->_disposeAfterUse = DisposeAfterUse::YES; break; } } @@ -90,8 +91,8 @@ void CSound::checkSounds() { for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ) { CSoundItem *soundItem = *i; - if (soundItem->_active && soundItem->_freeFlag) { - if (_soundManager.isActive(soundItem->_waveFile)) { + if (soundItem->_active && soundItem->_disposeAfterUse == DisposeAfterUse::YES) { + if (!_soundManager.isActive(soundItem->_waveFile)) { i = _sounds.erase(i); delete soundItem; continue; @@ -162,7 +163,8 @@ int CSound::playSound(const CString &name, CProximity &prox) { if (prox._soundType != Audio::Mixer::kPlainSoundType) waveFile->_soundType = prox._soundType; - activateSound(waveFile, prox._freeSoundFlag); + activateSound(waveFile, prox._freeSoundFlag ? DisposeAfterUse::YES : + DisposeAfterUse::NO); return _soundManager.playSound(*waveFile, prox); } @@ -209,7 +211,7 @@ int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &pr return -1; prox._soundDuration = waveFile->getDuration(); - activateSound(waveFile, prox._freeSoundFlag); + activateSound(waveFile, prox._freeSoundFlag ? DisposeAfterUse::YES : DisposeAfterUse::NO); return _soundManager.playSound(*waveFile, prox); } |