diff options
author | Max Horn | 2007-11-16 10:05:18 +0000 |
---|---|---|
committer | Max Horn | 2007-11-16 10:05:18 +0000 |
commit | c8ce5b1865c3854eca79843e12493453c7566d0b (patch) | |
tree | 4b2da4ab38219679ab0cddafe68f686b46fd5a67 /sound/adpcm.cpp | |
parent | ca2641b70f96f879352ab49b5d4f90909d4f75de (diff) | |
download | scummvm-rg350-c8ce5b1865c3854eca79843e12493453c7566d0b.tar.gz scummvm-rg350-c8ce5b1865c3854eca79843e12493453c7566d0b.tar.bz2 scummvm-rg350-c8ce5b1865c3854eca79843e12493453c7566d0b.zip |
Changed Audio::makeADPCMStream so that the stream passed to it can automatically be disposed
svn-id: r29517
Diffstat (limited to 'sound/adpcm.cpp')
-rw-r--r-- | sound/adpcm.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sound/adpcm.cpp b/sound/adpcm.cpp index ca1eb79c6f..d1e54de2af 100644 --- a/sound/adpcm.cpp +++ b/sound/adpcm.cpp @@ -37,6 +37,7 @@ namespace Audio { class ADPCMInputStream : public AudioStream { private: Common::SeekableReadStream *_stream; + bool _disposeAfterUse; uint32 _endpos; int _channels; typesADPCM _type; @@ -69,8 +70,8 @@ private: int16 decodeMS(ADPCMChannelStatus *c, byte); public: - ADPCMInputStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int rate, int channels = 2, uint32 blockAlign = 0); - ~ADPCMInputStream() {} + ADPCMInputStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, typesADPCM type, int rate, int channels = 2, uint32 blockAlign = 0); + ~ADPCMInputStream(); int readBuffer(int16 *buffer, const int numSamples); int readBufferOKI(int16 *buffer, const int numSamples); @@ -90,8 +91,8 @@ public: // In addition, also MS IMA ADPCM is supported. See // <http://wiki.multimedia.cx/index.php?title=Microsoft_IMA_ADPCM>. -ADPCMInputStream::ADPCMInputStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign) - : _stream(stream), _channels(channels), _type(type), _blockAlign(blockAlign), _rate(rate) { +ADPCMInputStream::ADPCMInputStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign) + : _stream(stream), _disposeAfterUse(disposeAfterUse), _channels(channels), _type(type), _blockAlign(blockAlign), _rate(rate) { _status.last = 0; _status.stepIndex = 0; @@ -106,6 +107,11 @@ ADPCMInputStream::ADPCMInputStream(Common::SeekableReadStream *stream, uint32 si error("ADPCMInputStream(): blockAlign isn't specifiled for MS ADPCM"); } +ADPCMInputStream::~ADPCMInputStream() { + if (_disposeAfterUse) + delete _stream; +} + int ADPCMInputStream::readBuffer(int16 *buffer, const int numSamples) { switch (_type) { case kADPCMOki: @@ -355,8 +361,8 @@ int16 ADPCMInputStream::decodeMSIMA(byte code) { return samp; } -AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign) { - return new ADPCMInputStream(stream, size, type, rate, channels, blockAlign); +AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 size, typesADPCM type, int rate, int channels, uint32 blockAlign) { + return new ADPCMInputStream(stream, disposeAfterUse, size, type, rate, channels, blockAlign); } } // End of namespace Audio |