aboutsummaryrefslogtreecommitdiff
path: root/engines/queen/sound.cpp
diff options
context:
space:
mode:
authorGregory Montoir2006-11-23 22:10:25 +0000
committerGregory Montoir2006-11-23 22:10:25 +0000
commitd47d545631fb37528ccad4c993d599c799591dc4 (patch)
treed01e9a2d6e3bcf74949d590d8b499a01fcdf1e7c /engines/queen/sound.cpp
parent1114480ece2c96b694ce0860c9f7af5fecf15ffa (diff)
downloadscummvm-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
Diffstat (limited to 'engines/queen/sound.cpp')
-rw-r--r--engines/queen/sound.cpp42
1 files changed, 32 insertions, 10 deletions
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;