aboutsummaryrefslogtreecommitdiff
path: root/audio/decoders
diff options
context:
space:
mode:
Diffstat (limited to 'audio/decoders')
-rw-r--r--audio/decoders/aac.cpp7
-rw-r--r--audio/decoders/aac.h7
-rw-r--r--audio/decoders/adpcm.cpp8
-rw-r--r--audio/decoders/adpcm_intern.h5
-rw-r--r--audio/decoders/mp3.cpp10
-rw-r--r--audio/decoders/quicktime.cpp7
-rw-r--r--audio/decoders/quicktime.h7
-rw-r--r--audio/decoders/quicktime_intern.h7
-rw-r--r--audio/decoders/raw.cpp22
-rw-r--r--audio/decoders/vorbis.cpp12
10 files changed, 30 insertions, 62 deletions
diff --git a/audio/decoders/aac.cpp b/audio/decoders/aac.cpp
index 50325dc9f0..7700bb3215 100644
--- a/audio/decoders/aac.cpp
+++ b/audio/decoders/aac.cpp
@@ -8,19 +8,16 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
-
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "audio/decoders/aac.h"
diff --git a/audio/decoders/aac.h b/audio/decoders/aac.h
index c5085fadaa..68e322c844 100644
--- a/audio/decoders/aac.h
+++ b/audio/decoders/aac.h
@@ -8,19 +8,16 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
-
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
/**
diff --git a/audio/decoders/adpcm.cpp b/audio/decoders/adpcm.cpp
index 116f2f776a..535652a0b3 100644
--- a/audio/decoders/adpcm.cpp
+++ b/audio/decoders/adpcm.cpp
@@ -41,8 +41,7 @@ namespace Audio {
// <http://wiki.multimedia.cx/index.php?title=Microsoft_IMA_ADPCM>.
ADPCMStream::ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign)
- : _stream(stream),
- _disposeAfterUse(disposeAfterUse),
+ : _stream(stream, disposeAfterUse),
_startpos(stream->pos()),
_endpos(_startpos + size),
_channels(channels),
@@ -52,11 +51,6 @@ ADPCMStream::ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Fl
reset();
}
-ADPCMStream::~ADPCMStream() {
- if (_disposeAfterUse == DisposeAfterUse::YES)
- delete _stream;
-}
-
void ADPCMStream::reset() {
memset(&_status, 0, sizeof(_status));
_blockPos[0] = _blockPos[1] = _blockAlign; // To make sure first header is read
diff --git a/audio/decoders/adpcm_intern.h b/audio/decoders/adpcm_intern.h
index c9f894fb84..38514d7fca 100644
--- a/audio/decoders/adpcm_intern.h
+++ b/audio/decoders/adpcm_intern.h
@@ -33,6 +33,7 @@
#include "audio/audiostream.h"
#include "common/endian.h"
+#include "common/ptr.h"
#include "common/stream.h"
#include "common/textconsole.h"
@@ -41,8 +42,7 @@ namespace Audio {
class ADPCMStream : public RewindableAudioStream {
protected:
- Common::SeekableReadStream *_stream;
- const DisposeAfterUse::Flag _disposeAfterUse;
+ Common::DisposablePtr<Common::SeekableReadStream> _stream;
const int32 _startpos;
const int32 _endpos;
const int _channels;
@@ -62,7 +62,6 @@ protected:
public:
ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign);
- ~ADPCMStream();
virtual bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); }
virtual bool isStereo() const { return _channels == 2; }
diff --git a/audio/decoders/mp3.cpp b/audio/decoders/mp3.cpp
index 8d7f006ec7..00669945c2 100644
--- a/audio/decoders/mp3.cpp
+++ b/audio/decoders/mp3.cpp
@@ -25,6 +25,7 @@
#ifdef USE_MAD
#include "common/debug.h"
+#include "common/ptr.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
@@ -52,8 +53,7 @@ protected:
MP3_STATE_EOS // end of data reached (may need to loop)
};
- Common::SeekableReadStream *_inStream;
- DisposeAfterUse::Flag _disposeAfterUse;
+ Common::DisposablePtr<Common::SeekableReadStream> _inStream;
uint _posInFrame;
State _state;
@@ -95,8 +95,7 @@ protected:
};
MP3Stream::MP3Stream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) :
- _inStream(inStream),
- _disposeAfterUse(dispose),
+ _inStream(inStream, dispose),
_posInFrame(0),
_state(MP3_STATE_INIT),
_length(0, 1000),
@@ -134,9 +133,6 @@ MP3Stream::MP3Stream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag
MP3Stream::~MP3Stream() {
deinitStream();
-
- if (_disposeAfterUse == DisposeAfterUse::YES)
- delete _inStream;
}
void MP3Stream::decodeMP3Data() {
diff --git a/audio/decoders/quicktime.cpp b/audio/decoders/quicktime.cpp
index a39fedc1d6..8cf0305e88 100644
--- a/audio/decoders/quicktime.cpp
+++ b/audio/decoders/quicktime.cpp
@@ -8,19 +8,16 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
-
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "common/debug.h"
diff --git a/audio/decoders/quicktime.h b/audio/decoders/quicktime.h
index 9f6c6c20e0..4dd1a57710 100644
--- a/audio/decoders/quicktime.h
+++ b/audio/decoders/quicktime.h
@@ -8,19 +8,16 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
-
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
/**
diff --git a/audio/decoders/quicktime_intern.h b/audio/decoders/quicktime_intern.h
index 7ce06b85fe..e31a1d3872 100644
--- a/audio/decoders/quicktime_intern.h
+++ b/audio/decoders/quicktime_intern.h
@@ -8,19 +8,16 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
-
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
/**
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
diff --git a/audio/decoders/vorbis.cpp b/audio/decoders/vorbis.cpp
index 2724dd1f02..64cacb4d58 100644
--- a/audio/decoders/vorbis.cpp
+++ b/audio/decoders/vorbis.cpp
@@ -29,6 +29,7 @@
#ifdef USE_VORBIS
+#include "common/ptr.h"
#include "common/stream.h"
#include "common/textconsole.h"
#include "common/util.h"
@@ -42,6 +43,7 @@
#include <tremor/ivorbisfile.h>
#endif
#else
+#define OV_EXCLUDE_STATIC_CALLBACKS
#include <vorbis/vorbisfile.h>
#endif
@@ -88,8 +90,7 @@ static ov_callbacks g_stream_wrap = {
class VorbisStream : public SeekableAudioStream {
protected:
- Common::SeekableReadStream *_inStream;
- DisposeAfterUse::Flag _disposeAfterUse;
+ Common::DisposablePtr<Common::SeekableReadStream> _inStream;
bool _isStereo;
int _rate;
@@ -120,10 +121,9 @@ protected:
};
VorbisStream::VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) :
- _inStream(inStream),
- _disposeAfterUse(dispose),
+ _inStream(inStream, dispose),
_length(0, 1000),
- _bufferEnd(_buffer + ARRAYSIZE(_buffer)) {
+ _bufferEnd(ARRAYEND(_buffer)) {
int res = ov_open_callbacks(inStream, &_ovFile, NULL, 0, g_stream_wrap);
if (res < 0) {
@@ -149,8 +149,6 @@ VorbisStream::VorbisStream(Common::SeekableReadStream *inStream, DisposeAfterUse
VorbisStream::~VorbisStream() {
ov_clear(&_ovFile);
- if (_disposeAfterUse == DisposeAfterUse::YES)
- delete _inStream;
}
int VorbisStream::readBuffer(int16 *buffer, const int numSamples) {