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.
This commit is contained in:
parent
eb2e3a554d
commit
85cc46ad6f
@ -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)
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user