From 9dd0e0f94c5c05dc09693936eb49b3f6706df750 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Fri, 7 Jan 2011 16:00:08 +0000 Subject: PARALLACTION: fix music playback (bug #2879793). * Do not restart character theme is already playing. * Play the correct tune in the night club. * Do not play muisc in the location meant to be silent. svn-id: r55147 --- engines/parallaction/sound.h | 4 ++-- engines/parallaction/sound_ns.cpp | 45 +++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/engines/parallaction/sound.h b/engines/parallaction/sound.h index 01eebfcc2d..1efbb17395 100644 --- a/engines/parallaction/sound.h +++ b/engines/parallaction/sound.h @@ -133,8 +133,8 @@ public: class DosSoundMan_ns : public SoundMan_ns { MidiPlayer *_midiPlayer; - int _musicData1; - + bool _playing; + bool isLocationSilent(const char *locationName); bool locationHasOwnSoftMusic(const char *locationName); diff --git a/engines/parallaction/sound_ns.cpp b/engines/parallaction/sound_ns.cpp index 431d2a1f4c..1ed45befa9 100644 --- a/engines/parallaction/sound_ns.cpp +++ b/engines/parallaction/sound_ns.cpp @@ -236,7 +236,7 @@ void MidiPlayer::timerCallback(void *p) { player->updateTimer(); } -DosSoundMan_ns::DosSoundMan_ns(Parallaction_ns *vm, MidiDriver *midiDriver) : SoundMan_ns(vm), _musicData1(0) { +DosSoundMan_ns::DosSoundMan_ns(Parallaction_ns *vm, MidiDriver *midiDriver) : SoundMan_ns(vm), _playing(false) { _midiPlayer = new MidiPlayer(midiDriver); } @@ -273,10 +273,15 @@ void DosSoundMan_ns::playMusic() { Common::SeekableReadStream *stream = _vm->_disk->loadMusic(_musicFile); _midiPlayer->play(stream); _midiPlayer->setVolume(255); + + _playing = true; } void DosSoundMan_ns::stopMusic() { + _musicFile[0] = 0; _midiPlayer->stop(); + + _playing = false; } void DosSoundMan_ns::pause(bool p) { @@ -289,52 +294,46 @@ bool DosSoundMan_ns::locationHasOwnSoftMusic(const char *locationName) { } void DosSoundMan_ns::playCharacterMusic(const char *character) { - if (character == NULL) { - return; - } - - if (locationHasOwnSoftMusic(_vm->_location._name)) { + if (!character || locationHasOwnSoftMusic(_vm->_location._name)) { return; } char *name = const_cast(character); - + const char *newMusicFile = 0; + if (!scumm_stricmp(name, _dinoName)) { - setMusicFile("dino"); + newMusicFile = "dino"; } else if (!scumm_stricmp(name, _donnaName)) { - setMusicFile("donna"); + newMusicFile = "donna"; } else if (!scumm_stricmp(name, _doughName)) { - setMusicFile("nuts"); + newMusicFile = "nuts"; } else { warning("unknown character '%s' in DosSoundMan_ns_ns::playCharacterMusic", character); return; } - playMusic(); + if (!_playing || (newMusicFile && scumm_stricmp(newMusicFile, _musicFile))) { + // avoid restarting the same piece + setMusicFile(newMusicFile); + playMusic(); + debugC(2, kDebugExec, "changeLocation: started character specific music (%s)", newMusicFile); + } } void DosSoundMan_ns::playLocationMusic(const char *location) { - if (_musicData1 != 0) { - playCharacterMusic(_vm->_char.getBaseName()); - _musicData1 = 0; - debugC(2, kDebugExec, "changeLocation: started character specific music"); - } - if (locationHasOwnSoftMusic(location)) { setMusicFile("soft"); playMusic(); - debugC(2, kDebugExec, "changeLocation: started music 'soft'"); - } - + } else if (isLocationSilent(location)) { stopMusic(); - _musicData1 = 1; - debugC(2, kDebugExec, "changeLocation: music stopped"); - } + } else { + playCharacterMusic(_vm->_char.getBaseName()); + } } -- cgit v1.2.3