diff options
author | Filippos Karapetis | 2010-01-21 21:28:32 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-01-21 21:28:32 +0000 |
commit | 93a8b469c03d05ddef0aa46a51887a68ff629eb7 (patch) | |
tree | b8b33fdeade8b14ccb96294e0a8a90a08c6cf0b1 /engines/sci/sound | |
parent | 66f90a40c93c97ede730da880cfb86ffaf06d2b0 (diff) | |
download | scummvm-rg350-93a8b469c03d05ddef0aa46a51887a68ff629eb7.tar.gz scummvm-rg350-93a8b469c03d05ddef0aa46a51887a68ff629eb7.tar.bz2 scummvm-rg350-93a8b469c03d05ddef0aa46a51887a68ff629eb7.zip |
- Fixed pausing of all sounds in the playlist
- Sounds are now paused correctly when opening/closing the debug console
- Some cleanup
svn-id: r47422
Diffstat (limited to 'engines/sci/sound')
-rw-r--r-- | engines/sci/sound/music.cpp | 20 | ||||
-rw-r--r-- | engines/sci/sound/music.h | 2 | ||||
-rw-r--r-- | engines/sci/sound/soundcmd.cpp | 46 | ||||
-rw-r--r-- | engines/sci/sound/soundcmd.h | 1 |
4 files changed, 36 insertions, 33 deletions
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index d96fdcbe70..c3141e67ef 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -91,12 +91,21 @@ void SciMusic::init() { } void SciMusic::clearPlayList() { - _mutex.lock(); + Common::StackLock lock(_mutex); + while (!_playList.empty()) { soundStop(_playList[0]); soundKill(_playList[0]); } - _mutex.unlock(); +} + +void SciMusic::pauseAll(bool pause) { + Common::StackLock lock(_mutex); + + const MusicList::iterator end = _playList.end(); + for (MusicList::iterator i = _playList.begin(); i != end; ++i) { + soundToggle(*i, pause); + } } void SciMusic::miditimerCallback(void *p) { @@ -326,6 +335,13 @@ void SciMusic::soundResume(MusicEntry *pSnd) { soundPlay(pSnd); } +void SciMusic::soundToggle(MusicEntry *pSnd, bool pause) { + if (pause) + soundPause(pSnd); + else + soundResume(pSnd); +} + uint16 SciMusic::soundGetMasterVolume() { return _masterVolume; } diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index 2c3f2d96a6..02b79b04b5 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -139,6 +139,7 @@ public: void init(); void onTimer(); void clearPlayList(); + void pauseAll(bool pause); // sound and midi functions void soundInitSnd(MusicEntry *pSnd); @@ -147,6 +148,7 @@ public: void soundKill(MusicEntry *pSnd); void soundPause(MusicEntry *pSnd); void soundResume(MusicEntry *pSnd); + void soundToggle(MusicEntry *pSnd, bool pause); void soundSetVolume(MusicEntry *pSnd, byte volume); void soundSetPriority(MusicEntry *pSnd, byte prio); uint16 soundGetMasterVolume(); diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp index 79e8670578..f5fb5b4e4f 100644 --- a/engines/sci/sound/soundcmd.cpp +++ b/engines/sci/sound/soundcmd.cpp @@ -530,51 +530,29 @@ void SoundCommandParser::cmdPauseSound(reg_t obj, int16 value) { changeSoundStatus(obj, value ? SOUND_STATUS_SUSPENDED : SOUND_STATUS_PLAYING); #else - MusicEntry *musicSlot = NULL; - MusicList::iterator slotLoop = NULL; - MusicList::iterator listEnd = NULL; - - if (!obj.segment) { + if (!obj.segment) { // pause the whole playlist // Pausing/Resuming the whole playlist was introduced // in the SCI1 late sound scheme if (_soundVersion <= SCI_VERSION_1_EARLY) return; - _music->_mutex.lock(); - slotLoop = _music->getPlayListStart(); - listEnd = _music->getPlayListEnd(); - musicSlot = *slotLoop; - _music->_mutex.unlock(); - } else { - _music->_mutex.lock(); - musicSlot = _music->getSlot(obj); - _music->_mutex.unlock(); + + _music->pauseAll(value); + } else { // pause a playlist slot + Common::StackLock lock(_music->_mutex); + MusicEntry *musicSlot = _music->getSlot(obj); if (!musicSlot) { warning("cmdPauseSound: Slot not found (%04x:%04x)", PRINT_REG(obj)); return; } - } - do { if (_soundVersion <= SCI_VERSION_0_LATE) { + // Always pause the sound in SCI0 games. It's resumed in cmdResumeSound() PUT_SEL32V(_segMan, musicSlot->soundObj, state, kSoundPaused); _music->soundPause(musicSlot); } else { - if (value) - _music->soundPause(musicSlot); - else - _music->soundResume(musicSlot); - } - - if (slotLoop) { - if (slotLoop == listEnd) { - break; - } else { - _music->_mutex.lock(); - musicSlot = *(slotLoop++); - _music->_mutex.unlock(); - } + _music->soundToggle(musicSlot, value); } - } while (slotLoop); + } #endif } @@ -1100,4 +1078,10 @@ void SoundCommandParser::setMasterVolume(int vol) { #endif } +void SoundCommandParser::pauseAll(bool pause) { +#ifndef USE_OLD_MUSIC_FUNCTIONS + _music->pauseAll(pause); +#endif +} + } // End of namespace Sci diff --git a/engines/sci/sound/soundcmd.h b/engines/sci/sound/soundcmd.h index d7b0b87609..fc80b6b3fa 100644 --- a/engines/sci/sound/soundcmd.h +++ b/engines/sci/sound/soundcmd.h @@ -63,6 +63,7 @@ public: void reconstructPlayList(int savegame_version); void printPlayList(Console *con); void setMasterVolume(int vol); + void pauseAll(bool pause); #ifndef USE_OLD_MUSIC_FUNCTIONS /** |