aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2008-10-29 08:16:13 +0000
committerNicola Mettifogo2008-10-29 08:16:13 +0000
commit73cf59b518b2d9ebd1973b77ac41a6783140e085 (patch)
tree1aad9a36f85ee4747660ea90767b9edc28990528 /engines
parent8c5f9f94513ae2f14f9b9be8aac48e9f331cad28 (diff)
downloadscummvm-rg350-73cf59b518b2d9ebd1973b77ac41a6783140e085.tar.gz
scummvm-rg350-73cf59b518b2d9ebd1973b77ac41a6783140e085.tar.bz2
scummvm-rg350-73cf59b518b2d9ebd1973b77ac41a6783140e085.zip
Removed reference to Common::File in music code, and small cleanup.
svn-id: r34861
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/sound.cpp59
-rw-r--r--engines/parallaction/sound.h2
2 files changed, 33 insertions, 28 deletions
diff --git a/engines/parallaction/sound.cpp b/engines/parallaction/sound.cpp
index df6867a90c..90cd2b9129 100644
--- a/engines/parallaction/sound.cpp
+++ b/engines/parallaction/sound.cpp
@@ -47,7 +47,7 @@ public:
MidiPlayer(MidiDriver *driver);
~MidiPlayer();
- void play(const char *filename);
+ void play(Common::SeekableReadStream *stream);
void stop();
void updateTimer();
void adjustVolume(int diff);
@@ -93,29 +93,17 @@ MidiPlayer::~MidiPlayer() {
close();
}
-void MidiPlayer::play(const char *filename) {
- stop();
-
- if (!scumm_strnicmp(_vm->_location._name, "museo", 5)) return;
- if (!scumm_strnicmp(_vm->_location._name, "intgrottadopo", 13)) return;
- if (!scumm_strnicmp(_vm->_location._name, "caveau", 6)) return;
- if (!scumm_strnicmp(_vm->_location._name, "estgrotta", 9)) return;
- if (!scumm_strnicmp(_vm->_location._name, "plaza1", 6)) return;
- if (!scumm_strnicmp(_vm->_location._name, "endtgz", 6)) return;
-
- char path[PATH_LEN];
- sprintf(path, "%s.mid", filename);
-
- Common::File stream;
-
- if (!stream.open(path))
+void MidiPlayer::play(Common::SeekableReadStream *stream) {
+ if (!stream) {
+ stop();
return;
+ }
- int size = stream.size();
+ int size = stream->size();
_midiData = (uint8 *)malloc(size);
if (_midiData) {
- stream.read(_midiData, size);
+ stream->read(_midiData, size);
_mutex.lock();
_parser->loadMusic(_midiData, size);
_parser->setTrack(0);
@@ -239,10 +227,32 @@ DosSoundMan::~DosSoundMan() {
delete _midiPlayer;
}
+bool DosSoundMan::isLocationSilent(const char *locationName) {
+
+ // these are the prefixes for location names with no background midi music
+ const char *noMusicPrefix[] = { "museo", "intgrottadopo", "caveau", "estgrotta", "plaza1", "endtgz", "common", 0 };
+ Common::String s(locationName);
+
+ for (int i = 0; noMusicPrefix[i]; i++) {
+ if (s.hasPrefix(noMusicPrefix[i])) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void DosSoundMan::playMusic() {
debugC(1, kDebugAudio, "DosSoundMan::playMusic()");
- _midiPlayer->play(_musicFile);
+ if (isLocationSilent(_vm->_location._name)) {
+ // just stop the music if this location is silent
+ _midiPlayer->stop();
+ return;
+ }
+
+ Common::SeekableReadStream *stream = _vm->_disk->loadMusic(_musicFile);
+ _midiPlayer->play(stream);
}
void DosSoundMan::stopMusic() {
@@ -291,14 +301,7 @@ void DosSoundMan::playLocationMusic(const char *location) {
debugC(2, kDebugExec, "changeLocation: started music 'soft'");
}
- if (!scumm_stricmp(location, "museo") ||
- !scumm_stricmp(location, "caveau") ||
- !scumm_strnicmp(location, "plaza1", 6) ||
- !scumm_stricmp(location, "estgrotta") ||
- !scumm_stricmp(location, "intgrottadopo") ||
- !scumm_stricmp(location, "endtgz") ||
- !scumm_stricmp(location, "common")) {
-
+ if (isLocationSilent(location)) {
stopMusic();
_musicData1 = 1;
diff --git a/engines/parallaction/sound.h b/engines/parallaction/sound.h
index e8360d47b8..e2e15fe601 100644
--- a/engines/parallaction/sound.h
+++ b/engines/parallaction/sound.h
@@ -70,6 +70,8 @@ class DosSoundMan : public SoundMan {
MidiPlayer *_midiPlayer;
int _musicData1;
+ bool isLocationSilent(const char *locationName);
+
public:
DosSoundMan(Parallaction *vm, MidiDriver *midiDriver);
~DosSoundMan();