aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-06 21:46:10 +0100
committerMax Kellermann <max@duempel.org>2014-01-06 21:59:43 +0100
commiteac9fabd4835cfde118ed402154952810450018c (patch)
tree2b7df5f67a3755618975aa90b7643cfbe9a9e006
parente2a08fa824665f13e3a51af5cc7ce12f8253f8b9 (diff)
downloadmpd-eac9fabd4835cfde118ed402154952810450018c.tar.gz
mpd-eac9fabd4835cfde118ed402154952810450018c.tar.xz
mpd-eac9fabd4835cfde118ed402154952810450018c.zip
DecoderBuffer: add method _clear()
-rw-r--r--src/DecoderBuffer.cxx6
-rw-r--r--src/DecoderBuffer.hxx3
-rw-r--r--src/decoder/FaadDecoderPlugin.cxx11
3 files changed, 12 insertions, 8 deletions
diff --git a/src/DecoderBuffer.cxx b/src/DecoderBuffer.cxx
index 6aad53cb2..0b326a6fd 100644
--- a/src/DecoderBuffer.cxx
+++ b/src/DecoderBuffer.cxx
@@ -82,6 +82,12 @@ decoder_buffer_is_full(const DecoderBuffer *buffer)
return buffer->consumed == 0 && buffer->length == buffer->size;
}
+void
+decoder_buffer_clear(DecoderBuffer *buffer)
+{
+ buffer->length = buffer->consumed = 0;
+}
+
static void
decoder_buffer_shift(DecoderBuffer *buffer)
{
diff --git a/src/DecoderBuffer.hxx b/src/DecoderBuffer.hxx
index 92cc31aa4..70cf63faa 100644
--- a/src/DecoderBuffer.hxx
+++ b/src/DecoderBuffer.hxx
@@ -56,6 +56,9 @@ decoder_buffer_is_empty(const DecoderBuffer *buffer);
bool
decoder_buffer_is_full(const DecoderBuffer *buffer);
+void
+decoder_buffer_clear(DecoderBuffer *buffer);
+
/**
* Read data from the input_stream and append it to the buffer.
*
diff --git a/src/decoder/FaadDecoderPlugin.cxx b/src/decoder/FaadDecoderPlugin.cxx
index 35ff0f049..c783997ba 100644
--- a/src/decoder/FaadDecoderPlugin.cxx
+++ b/src/decoder/FaadDecoderPlugin.cxx
@@ -84,7 +84,7 @@ adts_find_frame(DecoderBuffer *buffer)
const uint8_t *p = (const uint8_t *)memchr(data, 0xff, length);
if (p == nullptr) {
/* no marker - discard the buffer */
- decoder_buffer_consume(buffer, length);
+ decoder_buffer_clear(buffer);
continue;
}
@@ -111,10 +111,7 @@ adts_find_frame(DecoderBuffer *buffer)
/* not enough data; discard this frame
to prevent a possible buffer
overflow */
- data = (const uint8_t *)
- decoder_buffer_read(buffer, &length);
- if (data != nullptr)
- decoder_buffer_consume(buffer, length);
+ decoder_buffer_clear(buffer);
}
continue;
@@ -196,9 +193,7 @@ faad_song_duration(DecoderBuffer *buffer, InputStream &is)
is.LockSeek(tagsize, SEEK_SET, IgnoreError());
- data = (const uint8_t *)decoder_buffer_read(buffer, &length);
- if (data != nullptr)
- decoder_buffer_consume(buffer, length);
+ decoder_buffer_clear(buffer);
decoder_buffer_fill(buffer);
return song_length;