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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Mar 3 07:52:04 CET 2006


Revision: 21043
Author:   fingolfin
Date:     2006-03-03 07:51:33 -0800 (Fri, 03 Mar 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm?rev=21043&view=rev

Log Message:
-----------
Hiding the implementation of ADPCMInputStream from the public, in favor of a factory function (just like with the other AudioStream subclasses)

Modified Paths:
--------------
    scummvm/trunk/engines/saga/sndres.cpp
    scummvm/trunk/engines/scumm/he/sound_he.cpp
    scummvm/trunk/sound/adpcm.cpp
    scummvm/trunk/sound/adpcm.h
    scummvm/trunk/sound/wave.cpp
Modified: scummvm/trunk/engines/saga/sndres.cpp
===================================================================
--- scummvm/trunk/engines/saga/sndres.cpp	2006-03-03 15:46:39 UTC (rev 21042)
+++ scummvm/trunk/engines/saga/sndres.cpp	2006-03-03 15:51:33 UTC (rev 21043)
@@ -217,7 +217,7 @@
 			buffer.buffer = NULL;
 			free(soundResource);
 		} else {
-			voxStream = new ADPCMInputStream(&readS, soundResourceLength, kADPCMOki);
+			voxStream = makeADPCMStream(&readS, soundResourceLength, kADPCMOki);
 			buffer.buffer = (byte *)malloc(buffer.size);
 			voxSize = voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2);
 			if (voxSize != soundResourceLength * 2) {

Modified: scummvm/trunk/engines/scumm/he/sound_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/sound_he.cpp	2006-03-03 15:46:39 UTC (rev 21042)
+++ scummvm/trunk/engines/scumm/he/sound_he.cpp	2006-03-03 15:51:33 UTC (rev 21043)
@@ -419,7 +419,7 @@
 		}
 
 		if (compType == 17) {
-			AudioStream *voxStream = new ADPCMInputStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
+			AudioStream *voxStream = makeADPCMStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
 
 			sound = (char *)malloc(size * 4);
 			size = voxStream->readBuffer((int16*)sound, size * 2);

Modified: scummvm/trunk/sound/adpcm.cpp
===================================================================
--- scummvm/trunk/sound/adpcm.cpp	2006-03-03 15:46:39 UTC (rev 21042)
+++ scummvm/trunk/sound/adpcm.cpp	2006-03-03 15:51:33 UTC (rev 21043)
@@ -23,8 +23,43 @@
 #include "common/stdafx.h"
 
 #include "sound/adpcm.h"
+#include "sound/audiostream.h"
 
 
+// TODO: Switch from a SeekableReadStream to a plain ReadStream. This requires
+// some internal refactoring but is definitely possible and will increase the
+// flexibility of this code.
+class ADPCMInputStream : public AudioStream {
+private:
+	Common::SeekableReadStream *_stream;
+	uint32 _endpos;
+	int _channels;
+	typesADPCM _type;
+	uint32 _blockAlign;
+
+	struct adpcmStatus {
+		int32 last;
+		int32 stepIndex;
+	} _status;
+
+	int16 stepAdjust(byte);
+	int16 decodeOKI(byte);
+	int16 decodeMSIMA(byte);
+
+public:
+	ADPCMInputStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels = 2, uint32 blockAlign = 0);
+	~ADPCMInputStream() {};
+
+	int readBuffer(int16 *buffer, const int numSamples);
+	int readBufferOKI(int16 *buffer, const int numSamples);
+	int readBufferMSIMA1(int16 *buffer, const int numSamples);
+	int readBufferMSIMA2(int16 *buffer, const int numSamples);
+
+	bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); }
+	bool isStereo() const	{ return false; }
+	int getRate() const	{ return 22050; }
+};
+
 // Routines to convert 12 bit linear samples to the
 // Dialogic or Oki ADPCM coding format aka VOX.
 // See also <http://www.comptek.ru/telephony/tnotes/tt1-13.html>
@@ -205,3 +240,7 @@
 
 	return samp;
 }
+
+AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels, uint32 blockAlign) {
+	return new ADPCMInputStream(stream, size, type, channels, blockAlign);
+}

Modified: scummvm/trunk/sound/adpcm.h
===================================================================
--- scummvm/trunk/sound/adpcm.h	2006-03-03 15:46:39 UTC (rev 21042)
+++ scummvm/trunk/sound/adpcm.h	2006-03-03 15:51:33 UTC (rev 21043)
@@ -26,7 +26,6 @@
 #include "common/stdafx.h"
 #include "common/scummsys.h"
 #include "common/stream.h"
-#include "sound/audiostream.h"
 
 class AudioStream;
 
@@ -35,38 +34,7 @@
 	kADPCMIma
 };
 
-// TODO: Switch from a SeekableReadStream to a plain ReadStream. This requires
-// some internal refactoring but is definitely possible and will increase the
-// flexibility of this code.
-class ADPCMInputStream : public AudioStream {
-private:
-	Common::SeekableReadStream *_stream;
-	uint32 _endpos;
-	int _channels;
-	typesADPCM _type;
-	uint32 _blockAlign;
+AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels = 2, uint32 blockAlign = 0);
 
-	struct adpcmStatus {
-		int32 last;
-		int32 stepIndex;
-	} _status;
 
-	int16 stepAdjust(byte);
-	int16 decodeOKI(byte);
-	int16 decodeMSIMA(byte);
-
-public:
-	ADPCMInputStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels = 2, uint32 blockAlign = 0);
-	~ADPCMInputStream() {};
-
-	int readBuffer(int16 *buffer, const int numSamples);
-	int readBufferOKI(int16 *buffer, const int numSamples);
-	int readBufferMSIMA1(int16 *buffer, const int numSamples);
-	int readBufferMSIMA2(int16 *buffer, const int numSamples);
-
-	bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); }
-	bool isStereo() const	{ return false; }
-	int getRate() const	{ return 22050; }
-};
-
 #endif

Modified: scummvm/trunk/sound/wave.cpp
===================================================================
--- scummvm/trunk/sound/wave.cpp	2006-03-03 15:46:39 UTC (rev 21042)
+++ scummvm/trunk/sound/wave.cpp	2006-03-03 15:51:33 UTC (rev 21043)
@@ -165,7 +165,7 @@
 		return 0;
 
 	if (type == 17) // IMA ADPCM
-		return new ADPCMInputStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1);
+		return makeADPCMStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1);
 
 	byte *data = (byte *)malloc(size);
 	assert(data);







More information about the Scummvm-git-logs mailing list