diff options
author | Max Horn | 2010-01-16 21:36:08 +0000 |
---|---|---|
committer | Max Horn | 2010-01-16 21:36:08 +0000 |
commit | 7ec2da968c9c572daa888e4f3215e99ba0e9e86b (patch) | |
tree | 17170e1ada083a09a6bbb8ac89889a9938473fa3 /sound | |
parent | b8f2a3a34271b73ab2cb84ea25e5fbf80e076658 (diff) | |
download | scummvm-rg350-7ec2da968c9c572daa888e4f3215e99ba0e9e86b.tar.gz scummvm-rg350-7ec2da968c9c572daa888e4f3215e99ba0e9e86b.tar.bz2 scummvm-rg350-7ec2da968c9c572daa888e4f3215e99ba0e9e86b.zip |
Switch most AudioStream factories to use DisposeAfterUse::Flag
svn-id: r47334
Diffstat (limited to 'sound')
-rw-r--r-- | sound/audiostream.cpp | 53 | ||||
-rw-r--r-- | sound/audiostream.h | 25 | ||||
-rw-r--r-- | sound/flac.cpp | 2 | ||||
-rw-r--r-- | sound/flac.h | 3 | ||||
-rw-r--r-- | sound/mp3.cpp | 10 | ||||
-rw-r--r-- | sound/mp3.h | 3 | ||||
-rw-r--r-- | sound/voc.cpp | 8 | ||||
-rw-r--r-- | sound/voc.h | 5 | ||||
-rw-r--r-- | sound/vorbis.cpp | 10 | ||||
-rw-r--r-- | sound/vorbis.h | 3 | ||||
-rw-r--r-- | sound/wave.cpp | 6 | ||||
-rw-r--r-- | sound/wave.h | 3 |
12 files changed, 69 insertions, 62 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 168ca49e2d..d8d2533bc7 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -55,7 +55,7 @@ struct StreamFileFormat { * Pointer to a function which tries to open a file of type StreamFormat. * Return NULL in case of an error (invalid/nonexisting file). */ - SeekableAudioStream *(*openStreamFile)(Common::SeekableReadStream *stream, bool disposeAfterUse); + SeekableAudioStream *(*openStreamFile)(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse); }; static const StreamFileFormat STREAM_FILEFORMATS[] = { @@ -83,7 +83,7 @@ SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &b fileHandle->open(filename); if (fileHandle->isOpen()) { // Create the stream object - stream = STREAM_FILEFORMATS[i].openStreamFile(fileHandle, true); + stream = STREAM_FILEFORMATS[i].openStreamFile(fileHandle, DisposeAfterUse::YES); fileHandle = 0; break; } @@ -102,12 +102,12 @@ SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &b #pragma mark --- LoopingAudioStream --- #pragma mark - -LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops, bool disposeAfterUse) +LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse) : _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), _completeIterations(0) { } LoopingAudioStream::~LoopingAudioStream() { - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) delete _parent; } @@ -169,7 +169,7 @@ SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream, uint loops, const Timestamp loopStart, const Timestamp loopEnd, - bool disposeAfterUse) + DisposeAfterUse::Flag disposeAfterUse) : _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), _pos(0, getRate() * (isStereo() ? 2 : 1)), _loopStart(loopStart.convertToFramerate(getRate() * (isStereo() ? 2 : 1))), @@ -180,7 +180,7 @@ SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream, } SubLoopingAudioStream::~SubLoopingAudioStream() { - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) delete _parent; } @@ -218,7 +218,7 @@ int SubLoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { #pragma mark --- SubSeekableAudioStream --- #pragma mark - -SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, bool disposeAfterUse) +SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse) : _parent(parent), _disposeAfterUse(disposeAfterUse), _start(start.convertToFramerate(getRate())), _pos(0, getRate() * (isStereo() ? 2 : 1)), @@ -279,18 +279,18 @@ protected: const byte *_end; const int _rate; const byte *_origPtr; - const bool _disposeAfterUse; + const DisposeAfterUse::Flag _disposeAfterUse; const Timestamp _playtime; public: - LinearMemoryStream(int rate, const byte *ptr, uint len, bool autoFreeMemory) + LinearMemoryStream(int rate, const byte *ptr, uint len, DisposeAfterUse::Flag autoFreeMemory) : _ptr(ptr), _end(ptr+len), _rate(rate), _origPtr(ptr), _disposeAfterUse(autoFreeMemory), _playtime(0, len / (is16Bit ? 2 : 1) / (stereo ? 2 : 1), rate) { } virtual ~LinearMemoryStream() { - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) free(const_cast<byte *>(_origPtr)); } @@ -364,13 +364,13 @@ protected: int32 _filePos; ///< Current position in stream int32 _diskLeft; ///< Samples left in stream in current block not yet read to buffer int32 _bufferLeft; ///< Samples left in buffer in current block - bool _disposeAfterUse; ///< If true, delete stream object when LinearDiskStream is destructed + const DisposeAfterUse::Flag _disposeAfterUse; ///< Indicates whether the stream object should be deleted when this LinearDiskStream is destructed LinearDiskStreamAudioBlock *_audioBlock; ///< Audio block list - int _audioBlockCount; ///< Number of blocks in _audioBlock + const int _audioBlockCount; ///< Number of blocks in _audioBlock int _currentBlock; ///< Current audio block number public: - LinearDiskStream(int rate, bool disposeStream, Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, uint numBlocks) + LinearDiskStream(int rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, uint numBlocks) : _rate(rate), _playtime(0, rate), _stream(stream), _disposeAfterUse(disposeStream), _audioBlockCount(numBlocks) { @@ -407,7 +407,7 @@ public: virtual ~LinearDiskStream() { - if (_disposeAfterUse) { + if (_disposeAfterUse == DisposeAfterUse::YES) { delete _stream; } @@ -543,7 +543,7 @@ SeekableAudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate const bool is16Bit = (flags & Mixer::FLAG_16BITS) != 0; const bool isUnsigned = (flags & Mixer::FLAG_UNSIGNED) != 0; const bool isLE = (flags & Mixer::FLAG_LITTLE_ENDIAN) != 0; - const bool autoFree = (flags & Mixer::FLAG_AUTOFREE) != 0; + const DisposeAfterUse::Flag autoFree = (flags & Mixer::FLAG_AUTOFREE) != 0 ? DisposeAfterUse::YES : DisposeAfterUse::NO; // Verify the buffer sizes are sane if (is16Bit && isStereo) { @@ -605,14 +605,15 @@ AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, #define MAKE_LINEAR_DISK(STEREO, UNSIGNED) \ if (is16Bit) { \ if (isLE) \ - return new LinearDiskStream<STEREO, true, UNSIGNED, true>(rate, takeOwnership, stream, block, numBlocks); \ + return new LinearDiskStream<STEREO, true, UNSIGNED, true>(rate, disposeStream, stream, block, numBlocks); \ else \ - return new LinearDiskStream<STEREO, true, UNSIGNED, false>(rate, takeOwnership, stream, block, numBlocks); \ + return new LinearDiskStream<STEREO, true, UNSIGNED, false>(rate, disposeStream, stream, block, numBlocks); \ } else \ - return new LinearDiskStream<STEREO, false, UNSIGNED, false>(rate, takeOwnership, stream, block, numBlocks) + return new LinearDiskStream<STEREO, false, UNSIGNED, false>(rate, disposeStream, stream, block, numBlocks) -SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, int numBlocks, int rate, byte flags, bool takeOwnership) { +SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, int numBlocks, + int rate, byte flags, DisposeAfterUse::Flag disposeStream) { const bool isStereo = (flags & Mixer::FLAG_STEREO) != 0; const bool is16Bit = (flags & Mixer::FLAG_16BITS) != 0; const bool isUnsigned = (flags & Mixer::FLAG_UNSIGNED) != 0; @@ -634,7 +635,7 @@ SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, Li } AudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, - int numBlocks, int rate, byte flags, bool disposeStream, uint loopStart, uint loopEnd) { + int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream, uint loopStart, uint loopEnd) { SeekableAudioStream *s = makeLinearDiskStream(stream, block, numBlocks, rate, flags, disposeStream); const bool isStereo = (flags & Mixer::FLAG_STEREO) != 0; @@ -683,8 +684,8 @@ private: */ struct StreamHolder { AudioStream *_stream; - bool _disposeAfterUse; - StreamHolder(AudioStream *stream, bool disposeAfterUse) + DisposeAfterUse::Flag _disposeAfterUse; + StreamHolder(AudioStream *stream, DisposeAfterUse::Flag disposeAfterUse) : _stream(stream), _disposeAfterUse(disposeAfterUse) {} }; @@ -731,7 +732,7 @@ public: virtual bool endOfStream() const { return _finished && _queue.empty(); } // Implement the QueuingAudioStream API - virtual void queueAudioStream(AudioStream *stream, bool disposeAfterUse); + virtual void queueAudioStream(AudioStream *stream, DisposeAfterUse::Flag disposeAfterUse); virtual void finish() { _finished = true; } uint32 numQueuedStreams() const { @@ -743,12 +744,12 @@ public: QueuingAudioStreamImpl::~QueuingAudioStreamImpl() { while (!_queue.empty()) { StreamHolder tmp = _queue.pop(); - if (tmp._disposeAfterUse) + if (tmp._disposeAfterUse == DisposeAfterUse::YES) delete tmp._stream; } } -void QueuingAudioStreamImpl::queueAudioStream(AudioStream *stream, bool disposeAfterUse) { +void QueuingAudioStreamImpl::queueAudioStream(AudioStream *stream, DisposeAfterUse::Flag disposeAfterUse) { if ((stream->getRate() != getRate()) || (stream->isStereo() != isStereo())) error("QueuingAudioStreamImpl::queueAudioStream: stream has mismatched parameters"); @@ -766,7 +767,7 @@ int QueuingAudioStreamImpl::readBuffer(int16 *buffer, const int numSamples) { if (stream->endOfData() ) { StreamHolder tmp = _queue.pop(); - if (tmp._disposeAfterUse) + if (tmp._disposeAfterUse == DisposeAfterUse::YES) delete stream; } } diff --git a/sound/audiostream.h b/sound/audiostream.h index 83bada8740..4174fe017d 100644 --- a/sound/audiostream.h +++ b/sound/audiostream.h @@ -29,6 +29,7 @@ #include "common/util.h" #include "common/scummsys.h" #include "common/stream.h" +#include "common/types.h" #include "sound/timestamp.h" @@ -115,7 +116,7 @@ public: * @param loops How often to loop (0 = infinite) * @param disposeAfteruse Destroy the stream after the LoopingAudioStream has finished playback. */ - LoopingAudioStream(RewindableAudioStream *stream, uint loops, bool disposeAfterUse = true); + LoopingAudioStream(RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); ~LoopingAudioStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -131,7 +132,7 @@ public: uint getCompleteIterations() const { return _completeIterations; } private: RewindableAudioStream *_parent; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; uint _loops; uint _completeIterations; @@ -232,7 +233,7 @@ public: SubLoopingAudioStream(SeekableAudioStream *stream, uint loops, const Timestamp loopStart, const Timestamp loopEnd, - bool disposeAfterUse = true); + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); ~SubLoopingAudioStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -242,7 +243,7 @@ public: int getRate() const { return _parent->getRate(); } private: SeekableAudioStream *_parent; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; uint _loops; Timestamp _pos; @@ -271,9 +272,9 @@ public: * @param parent parent stream object. * @param start Start time. * @param end End time. - * @param disposeAfterUse Whether the parent stream object should be destroied on desctruction of the SubSeekableAudioStream. + * @param disposeAfterUse Whether the parent stream object should be destroyed on destruction of the SubSeekableAudioStream. */ - SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, bool disposeAfterUse = true); + SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); ~SubSeekableAudioStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -289,7 +290,7 @@ public: Timestamp getLength() const { return _length; } private: SeekableAudioStream *_parent; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; const Timestamp _start; const Timestamp _length; @@ -342,11 +343,11 @@ struct LinearDiskStreamAudioBlock { * @param len Length of the data (in bytes!) * @param flags Flags combination. * @see Mixer::RawFlags - * @param disposeStream Wheter the "stream" object should be destroyed after playback. + * @param disposeStream Whether the "stream" object should be destroyed after playback. * @return The new SeekableAudioStream (or 0 on failure). */ SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, - int numBlocks, int rate, byte flags, bool disposeStream); + int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream); /** * NOTE: @@ -358,7 +359,7 @@ SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, Li * each block of uncompressed audio in the stream. */ AudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, - int numBlocks, int rate, byte flags, bool disposeStream, uint loopStart, uint loopEnd); + int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream, uint loopStart, uint loopEnd); class QueuingAudioStream : public Audio::AudioStream { public: @@ -370,7 +371,7 @@ public: * deleted after all data contained in it has been played. */ virtual void queueAudioStream(Audio::AudioStream *audStream, - bool disposeAfterUse = true) = 0; + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES) = 0; /** * Queue a block of raw audio data for playback. This stream @@ -381,7 +382,7 @@ public: */ void queueBuffer(byte *data, uint32 size, byte flags) { AudioStream *stream = makeLinearInputStream(data, size, getRate(), flags, 0, 0); - queueAudioStream(stream, true); + queueAudioStream(stream, DisposeAfterUse::YES); } /** diff --git a/sound/flac.cpp b/sound/flac.cpp index 1c7f03b9d1..eb195e0c7b 100644 --- a/sound/flac.cpp +++ b/sound/flac.cpp @@ -726,7 +726,7 @@ void FlacInputStream::callWrapError(const ::FLAC__SeekableStreamDecoder *decoder SeekableAudioStream *makeFlacStream( Common::SeekableReadStream *stream, - bool disposeAfterUse) { + DisposeAfterUse::Flag disposeAfterUse) { return new FlacInputStream(stream, disposeAfterUse); } diff --git a/sound/flac.h b/sound/flac.h index 7c891d41d8..e35b608253 100644 --- a/sound/flac.h +++ b/sound/flac.h @@ -41,6 +41,7 @@ #ifndef SOUND_FLAC_H #define SOUND_FLAC_H +#include "common/types.h" #include "common/scummsys.h" #ifdef USE_FLAC @@ -64,7 +65,7 @@ class SeekableAudioStream; */ SeekableAudioStream *makeFlacStream( Common::SeekableReadStream *stream, - bool disposeAfterUse); + DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio diff --git a/sound/mp3.cpp b/sound/mp3.cpp index 98144621c8..26f0e6d320 100644 --- a/sound/mp3.cpp +++ b/sound/mp3.cpp @@ -54,7 +54,7 @@ protected: }; Common::SeekableReadStream *_inStream; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; uint _posInFrame; State _state; @@ -75,7 +75,7 @@ protected: public: MP3InputStream(Common::SeekableReadStream *inStream, - bool dispose); + DisposeAfterUse::Flag dispose); ~MP3InputStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -95,7 +95,7 @@ protected: void deinitStream(); }; -MP3InputStream::MP3InputStream(Common::SeekableReadStream *inStream, bool dispose) : +MP3InputStream::MP3InputStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) : _inStream(inStream), _disposeAfterUse(dispose), _posInFrame(0), @@ -129,7 +129,7 @@ MP3InputStream::MP3InputStream(Common::SeekableReadStream *inStream, bool dispos MP3InputStream::~MP3InputStream() { deinitStream(); - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) delete _inStream; } @@ -340,7 +340,7 @@ int MP3InputStream::readBuffer(int16 *buffer, const int numSamples) { SeekableAudioStream *makeMP3Stream( Common::SeekableReadStream *stream, - bool disposeAfterUse) { + DisposeAfterUse::Flag disposeAfterUse) { return new MP3InputStream(stream, disposeAfterUse); } diff --git a/sound/mp3.h b/sound/mp3.h index ca5a65ee00..3175df5e92 100644 --- a/sound/mp3.h +++ b/sound/mp3.h @@ -41,6 +41,7 @@ #ifndef SOUND_MP3_H #define SOUND_MP3_H +#include "common/types.h" #include "common/scummsys.h" #ifdef USE_MAD @@ -64,7 +65,7 @@ class SeekableAudioStream; */ SeekableAudioStream *makeMP3Stream( Common::SeekableReadStream *stream, - bool disposeAfterUse); + DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio diff --git a/sound/voc.cpp b/sound/voc.cpp index 79a64769f7..9247d5276e 100644 --- a/sound/voc.cpp +++ b/sound/voc.cpp @@ -298,7 +298,7 @@ int parseVOCFormat(Common::SeekableReadStream& stream, LinearDiskStreamAudioBloc return currentBlock; } -AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, bool takeOwnership) { +AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, DisposeAfterUse::Flag takeOwnership) { const int MAX_AUDIO_BLOCKS = 256; LinearDiskStreamAudioBlock *block = new LinearDiskStreamAudioBlock[MAX_AUDIO_BLOCKS]; @@ -318,7 +318,7 @@ AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, b return audioStream; } -SeekableAudioStream *makeVOCDiskStreamNoLoop(Common::SeekableReadStream &stream, byte flags, bool takeOwnership) { +SeekableAudioStream *makeVOCDiskStreamNoLoop(Common::SeekableReadStream &stream, byte flags, DisposeAfterUse::Flag takeOwnership) { const int MAX_AUDIO_BLOCKS = 256; LinearDiskStreamAudioBlock *block = new LinearDiskStreamAudioBlock[MAX_AUDIO_BLOCKS]; @@ -341,7 +341,7 @@ SeekableAudioStream *makeVOCDiskStreamNoLoop(Common::SeekableReadStream &stream, #endif -AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, uint loopStart, uint loopEnd, bool takeOwnershipOfStream) { +AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, uint loopStart, uint loopEnd, DisposeAfterUse::Flag takeOwnershipOfStream) { #ifdef STREAM_AUDIO_FROM_DISK return makeVOCDiskStream(stream, flags, takeOwnershipOfStream); #else @@ -356,7 +356,7 @@ AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, uint #endif } -SeekableAudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, bool takeOwnershipOfStream) { +SeekableAudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, DisposeAfterUse::Flag takeOwnershipOfStream) { #ifdef STREAM_AUDIO_FROM_DISK return makeVOCDiskStreamNoLoop(stream, flags, takeOwnershipOfStream); #else diff --git a/sound/voc.h b/sound/voc.h index 6008d3a7d7..191f42db02 100644 --- a/sound/voc.h +++ b/sound/voc.h @@ -38,6 +38,7 @@ #ifndef SOUND_VOC_H #define SOUND_VOC_H +#include "common/types.h" #include "common/scummsys.h" namespace Common { class ReadStream; } @@ -94,12 +95,12 @@ extern byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate) * * This function uses loadVOCFromStream() internally. */ -AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags = 0, uint loopStart = 0, uint loopEnd = 0, bool takeOwnershipOfStream = false); +AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags = 0, uint loopStart = 0, uint loopEnd = 0, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO); /** * This does not use any of the looping features of VOC files! */ -SeekableAudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, bool takeOwnershipOfStream); +SeekableAudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp index ed1ccf1346..4ce2f2c3f7 100644 --- a/sound/vorbis.cpp +++ b/sound/vorbis.cpp @@ -88,7 +88,7 @@ static ov_callbacks g_stream_wrap = { class VorbisInputStream : public SeekableAudioStream { protected: Common::SeekableReadStream *_inStream; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; bool _isStereo; int _rate; @@ -103,7 +103,7 @@ protected: public: // startTime / duration are in milliseconds - VorbisInputStream(Common::SeekableReadStream *inStream, bool dispose); + VorbisInputStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose); ~VorbisInputStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -118,7 +118,7 @@ protected: bool refill(); }; -VorbisInputStream::VorbisInputStream(Common::SeekableReadStream *inStream, bool dispose) : +VorbisInputStream::VorbisInputStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) : _inStream(inStream), _disposeAfterUse(dispose), _length(0, 1000), @@ -148,7 +148,7 @@ VorbisInputStream::VorbisInputStream(Common::SeekableReadStream *inStream, bool VorbisInputStream::~VorbisInputStream() { ov_clear(&_ovFile); - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) delete _inStream; } @@ -241,7 +241,7 @@ bool VorbisInputStream::refill() { SeekableAudioStream *makeVorbisStream( Common::SeekableReadStream *stream, - bool disposeAfterUse) { + DisposeAfterUse::Flag disposeAfterUse) { return new VorbisInputStream(stream, disposeAfterUse); } diff --git a/sound/vorbis.h b/sound/vorbis.h index 9e49eead55..dd0a89bfdd 100644 --- a/sound/vorbis.h +++ b/sound/vorbis.h @@ -41,6 +41,7 @@ #ifndef SOUND_VORBIS_H #define SOUND_VORBIS_H +#include "common/types.h" #include "common/scummsys.h" #ifdef USE_VORBIS @@ -64,7 +65,7 @@ class SeekableAudioStream; */ SeekableAudioStream *makeVorbisStream( Common::SeekableReadStream *stream, - bool disposeAfterUse); + DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio diff --git a/sound/wave.cpp b/sound/wave.cpp index e1a466393f..83a880dada 100644 --- a/sound/wave.cpp +++ b/sound/wave.cpp @@ -161,14 +161,14 @@ bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate, return true; } -RewindableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, bool disposeAfterUse) { +RewindableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse) { int size, rate; byte flags; uint16 type; int blockAlign; if (!loadWAVFromStream(*stream, size, rate, flags, &type, &blockAlign)) { - if (disposeAfterUse) + if (disposeAfterUse == DisposeAfterUse::YES) delete stream; return 0; } @@ -184,7 +184,7 @@ RewindableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, bool di assert(data); stream->read(data, size); - if (disposeAfterUse) + if (disposeAfterUse == DisposeAfterUse::YES) delete stream; // Since we allocated our own buffer for the data, we must set the autofree flag. diff --git a/sound/wave.h b/sound/wave.h index 542c38a31d..f0e3bb249b 100644 --- a/sound/wave.h +++ b/sound/wave.h @@ -38,6 +38,7 @@ #ifndef SOUND_WAVE_H #define SOUND_WAVE_H +#include "common/types.h" #include "common/scummsys.h" namespace Common { class SeekableReadStream; } @@ -74,7 +75,7 @@ extern bool loadWAVFromStream( */ RewindableAudioStream *makeWAVStream( Common::SeekableReadStream *stream, - bool disposeAfterUse = false); + DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio |