diff options
author | Gregory Montoir | 2005-11-07 18:34:55 +0000 |
---|---|---|
committer | Gregory Montoir | 2005-11-07 18:34:55 +0000 |
commit | 99c544869861e3a2f870f21891381dec38074c04 (patch) | |
tree | c0d7ce4b81322a9dbc0ed7a627707ef957b124ec | |
parent | 7d23fafc25cba76abafc2df60aa5a49a63c6acc7 (diff) | |
download | scummvm-rg350-99c544869861e3a2f870f21891381dec38074c04.tar.gz scummvm-rg350-99c544869861e3a2f870f21891381dec38074c04.tar.bz2 scummvm-rg350-99c544869861e3a2f870f21891381dec38074c04.zip |
Don't synchronize subtitle with speech sfx if MP3/OGG/Flac support isn't compiled it. This should fix bug #1350045.
svn-id: r19495
-rw-r--r-- | queen/resource.cpp | 13 | ||||
-rw-r--r-- | queen/sound.cpp | 48 | ||||
-rw-r--r-- | queen/sound.h | 14 |
3 files changed, 45 insertions, 30 deletions
diff --git a/queen/resource.cpp b/queen/resource.cpp index fb2f32fb19..f1c3f66746 100644 --- a/queen/resource.cpp +++ b/queen/resource.cpp @@ -239,13 +239,16 @@ const GameVersion *Resource::detectGameVersion(uint32 size) const { Common::File *Resource::giveCompressedSound(const char *filename, uint32 *size) { assert(strstr(filename, ".SB")); + Common::File *f = NULL; ResourceEntry *re = resourceEntry(filename); - assert(re != NULL); - if (size != NULL) { - *size = re->size; + if (re) { + if (size != NULL) { + *size = re->size; + } + _resourceFile->seek(re->offset); + f = _resourceFile; } - _resourceFile->seek(re->offset); - return _resourceFile; + return f; } LineReader::LineReader(char *buffer, uint32 bufsize) : _buffer(buffer), _bufSize(bufsize), _current(0) { diff --git a/queen/sound.cpp b/queen/sound.cpp index 97ca635321..20bb645773 100644 --- a/queen/sound.cpp +++ b/queen/sound.cpp @@ -103,8 +103,7 @@ void Sound::playSfx(uint16 sfx, bool isSpeech) { #endif strcat(name, ".SB"); waitFinished(isSpeech); - if (_vm->resource()->fileExists(name)) { - sfxPlay(name, isSpeech); + if (sfxPlay(name, isSpeech ? &_speechHandle : &_sfxHandle)) { _speechSfxExists = isSpeech; } else { _speechSfxExists = false; @@ -125,8 +124,7 @@ void Sound::playSfx(const char *base, bool isSpeech) { } strcat(name, ".SB"); waitFinished(isSpeech); - if (_vm->resource()->fileExists(name)) { - sfxPlay(name, isSpeech); + if (sfxPlay(name, isSpeech ? &_speechHandle : &_sfxHandle)) { _speechSfxExists = isSpeech; } else { _speechSfxExists = false; @@ -186,38 +184,54 @@ void Sound::loadState(uint32 ver, byte *&ptr) { _lastOverride = (int16)READ_BE_INT16(ptr); ptr += 2; } -void SBSound::playSound(byte *sound, uint32 size, bool isSpeech) { - byte flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE; - _mixer->playRaw(isSpeech ? &_speechHandle : &_sfxHandle, sound, size, 11025, flags); +bool SilentSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { + return false; } -void SBSound::sfxPlay(const char *name, bool isSpeech) { - uint32 size; - uint8 *buf = _vm->resource()->loadFile(name, SB_HEADER_SIZE, &size, true); - playSound(buf, size, isSpeech); +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; + } + return false; } #ifdef USE_MAD -void MP3Sound::sfxPlay(const char *name, bool isSpeech) { +bool MP3Sound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { uint32 size; Common::File *f = _vm->resource()->giveCompressedSound(name, &size); - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, isSpeech ? &_speechHandle : &_sfxHandle, makeMP3Stream(f, size)); + if (f) { + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, makeMP3Stream(f, size)); + return true; + } + return false; } #endif #ifdef USE_VORBIS -void OGGSound::sfxPlay(const char *name, bool isSpeech) { +bool OGGSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { uint32 size; Common::File *f = _vm->resource()->giveCompressedSound(name, &size); - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, isSpeech ? &_speechHandle : &_sfxHandle, makeVorbisStream(f, size)); + if (f) { + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, makeVorbisStream(f, size)); + return true; + } + return false; } #endif #ifdef USE_FLAC -void FLACSound::sfxPlay(const char *name, bool isSpeech) { +bool FLACSound::sfxPlay(const char *name, Audio::SoundHandle *soundHandle) { uint32 size; Common::File *f = _vm->resource()->giveCompressedSound(name, &size); - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, isSpeech ? &_speechHandle : &_sfxHandle, makeFlacStream(f, size)); + if (f) { + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, makeFlacStream(f, size)); + return true; + } + return false; } #endif diff --git a/queen/sound.h b/queen/sound.h index 8a70a17717..446b135fda 100644 --- a/queen/sound.h +++ b/queen/sound.h @@ -53,7 +53,7 @@ class Sound { public: Sound(Audio::Mixer *mixer, QueenEngine *vm); virtual ~Sound(); - virtual void sfxPlay(const char *name, bool isSpeech) = 0; + virtual bool sfxPlay(const char *name, Audio::SoundHandle *soundHandle) = 0; static Sound *giveSound(Audio::Mixer *mixer, QueenEngine *vm, uint8 compression); void playSfx(uint16 sfx, bool isSpeech); void playSfx(const char *base, bool isSpeech); @@ -119,22 +119,20 @@ protected: class SilentSound : public Sound { public: SilentSound(Audio::Mixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {}; - void sfxPlay(const char *name, bool isSpeech) { } + bool sfxPlay(const char *name, Audio::SoundHandle *soundHandle); }; class SBSound : public Sound { public: SBSound(Audio::Mixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {}; - void sfxPlay(const char *name, bool isSpeech); -protected: - void playSound(byte *sound, uint32 size, bool isSpeech); + bool sfxPlay(const char *name, Audio::SoundHandle *soundHandle); }; #ifdef USE_MAD class MP3Sound : public Sound { public: MP3Sound(Audio::Mixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {}; - void sfxPlay(const char *name, bool isSpeech); + bool sfxPlay(const char *name, Audio::SoundHandle *soundHandle); }; #endif @@ -142,7 +140,7 @@ public: class OGGSound : public Sound { public: OGGSound(Audio::Mixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {}; - void sfxPlay(const char *name, bool isSpeech); + bool sfxPlay(const char *name, Audio::SoundHandle *soundHandle); }; #endif @@ -150,7 +148,7 @@ public: class FLACSound : public Sound { public: FLACSound(Audio::Mixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {}; - void sfxPlay(const char *name, bool isSpeech); + bool sfxPlay(const char *name, Audio::SoundHandle *soundHandle); }; #endif // #ifdef USE_FLAC |