From 5d6771e3df2ecba333faf98c042c3357c0e40c1c Mon Sep 17 00:00:00 2001 From: Arnaud Boutonné Date: Sat, 1 Jan 2011 10:51:57 +0000 Subject: HUGO: Midi are no longer looping. Add handling to default playlist svn-id: r55084 --- engines/hugo/hugo.cpp | 1 + engines/hugo/sound.cpp | 20 +++++++++++++++++++- engines/hugo/sound.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'engines/hugo') diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp index 0e9e4d0ca1..0dc062a0bc 100644 --- a/engines/hugo/hugo.cpp +++ b/engines/hugo/hugo.cpp @@ -374,6 +374,7 @@ void HugoEngine::runMachine() { _mouse->mouseHandler(); // Mouse activity - adds to display list _screen->drawStatusText(); _screen->displayList(D_DISPLAY); // Blit the display list to screen + _sound->checkMusic(); break; case V_INVENT: // Accessing inventory _inventory->runInventory(); // Process Inventory state machine diff --git a/engines/hugo/sound.cpp b/engines/hugo/sound.cpp index 5f3ac52db6..8be6efcdca 100644 --- a/engines/hugo/sound.cpp +++ b/engines/hugo/sound.cpp @@ -73,7 +73,7 @@ void MidiPlayer::play(uint8 *stream, uint16 size) { syncVolume(); _parser->loadMusic(_midiData, size); _parser->setTrack(0); - _isLooping = true; + _isLooping = false; _isPlaying = true; _mutex.unlock(); } @@ -345,4 +345,22 @@ void SoundHandler::syncVolume() { _midiPlayer->syncVolume(); } +/** +* Check if music is still playing. +* If not, select the next track in the playlist and play it +*/ +void SoundHandler::checkMusic() { + if (_midiPlayer->isPlaying()) + return; + + for (int i = 0; _vm->_defltTunes[i] != -1; i++) { + if (_vm->_defltTunes[i] == _vm->getGameStatus().song) { + if (_vm->_defltTunes[i + 1] != -1) + playMusic(_vm->_defltTunes[i + 1]); + else + playMusic(_vm->_defltTunes[0]); + break; + } + } +} } // End of namespace Hugo diff --git a/engines/hugo/sound.h b/engines/hugo/sound.h index 4a7f6ac21f..91a50fe24f 100644 --- a/engines/hugo/sound.h +++ b/engines/hugo/sound.h @@ -59,6 +59,7 @@ public: void syncVolume(); int getVolume() const { return _masterVolume; } void setLooping(bool loop) { _isLooping = loop; } + bool isPlaying() { return _isPlaying; } // MidiDriver interface int open(); @@ -98,6 +99,7 @@ public: void playSound(int16 sound, stereo_t channel, byte priority); void initSound(); void syncVolume(); + void checkMusic(); private: HugoEngine *_vm; -- cgit v1.2.3