diff options
author | Nicola Mettifogo | 2009-01-06 16:21:23 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2009-01-06 16:21:23 +0000 |
commit | fa1d881ad44a515e57b87ba27b325d1eeb4a750b (patch) | |
tree | 35183034e8e725b83502983b4c5cf94a5b489fa2 | |
parent | c528f888d0c227bc735a3ba2110ad9708bc1abd8 (diff) | |
download | scummvm-rg350-fa1d881ad44a515e57b87ba27b325d1eeb4a750b.tar.gz scummvm-rg350-fa1d881ad44a515e57b87ba27b325d1eeb4a750b.tar.bz2 scummvm-rg350-fa1d881ad44a515e57b87ba27b325d1eeb4a750b.zip |
Implemented pauseEngineIntern, and fixed music volume handling in SoundMan.
svn-id: r35756
-rw-r--r-- | engines/parallaction/parallaction.cpp | 6 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 1 | ||||
-rw-r--r-- | engines/parallaction/sound.cpp | 29 | ||||
-rw-r--r-- | engines/parallaction/sound.h | 4 |
4 files changed, 37 insertions, 3 deletions
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 272152cd69..e1f26874e8 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -134,6 +134,12 @@ Common::Error Parallaction::init() { return Common::kNoError; } +void Parallaction::pauseEngineIntern(bool pause) { + if (_soundMan) { + _soundMan->pause(pause); + } +} + bool canScroll() { return (_vm->_gfx->_backgroundInfo->width > _vm->_screenWidth); } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index f7c79e1a3c..e5af0df7b9 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -253,6 +253,7 @@ public: // Engine APIs virtual Common::Error init(); virtual bool hasFeature(EngineFeature f) const; + virtual void pauseEngineIntern(bool pause); // info int32 _screenWidth; diff --git a/engines/parallaction/sound.cpp b/engines/parallaction/sound.cpp index 8c6174a0db..503f8b3303 100644 --- a/engines/parallaction/sound.cpp +++ b/engines/parallaction/sound.cpp @@ -49,6 +49,7 @@ public: void play(Common::SeekableReadStream *stream); void stop(); + void pause(bool p); void updateTimer(); void adjustVolume(int diff); void setVolume(int volume); @@ -74,6 +75,7 @@ private: uint8 *_midiData; bool _isLooping; bool _isPlaying; + bool _paused; int _masterVolume; MidiChannel *_channelsTable[NUM_CHANNELS]; uint8 _channelsVolume[NUM_CHANNELS]; @@ -81,10 +83,12 @@ private: }; MidiPlayer::MidiPlayer(MidiDriver *driver) - : _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0) { + : _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _paused(false), _masterVolume(0) { assert(_driver); memset(_channelsTable, 0, sizeof(_channelsTable)); - memset(_channelsVolume, 0, sizeof(_channelsVolume)); + for (int i = 0; i < NUM_CHANNELS; i++) { + _channelsVolume[i] = 127; + } open(); } @@ -125,7 +129,21 @@ void MidiPlayer::stop() { _mutex.unlock(); } +void MidiPlayer::pause(bool p) { + _paused = p; + + for (int i = 0; i < NUM_CHANNELS; ++i) { + if (_channelsTable[i]) { + _channelsTable[i]->volume(_paused ? 0 : _channelsVolume[i] * _masterVolume / 255); + } + } +} + void MidiPlayer::updateTimer() { + if (_paused) { + return; + } + _mutex.lock(); if (_isPlaying) { _parser->onTimer(); @@ -217,7 +235,6 @@ void MidiPlayer::timerCallback(void *p) { player->updateTimer(); } - DosSoundMan::DosSoundMan(Parallaction *vm, MidiDriver *midiDriver) : SoundMan(vm), _musicData1(0) { _midiPlayer = new MidiPlayer(midiDriver); } @@ -254,12 +271,18 @@ void DosSoundMan::playMusic() { Common::SeekableReadStream *stream = _vm->_disk->loadMusic(_musicFile); _midiPlayer->play(stream); + _midiPlayer->setVolume(255); } void DosSoundMan::stopMusic() { _midiPlayer->stop(); } +void DosSoundMan::pause(bool p) { + SoundMan::pause(p); + _midiPlayer->pause(p); +} + void DosSoundMan::playCharacterMusic(const char *character) { if (character == NULL) { return; diff --git a/engines/parallaction/sound.h b/engines/parallaction/sound.h index e2e15fe601..2baa9aaa63 100644 --- a/engines/parallaction/sound.h +++ b/engines/parallaction/sound.h @@ -62,6 +62,8 @@ public: virtual void stopMusic() = 0; virtual void playCharacterMusic(const char *character) = 0; virtual void playLocationMusic(const char *location) = 0; + virtual void pause(bool p) { } + void setMusicVolume(int value); }; @@ -80,6 +82,8 @@ public: void playCharacterMusic(const char *character); void playLocationMusic(const char *location); + + void pause(bool p); }; #define NUM_AMIGA_CHANNELS 4 |