diff options
author | Torbjörn Andersson | 2012-11-18 19:18:21 +0100 |
---|---|---|
committer | Torbjörn Andersson | 2012-11-18 19:18:21 +0100 |
commit | 94b0881427c9120e5e638872840e24297bad2a68 (patch) | |
tree | 6c9d007da7a5e53b664ab5e6950d284b05cd8ffe /engines/scumm | |
parent | ae823b5c6a31a568072545503dbc5c125d19c391 (diff) | |
download | scummvm-rg350-94b0881427c9120e5e638872840e24297bad2a68.tar.gz scummvm-rg350-94b0881427c9120e5e638872840e24297bad2a68.tar.bz2 scummvm-rg350-94b0881427c9120e5e638872840e24297bad2a68.zip |
SCUMM: Lock the sound resource while the music is playing
After some discussion on #scummvm, the player now locks the sound
resource while the music is playing. This prevents the resource
manager from expiring the resource, which at best could cause
music to restart where it shouldn't.. At worst, I guess it could
have crashed, but I never saw that happen.
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/player_mac.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/engines/scumm/player_mac.cpp b/engines/scumm/player_mac.cpp index 2286a158ab..ef97c2d452 100644 --- a/engines/scumm/player_mac.cpp +++ b/engines/scumm/player_mac.cpp @@ -25,6 +25,7 @@ #include "engines/engine.h" #include "gui/message.h" #include "scumm/player_mac.h" +#include "scumm/resource.h" #include "scumm/scumm.h" #include "scumm/imuse/imuse.h" @@ -163,6 +164,9 @@ void Player_Mac::setMusicVolume(int vol) { } void Player_Mac::stopAllSounds_Internal() { + if (_soundPlaying != -1) { + _vm->_res->unlock(rtSound, _soundPlaying); + } _soundPlaying = -1; for (int i = 0; i < _numberOfChannels; i++) { // The channel data is managed by the resource manager, so @@ -194,6 +198,8 @@ void Player_Mac::startSound(int nr) { Common::StackLock lock(_mutex); debug(5, "Player_Mac::startSound(%d)", nr); + stopAllSounds_Internal(); + const byte *ptr = _vm->getResourceAddress(rtSound, nr); assert(ptr); @@ -201,11 +207,11 @@ void Player_Mac::startSound(int nr) { return; } + _vm->_res->lock(rtSound, nr); _soundPlaying = nr; } bool Player_Mac::Channel::loadInstrument(Common::SeekableReadStream *stream) { - // Load the sound uint16 soundType = stream->readUint16BE(); if (soundType != 1) { warning("Player_Mac::loadInstrument: Unsupported sound type %d", soundType); |