[Scummvm-cvs-logs] SF.net SVN: scummvm:[40841] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun May 24 01:58:40 CEST 2009


Revision: 40841
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40841&view=rev
Author:   lordhoto
Date:     2009-05-23 23:58:40 +0000 (Sat, 23 May 2009)

Log Message:
-----------
Cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/sound.cpp
    scummvm/trunk/engines/kyra/sound.h
    scummvm/trunk/engines/kyra/sound_lol.cpp
    scummvm/trunk/engines/kyra/sound_towns.cpp

Modified: scummvm/trunk/engines/kyra/sound.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound.cpp	2009-05-23 23:49:47 UTC (rev 40840)
+++ scummvm/trunk/engines/kyra/sound.cpp	2009-05-23 23:58:40 UTC (rev 40841)
@@ -66,21 +66,20 @@
 	return false;
 }
 
-int32 Sound::voicePlay(const char *file, uint8 volume, bool isSfx, bool appendSuffix) {
-	int32 ptime = 0;
-	Audio::AudioStream *audioStream = getVoiceStream(file, &ptime, appendSuffix);
+int32 Sound::voicePlay(const char *file, uint8 volume, bool isSfx) {
+	Audio::AudioStream *audioStream = getVoiceStream(file);
 
 	if (!audioStream) {
 		warning("Couldn't load sound file '%s'", file);
 		return 0;
 	}
 
-	playVoiceStream(audioStream, file, volume, isSfx) ;
-
-	return ptime;
+	int playTime = audioStream->getTotalPlayTime();
+	playVoiceStream(audioStream, file, volume, isSfx);
+	return playTime;
 }
 
-Audio::AudioStream *Sound::getVoiceStream(const char *file, int32 *totalPlayingTime, bool appendSuffix) {
+Audio::AudioStream *Sound::getVoiceStream(const char *file) {
 	char filenamebuffer[25];
 
 	Audio::AudioStream *audioStream = 0;
@@ -95,28 +94,6 @@
 		break;
 	}
 
-	int32 vocStreamPlayTime = 0;
-
-	if (!audioStream) {
-		strcpy(filenamebuffer, file);
-		if (appendSuffix)
-			strcat(filenamebuffer, ".VOC");
-
-		uint32 fileSize = 0;
-		byte *fileData = _vm->resource()->fileData(filenamebuffer, &fileSize);
-		if (!fileData)
-			return 0;
-
-		Common::MemoryReadStream vocStream(fileData, fileSize);
-		audioStream = Audio::makeVOCStream(vocStream, Audio::Mixer::FLAG_UNSIGNED);
-
-		if (audioStream)
-			vocStreamPlayTime = vocStream.size() * 1000 / audioStream->getRate();
-	} else {
-		vocStreamPlayTime = audioStream->getTotalPlayTime();
-	}
- 
-	*totalPlayingTime = vocStreamPlayTime;
 	return audioStream;
 }
 
@@ -259,6 +236,21 @@
 
 // static res
 
+namespace {
+
+// A simple wrapper to create VOC streams the way like creating MP3, OGG/Vorbis and FLAC streams.
+// Possible TODO: Think of making this complete and moving it to sound/voc.cpp ?
+Audio::AudioStream *makeVOCStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 startTime, uint32 duration, uint numLoops) {
+	Audio::AudioStream *as = Audio::makeVOCStream(*stream, Audio::Mixer::FLAG_UNSIGNED);
+
+	if (disposeAfterUse)
+		delete stream;
+
+	return as;
+}
+
+} // end of anonymous namespace
+
 const Sound::SpeechCodecs Sound::_supportedCodecs[] = {
 #ifdef USE_FLAC
 	{ ".VOF", Audio::makeFlacStream },
@@ -269,6 +261,10 @@
 #ifdef USE_MAD
 	{ ".VO3", Audio::makeMP3Stream },
 #endif // USE_MAD
+
+	{ ".VOC", makeVOCStream },
+	{ "", makeVOCStream },
+
 	{ 0, 0 }
 };
 

Modified: scummvm/trunk/engines/kyra/sound.h
===================================================================
--- scummvm/trunk/engines/kyra/sound.h	2009-05-23 23:49:47 UTC (rev 40840)
+++ scummvm/trunk/engines/kyra/sound.h	2009-05-23 23:58:40 UTC (rev 40841)
@@ -187,17 +187,14 @@
 	 * specified voice file, it stops the
 	 * current voice.
 	 *
-	 * TODO: add support for queueing voice
-	 * files
-	 *
 	 * @param file		file to be played
 	 * @param volume	volume of the voice file
 	 * @param isSfx		marks file as sfx instead of voice
 	 * @return playtime of the voice file (-1 marks unknown playtime)
 	 */
-	virtual int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false, bool appendSuffix = true);
+	virtual int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false);
 	
-	Audio::AudioStream *getVoiceStream(const char *file, int32 *totalPlayingTime, bool appendSuffix = true);
+	Audio::AudioStream *getVoiceStream(const char *file);
 
 	void playVoiceStream(Audio::AudioStream * stream, const char *handleName, uint8 volume = 255, bool isSfx = false);
 
@@ -461,7 +458,7 @@
 	void haltTrack();
 	void beginFadeOut();
 
-	int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false, bool appendSuffix = true) { return -1; }
+	int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false) { return -1; }
 	void playSoundEffect(uint8);
 
 protected:
@@ -488,7 +485,7 @@
 	void haltTrack();
 	void beginFadeOut();
 
-	int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false, bool appendSuffix = true);
+	int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false);
 	void playSoundEffect(uint8 track);
 
 protected:

Modified: scummvm/trunk/engines/kyra/sound_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_lol.cpp	2009-05-23 23:49:47 UTC (rev 40840)
+++ scummvm/trunk/engines/kyra/sound_lol.cpp	2009-05-23 23:58:40 UTC (rev 40841)
@@ -106,11 +106,12 @@
 		delete *i;
 	_speechList.clear();
 
-	int32 pt = 0;
 	for (Common::List<const char*>::iterator i = playList.begin(); i != playList.end(); ++i) {
-		Audio::AudioStream *a = _sound->getVoiceStream(*i, &pt, false);
-		_speechList.push_back(a);
-		_activeVoiceFileTotalTime += pt;
+		Audio::AudioStream *a = _sound->getVoiceStream(*i);
+		if (a) {
+			_activeVoiceFileTotalTime += a->getTotalPlayTime();
+			_speechList.push_back(a);
+		}
 	}
 
 	//_activeVoiceFileTotalTime = _sound->voicePlay(_activeVoiceFile, 255, false, false);

Modified: scummvm/trunk/engines/kyra/sound_towns.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_towns.cpp	2009-05-23 23:49:47 UTC (rev 40840)
+++ scummvm/trunk/engines/kyra/sound_towns.cpp	2009-05-23 23:58:40 UTC (rev 40841)
@@ -4231,7 +4231,7 @@
 	haltTrack();
 }
 
-int32 SoundTownsPC98_v2::voicePlay(const char *file, uint8, bool, bool) {
+int32 SoundTownsPC98_v2::voicePlay(const char *file, uint8, bool) {
 	static const uint16 rates[] =	{ 0x10E1, 0x0CA9, 0x0870, 0x0654, 0x0438, 0x032A, 0x021C, 0x0194 };
 	static const char patternHOF[] = "%s.PCM";
 	static const char patternLOL[] = "%s.VOC";


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list