Commit 85cc46ad authored by Max Kellermann's avatar Max Kellermann

decoder_internal: don't push empty chunk into pipe

When the decoder chunk is empty in decoder_flush_chunk(), don't push it into the music pipe - return it to the music buffer instead. An empty chunk in the pipe wastes resources for no advantage.
parent eb2e3a55
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "pipe.h" #include "pipe.h"
#include "input_stream.h" #include "input_stream.h"
#include "buffer.h" #include "buffer.h"
#include "chunk.h"
#include <assert.h> #include <assert.h>
...@@ -73,6 +74,10 @@ decoder_flush_chunk(struct decoder *decoder) ...@@ -73,6 +74,10 @@ decoder_flush_chunk(struct decoder *decoder)
assert(decoder != NULL); assert(decoder != NULL);
assert(decoder->chunk != NULL); assert(decoder->chunk != NULL);
music_pipe_push(dc.pipe, decoder->chunk); if (music_chunk_is_empty(decoder->chunk))
music_buffer_return(dc.buffer, decoder->chunk);
else
music_pipe_push(dc.pipe, decoder->chunk);
decoder->chunk = NULL; decoder->chunk = NULL;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment