diff options
author | athrxx | 2011-05-29 01:01:07 +0200 |
---|---|---|
committer | unknown | 2011-05-29 01:04:08 +0200 |
commit | d7f877b3ab080b8e01bd6d55d2b52114dfe0f5fa (patch) | |
tree | 4ce775c78b65b493c17d3c6e1a4ac75e88d45267 /engines | |
parent | c60807cbb9dec063c0b00f8d6ffdb19e83db48f3 (diff) | |
download | scummvm-rg350-d7f877b3ab080b8e01bd6d55d2b52114dfe0f5fa.tar.gz scummvm-rg350-d7f877b3ab080b8e01bd6d55d2b52114dfe0f5fa.tar.bz2 scummvm-rg350-d7f877b3ab080b8e01bd6d55d2b52114dfe0f5fa.zip |
KYRA: pause midi sounds while gmm is running
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/sound.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/sound.h | 8 | ||||
-rw-r--r-- | engines/kyra/sound_intern.h | 2 | ||||
-rw-r--r-- | engines/kyra/sound_midi.cpp | 20 |
5 files changed, 34 insertions, 2 deletions
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 7f4f1ec2c7..75df1d148b 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -84,7 +84,7 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags) } void KyraEngine_v1::pauseEngineIntern(bool pause) { - Engine::pauseEngineIntern(pause); + _sound->pause(pause); _timer->pause(pause); } diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index 4da35cc28b..3713537afd 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -43,6 +43,10 @@ Sound::Sound(KyraEngine_v1 *vm, Audio::Mixer *mixer) Sound::~Sound() { } +void Sound::pause(bool paused) { + _mixer->pauseAll(paused); +} + bool Sound::voiceFileIsPresent(const char *file) { for (int i = 0; _supportedCodecs[i].fileext; ++i) { Common::String f = file; diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 4f8e54212f..566b37ff43 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -101,7 +101,7 @@ public: /** * Load a sound file for playing music - * (and somtimes sound effects) from. + * (and sometimes sound effects) from. */ virtual void loadSoundFile(Common::String file) = 0; @@ -153,6 +153,11 @@ public: */ virtual void beginFadeOut() = 0; + /** + * Stops all audio playback when paused. Continues after end of pause. + */ + virtual void pause(bool paused); + void enableMusic(int enable) { _musicEnabled = enable; } int musicEnabled() const { return _musicEnabled; } void enableSFX(bool enable) { _sfxEnabled = enable; } @@ -275,6 +280,7 @@ public: void stopAllSoundEffects() { _sfx->stopAllSoundEffects(); } void beginFadeOut() { _music->beginFadeOut(); } + void pause(bool paused) { _music->pause(paused); _sfx->pause(paused); } private: Sound *_music, *_sfx; }; diff --git a/engines/kyra/sound_intern.h b/engines/kyra/sound_intern.h index e9cffd88e8..2ba0890789 100644 --- a/engines/kyra/sound_intern.h +++ b/engines/kyra/sound_intern.h @@ -71,6 +71,8 @@ public: void stopAllSoundEffects(); void beginFadeOut(); + + void pause(bool paused); private: static void onTimer(void *data); diff --git a/engines/kyra/sound_midi.cpp b/engines/kyra/sound_midi.cpp index 00f6c9329e..6c003d0a11 100644 --- a/engines/kyra/sound_midi.cpp +++ b/engines/kyra/sound_midi.cpp @@ -714,6 +714,26 @@ void SoundMidiPC::beginFadeOut() { _fadeStartTime = _vm->_system->getMillis(); } +void SoundMidiPC::pause(bool paused) { + // Stop all mixer related sounds + Sound::pause(paused); + + Common::StackLock lock(_mutex); + + if (paused) { + _music->setMidiDriver(0); + for (int i = 0; i < 3; i++) + _sfx[i]->setMidiDriver(0); + for (int i = 0; i < 16; i++) + _output->stopNotesOnChannel(i); + } else { + _music->setMidiDriver(_output); + for (int i = 0; i < 3; ++i) + _sfx[i]->setMidiDriver(_output); + // Possible TODO (IMHO unnecessary): restore notes and/or update _fadeStartTime + } +} + void SoundMidiPC::onTimer(void *data) { SoundMidiPC *midi = (SoundMidiPC *)data; |