aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-08-27 08:31:33 +0000
committerTorbjörn Andersson2004-08-27 08:31:33 +0000
commitf004af9d4fe743730ec3fc254db2e0e652379387 (patch)
tree65a1c4697134559a6460bc6142bb09ea811d0caa
parentd1d308ff743c85fd91d45bf8a2e2a7f9507b6ced (diff)
downloadscummvm-rg350-f004af9d4fe743730ec3fc254db2e0e652379387.tar.gz
scummvm-rg350-f004af9d4fe743730ec3fc254db2e0e652379387.tar.bz2
scummvm-rg350-f004af9d4fe743730ec3fc254db2e0e652379387.zip
Use the same code for opening the music clusters as for opening the speech
clusters. (No, that doesn't mean compressed music is support yet. This is just a tiny little step closer.) svn-id: r14794
-rw-r--r--sword2/driver/d_sound.cpp32
-rw-r--r--sword2/driver/d_sound.h4
-rw-r--r--sword2/sound.cpp19
3 files changed, 19 insertions, 36 deletions
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index cdba64c023..a87fcc8c6d 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -86,9 +86,8 @@ CLUInputStream::CLUInputStream(File *file, int size)
// Determine the end position.
_end_pos = file->pos() + size;
- _prev = _file->readUint16LE();
-
// Read in initial data
+ _prev = _file->readUint16LE();
refill();
}
@@ -359,16 +358,7 @@ void MusicHandle::fadeUp(void) {
}
}
-int32 MusicHandle::play(const char *filename, uint32 musicId, bool looping) {
- // The assumption here is that we are never playing music from two
- // different files at the same time.
-
- if (!fpMus.isOpen())
- fpMus.open(filename);
-
- if (!fpMus.isOpen())
- return RDERR_INVALIDFILENAME;
-
+int32 MusicHandle::play(uint32 musicId, bool looping) {
fpMus.seek((musicId + 1) * 8, SEEK_SET);
_fileStart = fpMus.readUint32LE();
@@ -669,7 +659,7 @@ void Sound::waitForLeadOut(void) {
* @return RD_OK or an error code
*/
-int32 Sound::streamCompMusic(const char *filename, uint32 musicId, bool looping) {
+int32 Sound::streamCompMusic(uint32 musicId, bool looping) {
Common::StackLock lock(_mutex);
int32 primaryStream = -1;
@@ -722,7 +712,19 @@ int32 Sound::streamCompMusic(const char *filename, uint32 musicId, bool looping)
if (secondaryStream != -1)
_music[secondaryStream].fadeDown();
- return _music[primaryStream].play(filename, musicId, looping);
+ // The assumption here is that we are never playing music from two
+ // different files at the same time.
+
+ if (!fpMus.isOpen()) {
+ // TODO: We don't support compressed music yet. Patience.
+ if (openSoundFile(&fpMus, "music") != kCLUMode)
+ return RD_OK;
+ }
+
+ if (!fpMus.isOpen())
+ return RDERR_INVALIDFILENAME;
+
+ return _music[primaryStream].play(musicId, looping);
}
int32 Sound::dipMusic(void) {
@@ -938,7 +940,6 @@ int32 Sound::amISpeaking(void) {
* This function loads and decompresses a list of speech from a cluster, but
* does not play it. This is used for cutscene voice-overs, presumably to
* avoid having to read from more than one file on the CD during playback.
- * @param filename the file name of the speech cluster file
* @param speechid the text line id used to reference the speech
* @param buf a pointer to the buffer that will be allocated for the sound
*/
@@ -973,7 +974,6 @@ uint32 Sound::preFetchCompSpeech(uint32 speechid, uint16 **buf) {
/**
* This function loads, decompresses and plays a line of speech. An error
* occurs if speech is already playing.
- * @param filename the name of the speech cluster file
* @param speechid the text line id used to reference the speech
* @param vol volume, 0 (minimum) to 16 (maximum)
* @param pan panning, -16 (full left) to 16 (full right)
diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h
index 210549e4df..637c4cd522 100644
--- a/sword2/driver/d_sound.h
+++ b/sword2/driver/d_sound.h
@@ -73,7 +73,7 @@ public:
void fadeDown(void);
void fadeUp(void);
- int32 play(const char *filename, uint32 musicId, bool looping);
+ int32 play(uint32 musicId, bool looping);
void stop(void);
int readBuffer(int16 *buffer, const int numSamples);
bool endOfData(void) const;
@@ -138,7 +138,7 @@ public:
void saveMusicState(void);
void restoreMusicState(void);
void waitForLeadOut(void);
- int32 streamCompMusic(const char *filename, uint32 musicId, bool looping);
+ int32 streamCompMusic(uint32 musicId, bool looping);
int32 musicTimeRemaining(void);
void muteSpeech(bool mute);
diff --git a/sword2/sound.cpp b/sword2/sound.cpp
index 28c4218d78..bf0e79c1c8 100644
--- a/sword2/sound.cpp
+++ b/sword2/sound.cpp
@@ -326,24 +326,7 @@ int32 Logic::fnPlayMusic(int32 *params) {
_vm->_loopingMusicId = 0;
}
- // add the appropriate file extension & play it
-
- if (_scriptVars[DEMO]) {
- // The demo I found didn't come with any music file, but you
- // could use the music from the first CD of the complete game,
- // I suppose...
- strcpy(filename, "music.clu");
- } else {
- File f;
-
- sprintf(filename, "music%d.clu", _vm->_resman->whichCd());
- if (f.open(filename))
- f.close();
- else
- strcpy(filename, "music.clu");
- }
-
- rv = _vm->_sound->streamCompMusic(filename, params[0], loopFlag);
+ rv = _vm->_sound->streamCompMusic(params[0], loopFlag);
if (rv)
debug(5, "ERROR: streamCompMusic(%s, %d, %d) returned error 0x%.8x", filename, params[0], loopFlag, rv);