aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-09-22 08:18:58 +0200
committerMax Kellermann <max@duempel.org>2014-09-22 08:18:58 +0200
commit3ae0d6f4210e370225cf0b9177f6c16d84d9255b (patch)
tree946d5a451428d070b9be905f8e900def60e1f0a3 /src
parent13b66a77c73dbb5d00d439d42be82c004ac16ea1 (diff)
downloadmpd-3ae0d6f4210e370225cf0b9177f6c16d84d9255b.tar.gz
mpd-3ae0d6f4210e370225cf0b9177f6c16d84d9255b.tar.xz
mpd-3ae0d6f4210e370225cf0b9177f6c16d84d9255b.zip
DecoderBuffer: export the struct
Eliminates the functions _new() and _free().
Diffstat (limited to 'src')
-rw-r--r--src/decoder/DecoderBuffer.cxx29
-rw-r--r--src/decoder/DecoderBuffer.hxx45
-rw-r--r--src/decoder/plugins/FaadDecoderPlugin.cxx12
3 files changed, 28 insertions, 58 deletions
diff --git a/src/decoder/DecoderBuffer.cxx b/src/decoder/DecoderBuffer.cxx
index 895729da3..df536e2b5 100644
--- a/src/decoder/DecoderBuffer.cxx
+++ b/src/decoder/DecoderBuffer.cxx
@@ -21,38 +21,9 @@
#include "DecoderBuffer.hxx"
#include "DecoderAPI.hxx"
#include "util/ConstBuffer.hxx"
-#include "util/DynamicFifoBuffer.hxx"
#include <assert.h>
-struct DecoderBuffer {
- Decoder *const decoder;
- InputStream &is;
-
- DynamicFifoBuffer<uint8_t> buffer;
-
- DecoderBuffer(Decoder *_decoder, InputStream &_is,
- size_t _size)
- :decoder(_decoder), is(_is), buffer(_size) {}
-};
-
-DecoderBuffer *
-decoder_buffer_new(Decoder *decoder, InputStream &is,
- size_t size)
-{
- assert(size > 0);
-
- return new DecoderBuffer(decoder, is, size);
-}
-
-void
-decoder_buffer_free(DecoderBuffer *buffer)
-{
- assert(buffer != nullptr);
-
- delete buffer;
-}
-
const InputStream &
decoder_buffer_get_stream(const DecoderBuffer *buffer)
{
diff --git a/src/decoder/DecoderBuffer.hxx b/src/decoder/DecoderBuffer.hxx
index 4a482be75..79db7401d 100644
--- a/src/decoder/DecoderBuffer.hxx
+++ b/src/decoder/DecoderBuffer.hxx
@@ -21,38 +21,37 @@
#define MPD_DECODER_BUFFER_HXX
#include "Compiler.h"
+#include "util/DynamicFifoBuffer.hxx"
#include <stddef.h>
-/**
- * This objects handles buffered reads in decoder plugins easily. You
- * create a buffer object, and use its high-level methods to fill and
- * read it. It will automatically handle shifting the buffer.
- */
-struct DecoderBuffer;
-
struct Decoder;
class InputStream;
-
template<typename T> struct ConstBuffer;
/**
- * Creates a new buffer.
- *
- * @param decoder the decoder object, used for decoder_read(), may be nullptr
- * @param is the input stream object where we should read from
- * @param size the maximum size of the buffer
- * @return the new decoder_buffer object
- */
-DecoderBuffer *
-decoder_buffer_new(Decoder *decoder, InputStream &is,
- size_t size);
-
-/**
- * Frees resources used by the decoder_buffer object.
+ * This objects handles buffered reads in decoder plugins easily. You
+ * create a buffer object, and use its high-level methods to fill and
+ * read it. It will automatically handle shifting the buffer.
*/
-void
-decoder_buffer_free(DecoderBuffer *buffer);
+struct DecoderBuffer {
+ Decoder *const decoder;
+ InputStream &is;
+
+ DynamicFifoBuffer<uint8_t> buffer;
+
+ /**
+ * Creates a new buffer.
+ *
+ * @param _decoder the decoder object, used for decoder_read(),
+ * may be nullptr
+ * @param _is the input stream object where we should read from
+ * @param _size the maximum size of the buffer
+ */
+ DecoderBuffer(Decoder *_decoder, InputStream &_is,
+ size_t _size)
+ :decoder(_decoder), is(_is), buffer(_size) {}
+};
gcc_pure
const InputStream &
diff --git a/src/decoder/plugins/FaadDecoderPlugin.cxx b/src/decoder/plugins/FaadDecoderPlugin.cxx
index d59309a3a..6a2744243 100644
--- a/src/decoder/plugins/FaadDecoderPlugin.cxx
+++ b/src/decoder/plugins/FaadDecoderPlugin.cxx
@@ -308,8 +308,8 @@ static std::pair<bool, SignedSongTime>
faad_get_file_time(InputStream &is)
{
DecoderBuffer *buffer =
- decoder_buffer_new(nullptr, is,
- FAAD_MIN_STREAMSIZE * MAX_CHANNELS);
+ new DecoderBuffer(nullptr, is,
+ FAAD_MIN_STREAMSIZE * MAX_CHANNELS);
auto duration = faad_song_duration(buffer, is);
bool recognized = !duration.IsNegative();
@@ -326,7 +326,7 @@ faad_get_file_time(InputStream &is)
NeAACDecClose(decoder);
}
- decoder_buffer_free(buffer);
+ delete buffer;
return std::make_pair(recognized, duration);
}
@@ -415,8 +415,8 @@ static void
faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
{
DecoderBuffer *buffer =
- decoder_buffer_new(&mpd_decoder, is,
- FAAD_MIN_STREAMSIZE * MAX_CHANNELS);
+ new DecoderBuffer(&mpd_decoder, is,
+ FAAD_MIN_STREAMSIZE * MAX_CHANNELS);
/* create the libfaad decoder */
@@ -427,7 +427,7 @@ faad_stream_decode(Decoder &mpd_decoder, InputStream &is)
/* cleanup */
NeAACDecClose(decoder);
- decoder_buffer_free(buffer);
+ delete buffer;
}
static bool