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

Hkz at users.sourceforge.net Hkz at users.sourceforge.net
Mon Mar 30 15:42:28 CEST 2009


Revision: 39764
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39764&view=rev
Author:   Hkz
Date:     2009-03-30 13:42:28 +0000 (Mon, 30 Mar 2009)

Log Message:
-----------
Rate selection is now possible for VAG audio decoder, also decoder doesn't die with incomplete/corrupted files

Modified Paths:
--------------
    scummvm/trunk/sound/vag.cpp
    scummvm/trunk/sound/vag.h

Modified: scummvm/trunk/sound/vag.cpp
===================================================================
--- scummvm/trunk/sound/vag.cpp	2009-03-30 12:12:20 UTC (rev 39763)
+++ scummvm/trunk/sound/vag.cpp	2009-03-30 13:42:28 UTC (rev 39764)
@@ -27,11 +27,12 @@
 
 namespace Audio {
 
-VagStream::VagStream(Common::SeekableReadStream *stream, bool loop) : _stream(stream) {
+VagStream::VagStream(Common::SeekableReadStream *stream, bool loop, int rate) : _stream(stream) {
 	_samplesRemaining = 0;
 	_predictor = 0;
 	_s1 = _s2 = 0.0;
 	_loop = loop;
+	_rate = rate;
 }
 
 
@@ -58,8 +59,14 @@
 			buffer[samplesDecoded] = d;
 			samplesDecoded++;
 		}
-		
+
+#if 0
 		assert(i == 28); // We're screwed if this fails :P
+#endif
+		// This might mean the file is corrupted, or that the stream has
+		// been closed.
+		if (i != 28) return 0;
+
 		_samplesRemaining = 0;
 	}
 	

Modified: scummvm/trunk/sound/vag.h
===================================================================
--- scummvm/trunk/sound/vag.h	2009-03-30 12:12:20 UTC (rev 39763)
+++ scummvm/trunk/sound/vag.h	2009-03-30 13:42:28 UTC (rev 39764)
@@ -38,12 +38,12 @@
 
 class VagStream : public Audio::AudioStream {
 public:
-	VagStream(Common::SeekableReadStream *stream, bool loop = false);
+	VagStream(Common::SeekableReadStream *stream, bool loop = false, int rate = 11025);
 	~VagStream();
 	
 	bool isStereo() const { return false; }
 	bool endOfData() const { return _stream->pos() == _stream->size(); }
-	int getRate() const { return 11025; }
+	int getRate() const { return _rate; }
 	int readBuffer(int16 *buffer, const int numSamples);
 	void rewind();	
 
@@ -54,6 +54,7 @@
 	byte _predictor;
 	double _samples[28];
 	byte _samplesRemaining;
+	int _rate;
 	double _s1, _s2;
 };
 


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