Fix LinearMemoryStream::seek, when the stream was created without request to dispose the memory itself.
svn-id: r47184
This commit is contained in:
parent
c489259353
commit
b8727aefcc
1 changed files with 6 additions and 3 deletions
|
@ -231,6 +231,7 @@ protected:
|
||||||
const byte *_loopEnd;
|
const byte *_loopEnd;
|
||||||
const int _rate;
|
const int _rate;
|
||||||
const byte *_origPtr;
|
const byte *_origPtr;
|
||||||
|
const bool _disposeAfterUse;
|
||||||
const Timestamp _playtime;
|
const Timestamp _playtime;
|
||||||
|
|
||||||
uint _numLoops; ///< Number of loops to play
|
uint _numLoops; ///< Number of loops to play
|
||||||
|
@ -238,7 +239,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LinearMemoryStream(int rate, const byte *ptr, uint len, uint loopOffset, uint loopLen, bool autoFreeMemory)
|
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) {
|
if (loopLen) {
|
||||||
_numLoops = 0;
|
_numLoops = 0;
|
||||||
|
@ -249,9 +251,10 @@ public:
|
||||||
}
|
}
|
||||||
_numPlayedLoops = 0;
|
_numPlayedLoops = 0;
|
||||||
|
|
||||||
_origPtr = autoFreeMemory ? ptr : 0;
|
_origPtr = ptr;
|
||||||
}
|
}
|
||||||
virtual ~LinearMemoryStream() {
|
virtual ~LinearMemoryStream() {
|
||||||
|
if (_disposeAfterUse)
|
||||||
free(const_cast<byte *>(_origPtr));
|
free(const_cast<byte *>(_origPtr));
|
||||||
}
|
}
|
||||||
int readBuffer(int16 *buffer, const int numSamples);
|
int readBuffer(int16 *buffer, const int numSamples);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue