diff options
author | Matthew Hoops | 2011-01-19 16:52:47 +0000 |
---|---|---|
committer | Matthew Hoops | 2011-01-19 16:52:47 +0000 |
commit | 918a21cd7b0a6a3a99815338441a127cd54d794a (patch) | |
tree | 15ba535aaf53eb4e3019ae05437c25b64cbb21ae | |
parent | 6b123c0d113ba20e994fdf7064d9550b39be7ec5 (diff) | |
download | scummvm-rg350-918a21cd7b0a6a3a99815338441a127cd54d794a.tar.gz scummvm-rg350-918a21cd7b0a6a3a99815338441a127cd54d794a.tar.bz2 scummvm-rg350-918a21cd7b0a6a3a99815338441a127cd54d794a.zip |
MOHAWK: Use a separate SndHandle for Myst's background sound
svn-id: r55330
-rw-r--r-- | engines/mohawk/sound.cpp | 48 | ||||
-rw-r--r-- | engines/mohawk/sound.h | 6 |
2 files changed, 25 insertions, 29 deletions
diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index 4efe1371d9..f19a38e67d 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -45,6 +45,7 @@ Sound::Sound(MohawkEngine* vm) : _vm(vm) { Sound::~Sound() { stopSound(); stopAllSLST(); + stopBackgroundMyst(); if (_midiParser) { _midiParser->unloadMusic(); @@ -581,18 +582,16 @@ uint16 Sound::convertMystID(uint16 id) { } Audio::SoundHandle *Sound::replaceBackgroundMyst(uint16 id, uint16 volume) { - debug (0, "Replacing background %d", id); + debug(0, "Replacing background sound with %d", id); // TODO: The original engine does fading Common::String name = _vm->getResourceName(ID_MSND, convertMystID(id)); // Check if sound is already playing - for (uint32 i = 0; i < _handles.size(); i++) - if (_handles[i].type == kBackgroundHandle - && _vm->_mixer->isSoundHandleActive(_handles[i].handle) - && name.equals(_vm->getResourceName(ID_MSND, convertMystID(_handles[i].id)))) - return &_handles[i].handle; + if (_mystBackgroundSound.type == kUsedHandle && _vm->_mixer->isSoundHandleActive(_mystBackgroundSound.handle) + && name.equals(_vm->getResourceName(ID_MSND, convertMystID(_mystBackgroundSound.id)))) + return &_mystBackgroundSound.handle; // Stop old background sound stopBackgroundMyst(); @@ -601,46 +600,41 @@ Audio::SoundHandle *Sound::replaceBackgroundMyst(uint16 id, uint16 volume) { Audio::AudioStream *audStream = makeAudioStream(id); if (audStream) { - SndHandle *handle = getHandle(); - handle->type = kBackgroundHandle; - handle->id = id; - handle->samplesPerSecond = audStream->getRate(); + _mystBackgroundSound.type = kUsedHandle; + _mystBackgroundSound.id = id; + _mystBackgroundSound.samplesPerSecond = audStream->getRate(); // Set the stream to loop audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream *)audStream, 0); - _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle->handle, audStream, -1, volume >> 8); - return &handle->handle; + _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_mystBackgroundSound.handle, audStream, -1, volume >> 8); + return &_mystBackgroundSound.handle; } return NULL; } void Sound::stopBackgroundMyst() { - for (uint32 i = 0; i < _handles.size(); i++) - if (_handles[i].type == kBackgroundHandle) { - _vm->_mixer->stopHandle(_handles[i].handle); - _handles[i].type = kFreeHandle; - _handles[i].id = 0; - } + if (_mystBackgroundSound.type == kUsedHandle) { + _vm->_mixer->stopHandle(_mystBackgroundSound.handle); + _mystBackgroundSound.type = kFreeHandle; + _mystBackgroundSound.id = 0; + } } void Sound::pauseBackgroundMyst() { - for (uint32 i = 0; i < _handles.size(); i++) - if (_handles[i].type == kBackgroundHandle) - _vm->_mixer->pauseHandle(_handles[i].handle, true); + if (_mystBackgroundSound.type == kUsedHandle) + _vm->_mixer->pauseHandle(_mystBackgroundSound.handle, true); } void Sound::resumeBackgroundMyst() { - for (uint32 i = 0; i < _handles.size(); i++) - if (_handles[i].type == kBackgroundHandle) - _vm->_mixer->pauseHandle(_handles[i].handle, false); + if (_mystBackgroundSound.type == kUsedHandle) + _vm->_mixer->pauseHandle(_mystBackgroundSound.handle, false); } void Sound::changeBackgroundVolumeMyst(uint16 vol) { - for (uint32 i = 0; i < _handles.size(); i++) - if (_handles[i].type == kBackgroundHandle) - _vm->_mixer->setChannelVolume(_handles[i].handle, vol >> 8); + if (_mystBackgroundSound.type == kUsedHandle) + _vm->_mixer->setChannelVolume(_mystBackgroundSound.handle, vol >> 8); } } // End of namespace Mohawk diff --git a/engines/mohawk/sound.h b/engines/mohawk/sound.h index e2481f6428..7914dd40fc 100644 --- a/engines/mohawk/sound.h +++ b/engines/mohawk/sound.h @@ -59,8 +59,7 @@ struct SLSTRecord { enum SndHandleType { kFreeHandle, - kUsedHandle, - kBackgroundHandle + kUsedHandle }; struct SndHandle { @@ -163,6 +162,9 @@ private: Audio::AudioStream *makeAudioStream(uint16 id, CueList *cueList = NULL); uint16 convertMystID(uint16 id); + // Myst-specific + SndHandle _mystBackgroundSound; + // Riven-specific void playSLSTSound(uint16 index, bool fade, bool loop, uint16 volume, int16 balance); void stopSLSTSound(uint16 id, bool fade); |