aboutsummaryrefslogtreecommitdiff
path: root/audio/decoders/raw.cpp
diff options
context:
space:
mode:
authorChristoph Mallon2011-08-06 16:30:52 +0200
committerChristoph Mallon2011-08-07 15:19:08 +0200
commita5a8833c059f28c85e392a3cd22c361d38ef95ff (patch)
tree3b3b69326019444c2c375c66f39cb3013a003591 /audio/decoders/raw.cpp
parent2f23ff72c1d804d9d0e3ac09c46f52fd6b23a68c (diff)
downloadscummvm-rg350-a5a8833c059f28c85e392a3cd22c361d38ef95ff.tar.gz
scummvm-rg350-a5a8833c059f28c85e392a3cd22c361d38ef95ff.tar.bz2
scummvm-rg350-a5a8833c059f28c85e392a3cd22c361d38ef95ff.zip
COMMON: Add DisposablePtr<T>, which replaces many repeated implementations of a dispose flag.
Diffstat (limited to 'audio/decoders/raw.cpp')
-rw-r--r--audio/decoders/raw.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/audio/decoders/raw.cpp b/audio/decoders/raw.cpp
index 4789fd0f36..881b8c1d6a 100644
--- a/audio/decoders/raw.cpp
+++ b/audio/decoders/raw.cpp
@@ -51,7 +51,7 @@ template<bool is16Bit, bool isUnsigned, bool isLE>
class RawStream : public SeekableAudioStream {
public:
RawStream(int rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream, const RawStreamBlockList &blocks)
- : _rate(rate), _isStereo(stereo), _playtime(0, rate), _stream(stream), _disposeAfterUse(disposeStream), _blocks(blocks), _curBlock(_blocks.begin()), _blockLeft(0), _buffer(0) {
+ : _rate(rate), _isStereo(stereo), _playtime(0, rate), _stream(stream, disposeStream), _blocks(blocks), _curBlock(_blocks.begin()), _blockLeft(0), _buffer(0) {
assert(_blocks.size() > 0);
@@ -82,9 +82,6 @@ public:
}
~RawStream() {
- if (_disposeAfterUse == DisposeAfterUse::YES)
- delete _stream;
-
delete[] _buffer;
}
@@ -98,15 +95,14 @@ public:
bool seek(const Timestamp &where);
private:
- const int _rate; ///< Sample rate of stream
- const bool _isStereo; ///< Whether this is an stereo stream
- Timestamp _playtime; ///< Calculated total play time
- Common::SeekableReadStream *_stream; ///< Stream to read data from
- const DisposeAfterUse::Flag _disposeAfterUse; ///< Indicates whether the stream object should be deleted when this RawStream is destructed
- const RawStreamBlockList _blocks; ///< Audio block list
-
- RawStreamBlockList::const_iterator _curBlock; ///< Current audio block number
- int32 _blockLeft; ///< How many bytes are still left in the current block
+ const int _rate; ///< Sample rate of stream
+ const bool _isStereo; ///< Whether this is an stereo stream
+ Timestamp _playtime; ///< Calculated total play time
+ Common::DisposablePtr<Common::SeekableReadStream> _stream; ///< Stream to read data from
+ const RawStreamBlockList _blocks; ///< Audio block list
+
+ RawStreamBlockList::const_iterator _curBlock; ///< Current audio block number
+ int32 _blockLeft; ///< How many bytes are still left in the current block
/**
* Advance one block in the stream in case