diff options
author | Torbjörn Andersson | 2004-08-27 08:31:33 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2004-08-27 08:31:33 +0000 |
commit | f004af9d4fe743730ec3fc254db2e0e652379387 (patch) | |
tree | 65a1c4697134559a6460bc6142bb09ea811d0caa /sword2/driver | |
parent | d1d308ff743c85fd91d45bf8a2e2a7f9507b6ced (diff) | |
download | scummvm-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
Diffstat (limited to 'sword2/driver')
-rw-r--r-- | sword2/driver/d_sound.cpp | 32 | ||||
-rw-r--r-- | sword2/driver/d_sound.h | 4 |
2 files changed, 18 insertions, 18 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); |