diff options
author | Paweł Kołodziejski | 2004-04-26 07:47:12 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2004-04-26 07:47:12 +0000 |
commit | 32d7c8c181d899a0be034a60aea1759f28e68634 (patch) | |
tree | bef766fb395635f18395d9e1b669d788cbac0941 /scumm | |
parent | 0fcd887dcd38109688c8f7e07bf366430507fa3b (diff) | |
download | scummvm-rg350-32d7c8c181d899a0be034a60aea1759f28e68634.tar.gz scummvm-rg350-32d7c8c181d899a0be034a60aea1759f28e68634.tar.bz2 scummvm-rg350-32d7c8c181d899a0be034a60aea1759f28e68634.zip |
fixed stopping imuse sounds
svn-id: r13635
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/imuse_digi/dimuse.cpp | 8 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse.h | 3 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse_script.cpp | 55 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse_sndmgr.cpp | 4 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse_track.cpp | 2 | ||||
-rw-r--r-- | scumm/resource.cpp | 2 |
6 files changed, 35 insertions, 39 deletions
diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp index 23bf682865..5d8ef034ec 100644 --- a/scumm/imuse_digi/dimuse.cpp +++ b/scumm/imuse_digi/dimuse.cpp @@ -58,11 +58,9 @@ IMuseDigital::IMuseDigital(ScummEngine *scumm) } IMuseDigital::~IMuseDigital() { - stopAllSounds(true); - { - Common::StackLock lock(_mutex, "IMuseDigital::~IMuseDigital()"); - _vm->_timer->removeTimerProc(timer_handler); - } + Common::StackLock lock(_mutex, "IMuseDigital::~IMuseDigital()"); + stopAllSounds(); + _vm->_timer->removeTimerProc(timer_handler); for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { delete _track[l]; } diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h index 8d9d8f6c8d..66d4583f65 100644 --- a/scumm/imuse_digi/dimuse.h +++ b/scumm/imuse_digi/dimuse.h @@ -148,8 +148,7 @@ public: void setFade(int soundId, int destVolume, int delay60HzTicks); void setMasterVolume(int vol) {} void stopSound(int soundId); - void stopAllSounds() { stopAllSounds(false); } - void stopAllSounds(bool waitForStop); + void stopAllSounds(); void pause(bool pause); void parseScriptCmds(int a, int b, int c, int d, int e, int f, int g, int h); void refreshScripts(); diff --git a/scumm/imuse_digi/dimuse_script.cpp b/scumm/imuse_digi/dimuse_script.cpp index 5f1eec9bb9..630c13826e 100644 --- a/scumm/imuse_digi/dimuse_script.cpp +++ b/scumm/imuse_digi/dimuse_script.cpp @@ -256,12 +256,19 @@ void IMuseDigital::stopSound(int soundId) { Common::StackLock lock(_mutex, "IMuseDigital::stopSound()"); debug(5, "IMuseDigital::stopSound(%d)", soundId); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { - if ((_track[l]->soundId == soundId) && _track[l]->used) { + if ((_track[l]->soundId == soundId) && (_track[l]->used)) { if (_track[l]->stream) { - _track[l]->toBeRemoved = true; - } - else if (_track[l]->stream2) + _track[l]->stream->finish(); + _track[l]->stream = NULL; _vm->_mixer->stopHandle(_track[l]->handle); + _sound->closeSound(_track[l]->soundHandle); + _track[l]->soundHandle = NULL; + } else if (_track[l]->stream2) { + _vm->_mixer->stopHandle(_track[l]->handle); + delete _track[l]->stream2; + _track[l]->stream2 = NULL; + } + _track[l]->used = false; } } } @@ -337,33 +344,25 @@ int32 IMuseDigital::getCurMusicLipSyncHeight(int syncId) { return height; } -void IMuseDigital::stopAllSounds(bool waitForStop) { +void IMuseDigital::stopAllSounds() { + Common::StackLock lock(_mutex, "IMuseDigital::stopAllSounds()"); debug(5, "IMuseDigital::stopAllSounds"); - { - Common::StackLock lock(_mutex, "IMuseDigital::stopAllSounds()"); - for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { - if (_track[l]->used) { - if (_track[l]->stream) { - _track[l]->toBeRemoved = true; - } else if (_track[l]->stream2) - _vm->_mixer->stopHandle(_track[l]->handle); - } - } - } - // FIXME: ignore wait, it can cause deadlock, it need better implementaion - return; - - if (waitForStop) { - bool used; - do { - used = false; - for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { - if (_track[l]->used) - used = true; + for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { + if (_track[l]->used) { + if (_track[l]->stream) { + _track[l]->stream->finish(); + _track[l]->stream = NULL; + _vm->_mixer->stopHandle(_track[l]->handle); + _sound->closeSound(_track[l]->soundHandle); + _track[l]->soundHandle = NULL; + } else if (_track[l]->stream2) { + _vm->_mixer->stopHandle(_track[l]->handle); + delete _track[l]->stream2; + _track[l]->stream2 = NULL; } - g_system->delay_msecs(10); - } while (used); + _track[l]->used = false; + } } } diff --git a/scumm/imuse_digi/dimuse_sndmgr.cpp b/scumm/imuse_digi/dimuse_sndmgr.cpp index 69a02a1127..ee6f6bcb52 100644 --- a/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -232,7 +232,7 @@ bool ImuseDigiSndMgr::openMusicBundle(int slot) { if (_disk != _vm->VAR(_vm->VAR_CURRENTDISK)) { _vm->_imuseDigital->parseScriptCmds(0x1000, 0, 0, 0, 0, 0, 0, 0); _vm->_imuseDigital->parseScriptCmds(0x2000, 0, 0, 0, 0, 0, 0, 0); - _vm->_imuseDigital->stopAllSounds(true); + _vm->_imuseDigital->stopAllSounds(); _sounds[slot].bundle->closeFile(); } @@ -263,7 +263,7 @@ bool ImuseDigiSndMgr::openVoiceBundle(int slot) { if (_disk != _vm->VAR(_vm->VAR_CURRENTDISK)) { _vm->_imuseDigital->parseScriptCmds(0x1000, 0, 0, 0, 0, 0, 0, 0); _vm->_imuseDigital->parseScriptCmds(0x2000, 0, 0, 0, 0, 0, 0, 0); - _vm->_imuseDigital->stopAllSounds(true); + _vm->_imuseDigital->stopAllSounds(); _sounds[slot].bundle->closeFile(); } diff --git a/scumm/imuse_digi/dimuse_track.cpp b/scumm/imuse_digi/dimuse_track.cpp index 7052b2aa88..1e1b31ee38 100644 --- a/scumm/imuse_digi/dimuse_track.cpp +++ b/scumm/imuse_digi/dimuse_track.cpp @@ -105,7 +105,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int bits = 0, freq = 0, channels = 0; if (input) { - _track[l]->iteration = 1; // ? + _track[l]->iteration = 0; // Do nothing here, we already have an audio stream } else { _track[l]->soundHandle = _sound->openSound(soundId, soundName, soundType, volGroupId); diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 8a26f532d9..168ac4f247 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -234,7 +234,7 @@ void ScummEngine::askForDisk(const char *filename, int disknum) { if (_version == 8) { char result; - _imuseDigital->stopAllSounds(true); + _imuseDigital->stopAllSounds(); #ifdef MACOSX sprintf(buf, "Cannot find file: '%s'\nPlease insert disc %d.\nPress OK to retry, Quit to exit", filename, disknum); |