diff options
Diffstat (limited to 'engines')
| -rw-r--r-- | engines/titanic/sound/sound.cpp | 18 | ||||
| -rw-r--r-- | engines/titanic/sound/sound.h | 13 | 
2 files changed, 18 insertions, 13 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);  } diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h index de95f9edf1..21f2a93f24 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  | 
