[Scummvm-cvs-logs] SF.net SVN: scummvm:[47184] scummvm/trunk/sound/audiostream.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Jan 8 23:14:55 CET 2010


Revision: 47184
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47184&view=rev
Author:   lordhoto
Date:     2010-01-08 22:14:55 +0000 (Fri, 08 Jan 2010)

Log Message:
-----------
Fix LinearMemoryStream::seek, when the stream was created without request to dispose the memory itself.

Modified Paths:
--------------
    scummvm/trunk/sound/audiostream.cpp

Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp	2010-01-08 22:10:19 UTC (rev 47183)
+++ scummvm/trunk/sound/audiostream.cpp	2010-01-08 22:14:55 UTC (rev 47184)
@@ -231,6 +231,7 @@
 	const byte *_loopEnd;
 	const int _rate;
 	const byte *_origPtr;
+	const bool _disposeAfterUse;
 	const Timestamp _playtime;
 
 	uint _numLoops;			///< Number of loops to play
@@ -238,7 +239,8 @@
 
 public:
 	LinearMemoryStream(int rate, const byte *ptr, uint len, uint loopOffset, uint loopLen, bool autoFreeMemory)
-		: _ptr(ptr), _end(ptr+len), _loopPtr(0), _loopEnd(0), _rate(rate), _playtime(0, len / (is16Bit ? 2 : 1) / (stereo ? 2 : 1), rate) {
+	    : _ptr(ptr), _end(ptr+len), _loopPtr(0), _loopEnd(0), _rate(rate), _disposeAfterUse(autoFreeMemory),
+	      _playtime(0, len / (is16Bit ? 2 : 1) / (stereo ? 2 : 1), rate) {
 
 		if (loopLen) {
 			_numLoops = 0;
@@ -249,10 +251,11 @@
 		}
 		_numPlayedLoops = 0;
 
-		_origPtr = autoFreeMemory ? ptr : 0;
+		_origPtr = ptr;
 	}
 	virtual ~LinearMemoryStream() {
-		free(const_cast<byte *>(_origPtr));
+		if (_disposeAfterUse)
+			free(const_cast<byte *>(_origPtr));
 	}
 	int readBuffer(int16 *buffer, const int numSamples);
 


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