From 707cfd07ac373dd30e71bb33d3dec8c1d14a386c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 4 Jun 2014 01:49:31 +0200 Subject: SCUMM: Only stop music when requested in AD code. --- engines/scumm/players/player_ad.cpp | 39 ++++++++++++++++++++++--------------- engines/scumm/players/player_ad.h | 1 + 2 files changed, 24 insertions(+), 16 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/players/player_ad.cpp b/engines/scumm/players/player_ad.cpp index 6083283de5..dfd4d7f131 100644 --- a/engines/scumm/players/player_ad.cpp +++ b/engines/scumm/players/player_ad.cpp @@ -147,7 +147,7 @@ void Player_AD::stopSound(int sound) { Common::StackLock lock(_mutex); if (sound == _soundPlaying) { - stopAllSounds(); + stopMusic(); } else { for (int i = 0; i < ARRAYSIZE(_sfx); ++i) { if (_sfx[i].resource == sound) { @@ -160,21 +160,8 @@ void Player_AD::stopSound(int sound) { void Player_AD::stopAllSounds() { Common::StackLock lock(_mutex); - // Unlock the music resource if present - if (_soundPlaying != -1) { - _vm->_res->unlock(rtSound, _soundPlaying); - _soundPlaying = -1; - } - - // Stop the music playback - _curOffset = 0; - - // Stop all music voice channels - for (int i = 0; i < ARRAYSIZE(_voiceChannels); ++i) { - if (_voiceChannels[i].lastEvent) { - noteOff(i); - } - } + // Stop the music + stopMusic(); // Stop all the sfx playback for (int i = 0; i < ARRAYSIZE(_sfx); ++i) { @@ -384,6 +371,26 @@ void Player_AD::startMusic() { _musicLoopStart = READ_LE_UINT16(_musicData + 5); } +void Player_AD::stopMusic() { + if (_soundPlaying == -1) { + return; + } + + // Unlock the music resource if present + _vm->_res->unlock(rtSound, _soundPlaying); + _soundPlaying = -1; + + // Stop the music playback + _curOffset = 0; + + // Stop all music voice channels + for (int i = 0; i < ARRAYSIZE(_voiceChannels); ++i) { + if (_voiceChannels[i].lastEvent) { + noteOff(i); + } + } +} + void Player_AD::updateMusic() { _musicTimer += _musicTicks; if (_musicTimer < _timerLimit) { diff --git a/engines/scumm/players/player_ad.h b/engines/scumm/players/player_ad.h index f8504c4473..fbf604e3f8 100644 --- a/engines/scumm/players/player_ad.h +++ b/engines/scumm/players/player_ad.h @@ -105,6 +105,7 @@ private: // Music handling void startMusic(); + void stopMusic(); void updateMusic(); void noteOff(uint channel); void setupFrequency(uint channel, int8 frequency); -- cgit v1.2.3