[Scummvm-cvs-logs] SF.net SVN: scummvm:[47715] scummvm/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Jan 30 16:19:16 CET 2010


Revision: 47715
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47715&view=rev
Author:   lordhoto
Date:     2010-01-30 15:19:15 +0000 (Sat, 30 Jan 2010)

Log Message:
-----------
Get rid of Audio::makeRawMemoryStream_OLD.

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/player_mod.cpp
    scummvm/trunk/engines/scumm/sound.cpp
    scummvm/trunk/sound/decoders/raw.cpp
    scummvm/trunk/sound/decoders/raw.h
    scummvm/trunk/sound/decoders/voc.cpp

Modified: scummvm/trunk/engines/scumm/player_mod.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_mod.cpp	2010-01-30 15:18:25 UTC (rev 47714)
+++ scummvm/trunk/engines/scumm/player_mod.cpp	2010-01-30 15:19:15 UTC (rev 47715)
@@ -95,7 +95,10 @@
 	_channels[i].pan = pan;
 	_channels[i].freq = rate;
 	_channels[i].ctr = 0;
-	_channels[i].input = Audio::makeRawMemoryStream_OLD((const byte*)data, size, rate, 0, loopStart, loopEnd);
+
+	Audio::SeekableAudioStream *stream = Audio::makeRawStream((const byte *)data, size, rate, 0);
+	_channels[i].input = Audio::makeLoopingAudioStream(stream, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate), loopStart == loopEnd ? 1 : 0);
+
 	// read the first sample
 	_channels[i].input->readBuffer(&_channels[i].pos, 1);
 }

Modified: scummvm/trunk/engines/scumm/sound.cpp
===================================================================
--- scummvm/trunk/engines/scumm/sound.cpp	2010-01-30 15:18:25 UTC (rev 47714)
+++ scummvm/trunk/engines/scumm/sound.cpp	2010-01-30 15:19:15 UTC (rev 47715)
@@ -349,7 +349,8 @@
 				}
 				size -= waveSize;
 
-				stream = Audio::makeRawMemoryStream_OLD(sound, waveSize, rate, Audio::FLAG_UNSIGNED, loopStart, loopEnd);
+				Audio::SeekableAudioStream *s = Audio::makeRawStream(sound, waveSize, rate, Audio::FLAG_UNSIGNED);
+				stream = Audio::makeLoopingAudioStream(s, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate), 0);
 				_mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, 255, 0);
 			}
 			break;
@@ -430,17 +431,21 @@
 		int vol = ptr[24] * 4;
 		int loopStart = 0, loopEnd = 0;
 		int loopcount = ptr[27];
+
+		memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
+		Audio::SeekableAudioStream *plainStream = Audio::makeRawStream(sound, size, rate, 0);
+
 		if (loopcount > 1) {
-			// TODO: We can only loop once, or infinitely many times, but
-			// have no support for a finite number of repetitions.
-			// So far, I have seen only 1 and 255 (for infinite repetitions),
-			// so maybe this is not really a problem.
 			loopStart = READ_BE_UINT16(ptr + 10) - READ_BE_UINT16(ptr + 8);
 			loopEnd = READ_BE_UINT16(ptr + 14);
+
+			// TODO: Currently we will only ever play till "loopEnd", even when we only have
+			// a finite repition count.
+			stream = Audio::makeLoopingAudioStream(plainStream, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate), loopcount == 255 ? 0 : loopcount);
+		} else {
+			stream = plainStream;
 		}
 
-		memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
-		stream = Audio::makeRawMemoryStream_OLD(sound, size, rate, 0, loopStart, loopEnd);
 		_mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, vol, 0);
 	}
 	else {

Modified: scummvm/trunk/sound/decoders/raw.cpp
===================================================================
--- scummvm/trunk/sound/decoders/raw.cpp	2010-01-30 15:18:25 UTC (rev 47714)
+++ scummvm/trunk/sound/decoders/raw.cpp	2010-01-30 15:19:15 UTC (rev 47715)
@@ -339,37 +339,6 @@
 	}
 }
 
-
-AudioStream *makeRawMemoryStream_OLD(const byte *ptr, uint32 len,
-		int rate, byte flags,
-		uint loopStart, uint loopEnd,
-		DisposeAfterUse::Flag autoFree
-	) {
-	SeekableAudioStream *s = makeRawMemoryStream(ptr, len, rate, flags, autoFree);
-
-	if (loopStart != loopEnd) {
-		const bool isStereo   = (flags & Audio::FLAG_STEREO) != 0;
-		const bool is16Bit    = (flags & Audio::FLAG_16BITS) != 0;
-
-		if (loopEnd == 0)
-			loopEnd = len;
-		assert(loopStart <= loopEnd);
-		assert(loopEnd <= len);
-
-		// Verify the buffer sizes are sane
-		if (is16Bit && isStereo)
-			assert((loopStart & 3) == 0 && (loopEnd & 3) == 0);
-		else if (is16Bit || isStereo)
-			assert((loopStart & 1) == 0 && (loopEnd & 1) == 0);
-
-		const uint32 extRate = s->getRate() * (is16Bit ? 2 : 1) * (isStereo ? 2 : 1);
-
-		return new SubLoopingAudioStream(s, 0, Timestamp(0, loopStart, extRate), Timestamp(0, loopEnd, extRate));
-	} else {
-		return s;
-	}
-}
-
 #define MAKE_LINEAR_DISK(STEREO, UNSIGNED) \
 		if (is16Bit) { \
 			if (isLE) \

Modified: scummvm/trunk/sound/decoders/raw.h
===================================================================
--- scummvm/trunk/sound/decoders/raw.h	2010-01-30 15:18:25 UTC (rev 47714)
+++ scummvm/trunk/sound/decoders/raw.h	2010-01-30 15:19:15 UTC (rev 47715)
@@ -86,24 +86,6 @@
 		);
 
 /**
- * NOTE:
- * This API is considered deprecated.
- *
- * Factory function for a raw PCM AudioStream, which will simply treat all
- * data in the buffer described by ptr and len as raw sample data in the
- * specified format. It will then simply pass this data directly to the mixer,
- * after converting it to the sample format used by the mixer (i.e. 16 bit
- * signed native endian). Optionally supports (infinite) looping of a portion
- * of the data.
- */
-AudioStream *makeRawMemoryStream_OLD(const byte *ptr, uint32 len,
-		int rate, byte flags,
-		uint loopStart, uint loopEnd,
-		DisposeAfterUse::Flag autofreeBuffer = DisposeAfterUse::YES
-		);
-
-
-/**
  * Struct used to define the audio data to be played by a RawDiskStream.
  */
 struct RawDiskStreamAudioBlock {

Modified: scummvm/trunk/sound/decoders/voc.cpp
===================================================================
--- scummvm/trunk/sound/decoders/voc.cpp	2010-01-30 15:18:25 UTC (rev 47714)
+++ scummvm/trunk/sound/decoders/voc.cpp	2010-01-30 15:19:15 UTC (rev 47715)
@@ -353,7 +353,29 @@
 	if (!data)
 		return 0;
 
-	return makeRawMemoryStream_OLD(data, size, rate, flags, loopStart, loopEnd);
+	SeekableAudioStream *s = Audio::makeRawStream(data, size, rate, flags);
+
+	if (loopStart != loopEnd) {
+		const bool isStereo   = (flags & Audio::FLAG_STEREO) != 0;
+		const bool is16Bit    = (flags & Audio::FLAG_16BITS) != 0;
+
+		if (loopEnd == 0)
+			loopEnd = size;
+		assert(loopStart <= loopEnd);
+		assert(loopEnd <= (uint)size);
+
+		// Verify the buffer sizes are sane
+		if (is16Bit && isStereo)
+			assert((loopStart & 3) == 0 && (loopEnd & 3) == 0);
+		else if (is16Bit || isStereo)
+			assert((loopStart & 1) == 0 && (loopEnd & 1) == 0);
+
+		const uint32 extRate = s->getRate() * (is16Bit ? 2 : 1) * (isStereo ? 2 : 1);
+
+		return new SubLoopingAudioStream(s, 0, Timestamp(0, loopStart, extRate), Timestamp(0, loopEnd, extRate));
+	} else {
+		return s;
+	}
 #endif
 }
 


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