[Scummvm-git-logs] scummvm master -> d971dbea406925760e74e17ffe329d637ad962d6
dreammaster
dreammaster at scummvm.org
Sat Sep 3 05:40:34 CEST 2016
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d971dbea40 TITANIC: Fix and cleanup for sound freeing
Commit: d971dbea406925760e74e17ffe329d637ad962d6
https://github.com/scummvm/scummvm/commit/d971dbea406925760e74e17ffe329d637ad962d6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-02T23:40:25-04:00
Commit Message:
TITANIC: Fix and cleanup for sound freeing
Changed paths:
engines/titanic/sound/sound.cpp
engines/titanic/sound/sound.h
diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp
index 39c8d04..998a0a9 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);
}
diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h
index de95f9e..21f2a93 100644
--- a/engines/titanic/sound/sound.h
+++ b/engines/titanic/sound/sound.h
@@ -41,15 +41,17 @@ public:
CWaveFile *_waveFile;
File *_dialogueFileHandle;
int _speechId;
- bool _freeFlag;
+ DisposeAfterUse::Flag _disposeAfterUse;
bool _active;
public:
CSoundItem() : ListItem(), _waveFile(nullptr), _dialogueFileHandle(nullptr),
- _speechId(0), _freeFlag(false), _active(false) {}
+ _speechId(0), _disposeAfterUse(DisposeAfterUse::NO), _active(false) {}
CSoundItem(const CString &name) : ListItem(), _name(name), _waveFile(nullptr),
- _dialogueFileHandle(nullptr), _speechId(0), _freeFlag(false), _active(false) {}
+ _dialogueFileHandle(nullptr), _disposeAfterUse(DisposeAfterUse::NO),
+ _speechId(0), _active(false) {}
CSoundItem(File *dialogueFile, int speechId) : ListItem(), _waveFile(nullptr),
- _dialogueFileHandle(dialogueFile), _speechId(speechId), _freeFlag(false), _active(false) {}
+ _dialogueFileHandle(dialogueFile), _speechId(speechId), _active(false),
+ _disposeAfterUse(DisposeAfterUse::NO) {}
};
class CSoundItemList : public List<CSoundItem> {
@@ -126,7 +128,8 @@ public:
/**
* Flags a sound about to be played as activated
*/
- void activateSound(CWaveFile *waveFile, bool freeFlag);
+ void activateSound(CWaveFile *waveFile,
+ DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO);
/**
* Stops any sounds attached to a given channel
More information about the Scummvm-git-logs
mailing list