Don't synchronize subtitle with speech sfx if MP3/OGG/Flac support isn't compiled it. This should fix bug #1350045.

svn-id: r19495
This commit is contained in:
Gregory Montoir 2005-11-07 18:34:55 +00:00
parent 7d23fafc25
commit 99c5448698
3 changed files with 45 additions and 30 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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