aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/sound/sound.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-12 07:46:35 -0400
committerPaul Gilbert2016-08-12 07:46:35 -0400
commitbf4562ba4f8befe9f985c464e9a5094e3e6f255d (patch)
tree9f0675fd6998656f34345f0c1bf05ca6835c63b3 /engines/titanic/sound/sound.cpp
parent31f344079ff6b66f933becd6602e446d94717a4d (diff)
downloadscummvm-rg350-bf4562ba4f8befe9f985c464e9a5094e3e6f255d.tar.gz
scummvm-rg350-bf4562ba4f8befe9f985c464e9a5094e3e6f255d.tar.bz2
scummvm-rg350-bf4562ba4f8befe9f985c464e9a5094e3e6f255d.zip
TITANIC: Further fleshing out sound manager, fixing sound looping
Diffstat (limited to 'engines/titanic/sound/sound.cpp')
-rw-r--r--engines/titanic/sound/sound.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp
index d14c628a78..7e791c2ba5 100644
--- a/engines/titanic/sound/sound.cpp
+++ b/engines/titanic/sound/sound.cpp
@@ -68,8 +68,18 @@ void CSound::setVolume(uint handle, uint volume, uint seconds) {
_soundManager.setVolume(handle, volume, seconds);
}
-void CSound::fn4(CWaveFile *waveFile, int val) {
- // TODO
+void CSound::activateSound(CWaveFile *waveFile, bool freeFlag) {
+ for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) {
+ CSoundItem *sound = *i;
+ if (sound->_waveFile == waveFile) {
+ sound->_active = true;
+ sound->_freeFlag = freeFlag;
+
+ if (!freeFlag && waveFile->size() > 51200)
+ sound->_freeFlag = true;
+ break;
+ }
+ }
}
void CSound::stopChannel(int channel) {
@@ -79,7 +89,7 @@ void CSound::stopChannel(int channel) {
void CSound::checkSounds() {
for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) {
CSoundItem *soundItem = *i;
- if (soundItem->_field24 && soundItem->_field28) {
+ if (soundItem->_active && soundItem->_freeFlag) {
if (_soundManager.isActive(soundItem->_waveFile)) {
_sounds.remove(soundItem);
delete soundItem;
@@ -92,7 +102,7 @@ void CSound::removeOldest() {
for (CSoundItemList::iterator i = _sounds.reverse_begin();
i != _sounds.end(); --i) {
CSoundItem *soundItem = *i;
- if (soundItem->_field28 && !_soundManager.isActive(soundItem->_waveFile)) {
+ if (soundItem->_active && !_soundManager.isActive(soundItem->_waveFile)) {
_sounds.remove(soundItem);
delete soundItem;
break;
@@ -145,7 +155,7 @@ int CSound::playSound(const CString &name, CProximity &prox) {
return -1;
prox._field6C = waveFile->fn1();
- fn4(waveFile, prox._field60);
+ activateSound(waveFile, prox._freeSoundFlag);
return _soundManager.playSound(*waveFile, prox);
}
@@ -192,7 +202,7 @@ int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &pr
return -1;
prox._field6C = waveFile->fn1();
- fn4(waveFile, prox._field60);
+ activateSound(waveFile, prox._freeSoundFlag);
return _soundManager.playSound(*waveFile, prox);
}