diff options
author | Gregory Montoir | 2006-11-23 22:10:25 +0000 |
---|---|---|
committer | Gregory Montoir | 2006-11-23 22:10:25 +0000 |
commit | d47d545631fb37528ccad4c993d599c799591dc4 (patch) | |
tree | d01e9a2d6e3bcf74949d590d8b499a01fcdf1e7c | |
parent | 1114480ece2c96b694ce0860c9f7af5fecf15ffa (diff) | |
download | scummvm-rg350-d47d545631fb37528ccad4c993d599c799591dc4.tar.gz scummvm-rg350-d47d545631fb37528ccad4c993d599c799591dc4.tar.bz2 scummvm-rg350-d47d545631fb37528ccad4c993d599c799591dc4.zip |
Fix for bug #1599393 - FOTAQ: clicks at the beginning of speech. English talkie version (and probably others) has 2 different .SB file formats, with a different size for the header data. Added code to detect that.
svn-id: r24775
-rw-r--r-- | engines/queen/resource.cpp | 2 | ||||
-rw-r--r-- | engines/queen/resource.h | 2 | ||||
-rw-r--r-- | engines/queen/sound.cpp | 42 |
3 files changed, 34 insertions, 12 deletions
diff --git a/engines/queen/resource.cpp b/engines/queen/resource.cpp index e51f641287..6f75439376 100644 --- a/engines/queen/resource.cpp +++ b/engines/queen/resource.cpp @@ -257,7 +257,7 @@ const RetailGameVersion *Resource::detectGameVersionFromSize(uint32 size) { return NULL; } -Common::File *Resource::giveCompressedSound(const char *filename, uint32 *size) { +Common::File *Resource::giveSound(const char *filename, uint32 *size) { assert(strstr(filename, ".SB")); Common::File *f = NULL; ResourceEntry *re = resourceEntry(filename); diff --git a/engines/queen/resource.h b/engines/queen/resource.h index de97dc02c3..3ff5c1e2fc 100644 --- a/engines/queen/resource.h +++ b/engines/queen/resource.h @@ -71,7 +71,7 @@ public: bool fileExists(const char *filename) const { return resourceEntry(filename) != NULL; } //! returns a reference to a sound file - Common::File *giveCompressedSound(const char *filename, uint32 *size); + Common::File *giveSound(const char *filename, uint32 *size); bool isDemo() const { return (_version.features & GF_DEMO) != 0; } bool isInterview() const { return (_version.features & GF_INTERVIEW) != 0; } diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp index 199c2c5580..5a2e8598df 100644 --- a/engines/queen/sound.cpp +++ b/engines/queen/sound.cpp @@ -34,7 +34,8 @@ #include "sound/mp3.h" #include "sound/vorbis.h" -#define SB_HEADER_SIZE 110 +#define SB_HEADER_SIZE_V104 110 +#define SB_HEADER_SIZE_V110 122 #define STOP_MUSIC -1 namespace Queen { @@ -188,12 +189,33 @@ bool SilentSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { } bool SBSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { - if (_vm->resource()->fileExists(name)) { - uint32 size; - uint8 *sound = _vm->resource()->loadFile(name, SB_HEADER_SIZE, &size, true); - byte flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE; - _mixer->playRaw(soundHandle, sound, size, 11025, flags); - return true; + uint32 size; + Common::File *f = _vm->resource()->giveSound(name, &size); + if (f) { + int headerSize; + f->seek(2, SEEK_CUR); + uint16 version = f->readUint16LE(); + switch (version) { + case 104: + headerSize = SB_HEADER_SIZE_V104; + break; + case 110: + headerSize = SB_HEADER_SIZE_V110; + break; + default: + warning("Unhandled SB file version %d, defaulting to 104\n", version); + headerSize = SB_HEADER_SIZE_V104; + break; + } + f->seek(headerSize - 4, SEEK_CUR); + size -= headerSize; + uint8 *sound = (uint8 *)malloc(size); + if (sound) { + f->read(sound, size); + byte flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE; + _mixer->playRaw(soundHandle, sound, size, 11025, flags); + return true; + } } return false; } @@ -201,7 +223,7 @@ bool SBSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { #ifdef USE_MAD bool MP3Sound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { uint32 size; - Common::File *f = _vm->resource()->giveCompressedSound(name, &size); + Common::File *f = _vm->resource()->giveSound(name, &size); if (f) { _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeMP3Stream(f, size)); return true; @@ -213,7 +235,7 @@ bool MP3Sound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { #ifdef USE_VORBIS bool OGGSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { uint32 size; - Common::File *f = _vm->resource()->giveCompressedSound(name, &size); + Common::File *f = _vm->resource()->giveSound(name, &size); if (f) { _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeVorbisStream(f, size)); return true; @@ -225,7 +247,7 @@ bool OGGSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { #ifdef USE_FLAC bool FLACSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { uint32 size; - Common::File *f = _vm->resource()->giveCompressedSound(name, &size); + Common::File *f = _vm->resource()->giveSound(name, &size); if (f) { _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeFlacStream(f, size)); return true; |