diff options
Diffstat (limited to 'audio/audiostream.cpp')
-rw-r--r-- | audio/audiostream.cpp | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/audio/audiostream.cpp b/audio/audiostream.cpp index 547aa77526..1c5c435359 100644 --- a/audio/audiostream.cpp +++ b/audio/audiostream.cpp @@ -61,15 +61,13 @@ static const StreamFileFormat STREAM_FILEFORMATS[] = { { "MPEG Layer 3", ".mp3", makeMP3Stream }, #endif { "MPEG-4 Audio", ".m4a", makeQuickTimeStream }, - - { NULL, NULL, NULL } // Terminator }; SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &basename) { SeekableAudioStream *stream = NULL; Common::File *fileHandle = new Common::File(); - for (int i = 0; i < ARRAYSIZE(STREAM_FILEFORMATS)-1 && stream == NULL; ++i) { + for (int i = 0; i < ARRAYSIZE(STREAM_FILEFORMATS); ++i) { Common::String filename = basename + STREAM_FILEFORMATS[i].fileExtension; fileHandle->open(filename); if (fileHandle->isOpen()) { @@ -93,7 +91,7 @@ SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &b #pragma mark - LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse) - : _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), _completeIterations(0) { + : _parent(stream, disposeAfterUse), _loops(loops), _completeIterations(0) { assert(stream); if (!stream->rewind()) { @@ -102,11 +100,6 @@ LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops } } -LoopingAudioStream::~LoopingAudioStream() { - if (_disposeAfterUse == DisposeAfterUse::YES) - delete _parent; -} - int LoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { if ((_loops && _completeIterations == _loops) || !numSamples) return 0; @@ -169,7 +162,7 @@ SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream, const Timestamp loopStart, const Timestamp loopEnd, DisposeAfterUse::Flag disposeAfterUse) - : _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), + : _parent(stream, disposeAfterUse), _loops(loops), _pos(0, getRate() * (isStereo() ? 2 : 1)), _loopStart(convertTimeToStreamPos(loopStart, getRate(), isStereo())), _loopEnd(convertTimeToStreamPos(loopEnd, getRate(), isStereo())), @@ -180,11 +173,6 @@ SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream, _done = true; } -SubLoopingAudioStream::~SubLoopingAudioStream() { - if (_disposeAfterUse == DisposeAfterUse::YES) - delete _parent; -} - int SubLoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { if (_done) return 0; @@ -225,7 +213,7 @@ int SubLoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { #pragma mark - SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse) - : _parent(parent), _disposeAfterUse(disposeAfterUse), + : _parent(parent, disposeAfterUse), _start(convertTimeToStreamPos(start, getRate(), isStereo())), _pos(0, getRate() * (isStereo() ? 2 : 1)), _length(convertTimeToStreamPos(end, getRate(), isStereo()) - _start) { @@ -234,11 +222,6 @@ SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, cons _parent->seek(_start); } -SubSeekableAudioStream::~SubSeekableAudioStream() { - if (_disposeAfterUse) - delete _parent; -} - int SubSeekableAudioStream::readBuffer(int16 *buffer, const int numSamples) { int framesLeft = MIN(_length.frameDiff(_pos), numSamples); int framesRead = _parent->readBuffer(buffer, framesLeft); |