aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2011-01-07 16:00:08 +0000
committerNicola Mettifogo2011-01-07 16:00:08 +0000
commit9dd0e0f94c5c05dc09693936eb49b3f6706df750 (patch)
treee91583e95f445e4e0d1216b020bb374ed810cb32
parent75d7ee9bd61b52dfd145a0e06365393531d265e7 (diff)
downloadscummvm-rg350-9dd0e0f94c5c05dc09693936eb49b3f6706df750.tar.gz
scummvm-rg350-9dd0e0f94c5c05dc09693936eb49b3f6706df750.tar.bz2
scummvm-rg350-9dd0e0f94c5c05dc09693936eb49b3f6706df750.zip
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
-rw-r--r--engines/parallaction/sound.h4
-rw-r--r--engines/parallaction/sound_ns.cpp45
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<char*>(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());
+ }
}