From b8727aefcc6b73dba5338872ce6bc35b856e84f7 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 8 Jan 2010 22:14:55 +0000 Subject: Fix LinearMemoryStream::seek, when the stream was created without request to dispose the memory itself. svn-id: r47184 --- sound/audiostream.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 6928638c35..6d7ee24738 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -231,6 +231,7 @@ protected: 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 @@ protected: 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 @@ public: } _numPlayedLoops = 0; - _origPtr = autoFreeMemory ? ptr : 0; + _origPtr = ptr; } virtual ~LinearMemoryStream() { - free(const_cast(_origPtr)); + if (_disposeAfterUse) + free(const_cast(_origPtr)); } int readBuffer(int16 *buffer, const int numSamples); -- cgit v1.2.3