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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Jan 28 10:38:21 CET 2010


Revision: 47634
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47634&view=rev
Author:   fingolfin
Date:     2010-01-28 09:38:21 +0000 (Thu, 28 Jan 2010)

Log Message:
-----------
Hide VagStream implementation, only expose it via a factory method

Modified Paths:
--------------
    scummvm/trunk/engines/sword1/music.cpp
    scummvm/trunk/engines/sword1/sound.cpp
    scummvm/trunk/engines/sword2/music.cpp
    scummvm/trunk/engines/sword2/sound.cpp
    scummvm/trunk/engines/tinsel/sound.cpp
    scummvm/trunk/sound/decoders/vag.cpp
    scummvm/trunk/sound/decoders/vag.h

Modified: scummvm/trunk/engines/sword1/music.cpp
===================================================================
--- scummvm/trunk/engines/sword1/music.cpp	2010-01-28 09:37:50 UTC (rev 47633)
+++ scummvm/trunk/engines/sword1/music.cpp	2010-01-28 09:38:21 UTC (rev 47634)
@@ -33,6 +33,7 @@
 #include "sword1/music.h"
 
 #include "sound/mixer.h"
+#include "sound/audiostream.h"
 #include "sound/decoders/aiff.h"
 #include "sound/decoders/flac.h"
 #include "sound/decoders/mp3.h"
@@ -137,7 +138,7 @@
 	// not over file size
 	if ((size != 0) && (size != 0xffffffff) && ((int32)(offset + size) <= _file.size())) {
 		_file.seek(offset, SEEK_SET);
-		_audioSource = Audio::makeLoopingAudioStream(new Audio::VagStream(_file.readStream(size)), loop ? 0 : 1);
+		_audioSource = Audio::makeLoopingAudioStream(Audio::makeVagStream(_file.readStream(size)), loop ? 0 : 1);
 		fadeUp();
 	} else {
 		_audioSource = NULL;

Modified: scummvm/trunk/engines/sword1/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sound.cpp	2010-01-28 09:37:50 UTC (rev 47633)
+++ scummvm/trunk/engines/sword1/sound.cpp	2010-01-28 09:38:21 UTC (rev 47634)
@@ -36,6 +36,7 @@
 #include "sword1/logic.h"
 #include "sword1/sword1.h"
 
+#include "sound/audiostream.h"
 #include "sound/decoders/flac.h"
 #include "sound/decoders/mp3.h"
 #include "sound/decoders/raw.h"
@@ -259,7 +260,7 @@
 
 					if (SwordEngine::isPsx()) {
 						uint32 size = READ_LE_UINT32(sampleData);
-						Audio::AudioStream *audStream = Audio::makeLoopingAudioStream(new Audio::VagStream(new Common::MemoryReadStream(sampleData + 4, size-4)), (_fxList[elem->id].type == FX_LOOP) ? 0 : 1);
+						Audio::AudioStream *audStream = Audio::makeLoopingAudioStream(Audio::makeVagStream(new Common::MemoryReadStream(sampleData + 4, size-4)), (_fxList[elem->id].type == FX_LOOP) ? 0 : 1);
 						_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &elem->handle, audStream, elem->id, volume, pan);
 					} else {
 						uint32 size = READ_LE_UINT32(sampleData + 0x28);
@@ -367,7 +368,7 @@
 			_cowFile.seek(index * 2048);
 			Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize);
 			assert(tmp);
-			stream = new Audio::VagStream(tmp);
+			stream = Audio::makeVagStream(tmp);
 			_mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, stream, SOUND_SPEECH_ID, speechVol, speechPan);
 			// with compressed audio, we can't calculate the wave volume.
 			// so default to talking.

Modified: scummvm/trunk/engines/sword2/music.cpp
===================================================================
--- scummvm/trunk/engines/sword2/music.cpp	2010-01-28 09:37:50 UTC (rev 47633)
+++ scummvm/trunk/engines/sword2/music.cpp	2010-01-28 09:38:21 UTC (rev 47634)
@@ -302,7 +302,7 @@
 
 	byte *buffer = (byte *)malloc(size);
 	file->read(buffer, size);
-	return new Audio::VagStream(new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES));
+	return Audio::makeVagStream(new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES));
 }
 
 // ----------------------------------------------------------------------------

Modified: scummvm/trunk/engines/sword2/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sound.cpp	2010-01-28 09:37:50 UTC (rev 47633)
+++ scummvm/trunk/engines/sword2/sound.cpp	2010-01-28 09:38:21 UTC (rev 47634)
@@ -334,7 +334,7 @@
 	Audio::RewindableAudioStream *input = 0;
 
 	if (Sword2Engine::isPsx())
-		input = new Audio::VagStream(stream);
+		input = Audio::makeVagStream(stream);
 	else
 		input = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
 

Modified: scummvm/trunk/engines/tinsel/sound.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/sound.cpp	2010-01-28 09:37:50 UTC (rev 47633)
+++ scummvm/trunk/engines/tinsel/sound.cpp	2010-01-28 09:38:21 UTC (rev 47634)
@@ -109,7 +109,7 @@
 
 	if (TinselV1PSX) {
 		// Read the stream and create a VAG Audio stream
-		Audio::AudioStream *vagStream = new Audio::VagStream(_sampleStream.readStream(sampleLen), 44100);
+		Audio::AudioStream *vagStream = Audio::makeVagStream(_sampleStream.readStream(sampleLen), 44100);
 
 		// FIXME: Should set this in a different place ;)
 		_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_config->_soundVolume);

Modified: scummvm/trunk/sound/decoders/vag.cpp
===================================================================
--- scummvm/trunk/sound/decoders/vag.cpp	2010-01-28 09:37:50 UTC (rev 47633)
+++ scummvm/trunk/sound/decoders/vag.cpp	2010-01-28 09:38:21 UTC (rev 47634)
@@ -24,9 +24,32 @@
  */
 
 #include "sound/decoders/vag.h"
+#include "sound/audiostream.h"
+#include "common/stream.h"
 
 namespace Audio {
 
+class VagStream : public Audio::RewindableAudioStream {
+public:
+	VagStream(Common::SeekableReadStream *stream, int rate);
+	~VagStream();
+
+	bool isStereo() const { return false; }
+	bool endOfData() const { return _stream->pos() == _stream->size(); }
+	int getRate() const { return _rate; }
+	int readBuffer(int16 *buffer, const int numSamples);
+
+	bool rewind();
+private:
+	Common::SeekableReadStream *_stream;
+
+	byte _predictor;
+	double _samples[28];
+	byte _samplesRemaining;
+	int _rate;
+	double _s1, _s2;
+};
+
 VagStream::VagStream(Common::SeekableReadStream *stream, int rate) : _stream(stream) {
 	_samplesRemaining = 0;
 	_predictor = 0;
@@ -120,4 +143,8 @@
 	return true;
 }
 
+RewindableAudioStream *makeVagStream(Common::SeekableReadStream *stream, int rate) {
+	return new VagStream(stream, rate);
 }
+
+}

Modified: scummvm/trunk/sound/decoders/vag.h
===================================================================
--- scummvm/trunk/sound/decoders/vag.h	2010-01-28 09:37:50 UTC (rev 47633)
+++ scummvm/trunk/sound/decoders/vag.h	2010-01-28 09:38:21 UTC (rev 47634)
@@ -34,32 +34,27 @@
 #ifndef SOUND_VAG_H
 #define SOUND_VAG_H
 
-#include "sound/audiostream.h"
-#include "common/stream.h"
+namespace Common {
+	class SeekableReadStream;
+}
 
 namespace Audio {
 
-class VagStream : public Audio::RewindableAudioStream {
-public:
-	VagStream(Common::SeekableReadStream *stream, int rate = 11025);
-	~VagStream();
+class AudioStream;
+class RewindableAudioStream;
 
-	bool isStereo() const { return false; }
-	bool endOfData() const { return _stream->pos() == _stream->size(); }
-	int getRate() const { return _rate; }
-	int readBuffer(int16 *buffer, const int numSamples);
+/**
+ * Takes an input stream containing Vag sound data and creates
+ * an RewindableAudioStream from that.
+ *
+ * @param stream            the SeekableReadStream from which to read the ADPCM data
+ * @param rate              the sampling rate
+ * @return   a new RewindableAudioStream, or NULL, if an error occured
+ */
+RewindableAudioStream *makeVagStream(
+	Common::SeekableReadStream *stream,
+	int rate = 11025);
 
-	bool rewind();
-private:
-	Common::SeekableReadStream *_stream;
-
-	byte _predictor;
-	double _samples[28];
-	byte _samplesRemaining;
-	int _rate;
-	double _s1, _s2;
-};
-
 } // End of namespace Sword1
 
 #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