[Scummvm-cvs-logs] CVS: scummvm/queen resource.cpp,1.62,1.63 sound.cpp,1.61,1.62 sound.h,1.34,1.35

Gregory Montoir cyx at users.sourceforge.net
Mon Nov 7 10:36:35 CET 2005


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2601/queen

Modified Files:
	resource.cpp sound.cpp sound.h 
Log Message:
Don't synchronize subtitle with speech sfx if MP3/OGG/Flac support isn't compiled it. This should fix bug #1350045.

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/resource.cpp,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- resource.cpp	5 Nov 2005 18:12:41 -0000	1.62
+++ resource.cpp	7 Nov 2005 18:34:54 -0000	1.63
@@ -239,13 +239,16 @@
 
 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) {

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/sound.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- sound.cpp	5 Nov 2005 18:12:41 -0000	1.61
+++ sound.cpp	7 Nov 2005 18:34:54 -0000	1.62
@@ -103,8 +103,7 @@
 #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 @@
 	}
 	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 @@
 	_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
 

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/sound.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- sound.h	5 Nov 2005 18:12:41 -0000	1.34
+++ sound.h	7 Nov 2005 18:34:55 -0000	1.35
@@ -53,7 +53,7 @@
 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 @@
 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 @@
 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 @@
 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
 





More information about the Scummvm-git-logs mailing list