aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorJohannes Schickel2010-01-08 22:14:55 +0000
committerJohannes Schickel2010-01-08 22:14:55 +0000
commitb8727aefcc6b73dba5338872ce6bc35b856e84f7 (patch)
tree3a3f3580415a044f71a909cfb4aefe80f228ebf5 /sound
parentc4892593538887d36858cbba609dbe34a4b60792 (diff)
downloadscummvm-rg350-b8727aefcc6b73dba5338872ce6bc35b856e84f7.tar.gz
scummvm-rg350-b8727aefcc6b73dba5338872ce6bc35b856e84f7.tar.bz2
scummvm-rg350-b8727aefcc6b73dba5338872ce6bc35b856e84f7.zip
Fix LinearMemoryStream::seek, when the stream was created without request to dispose the memory itself.
svn-id: r47184
Diffstat (limited to 'sound')
-rw-r--r--sound/audiostream.cpp9
1 files 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<byte *>(_origPtr));
+ if (_disposeAfterUse)
+ free(const_cast<byte *>(_origPtr));
}
int readBuffer(int16 *buffer, const int numSamples);