aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/DecoderBuffer.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder/DecoderBuffer.hxx')
-rw-r--r--src/decoder/DecoderBuffer.hxx45
1 files changed, 22 insertions, 23 deletions
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 &