diff options
author | Filippos Karapetis | 2007-06-26 23:40:22 +0000 |
---|---|---|
committer | Filippos Karapetis | 2007-06-26 23:40:22 +0000 |
commit | 137862b00b6f97b8ab94273a0bd162d6f78c8e8c (patch) | |
tree | 0a212523bc75a67340a770646de9677a7091a595 | |
parent | 9263d7cd6c2cf5d549db6006d1f8dd336689c8db (diff) | |
download | scummvm-rg350-137862b00b6f97b8ab94273a0bd162d6f78c8e8c.tar.gz scummvm-rg350-137862b00b6f97b8ab94273a0bd162d6f78c8e8c.tar.bz2 scummvm-rg350-137862b00b6f97b8ab94273a0bd162d6f78c8e8c.zip |
Add support for compressed digital music in ITE
svn-id: r27734
-rw-r--r-- | engines/saga/music.cpp | 58 | ||||
-rw-r--r-- | engines/saga/music.h | 3 |
2 files changed, 59 insertions, 2 deletions
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 27729247ef..b74bd4818d 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -354,7 +354,7 @@ bool Music::isPlaying() { void Music::play(uint32 resourceId, MusicFlags flags) { Audio::AudioStream *audioStream = NULL; MidiParser *parser; - ResourceContext *context; + ResourceContext *context = NULL; byte *resourceData; size_t resourceSize; uint32 loopStart; @@ -413,7 +413,61 @@ void Music::play(uint32 resourceId, MusicFlags flags) { loopStart = 4 * 18727; } - audioStream = new RAWInputStream(_vm, _musicContext, resourceId - 9, flags == MUSIC_LOOP, loopStart); + if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) { + // uncompressed digital music + audioStream = new RAWInputStream(_vm, _musicContext, resourceId - 9, flags == MUSIC_LOOP, loopStart); + } else { + // compressed digital music + ResourceData * resourceData; + Common::File *_file; + byte compressedHeader[10]; + GameSoundTypes soundType; + + resourceData = _vm->_resource->getResourceData(_musicContext, resourceId - 9); + _file = _musicContext->getFile(resourceData); + + if (_vm->getMusicInfo() == NULL) { + error("RAWInputStream() wrong musicInfo"); + } + + _file->seek((long)resourceData->offset, SEEK_SET); + + _file->read(compressedHeader, 9); + + if (compressedHeader[0] == char(0)) { + soundType = kSoundMP3; + } else if (compressedHeader[0] == char(1)) { + soundType = kSoundOGG; + } else if (compressedHeader[0] == char(2)) { + soundType = kSoundFLAC; + } + + switch (soundType) { +#ifdef USE_MAD + case kSoundMP3: + debug(1, "Playing MP3 compressed digital music"); + audioStream = Audio::makeMP3Stream(_file, resourceData->size); + break; +#endif +#ifdef USE_VORBIS + case kSoundOGG: + debug(1, "Playing OGG compressed digital music"); + audioStream = Audio::makeVorbisStream(_file, resourceData->size); + break; +#endif +#ifdef USE_FLAC + case kSoundFLAC: + debug(1, "Playing FLAC compressed digital music"); + audioStream = Audio::makeFlacStream(_file, resourceData->size); + break; +#endif + default: + // Unknown compression + error("Trying to play a compressed digital music, but the compression is not known"); + break; + } + + } } } } diff --git a/engines/saga/music.h b/engines/saga/music.h index 125c85aa9b..96d8608bcd 100644 --- a/engines/saga/music.h +++ b/engines/saga/music.h @@ -31,6 +31,9 @@ #include "sound/audiocd.h" #include "sound/mididrv.h" #include "sound/midiparser.h" +#include "sound/mp3.h" +#include "sound/vorbis.h" +#include "sound/flac.h" namespace Saga { |