[vlc-commits] decoder: add input_DecoderDrain()
Rémi Denis-Courmont
git at videolan.org
Sat Mar 21 18:20:09 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 21 19:09:31 2015 +0200| [132f872d78a5f489908a0b108cd3f3544a9cf0f7] | committer: Rémi Denis-Courmont
decoder: add input_DecoderDrain()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=132f872d78a5f489908a0b108cd3f3544a9cf0f7
---
include/vlc_input.h | 1 +
src/input/decoder.c | 20 +++++++++++++++++++-
src/libvlccore.sym | 1 +
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/include/vlc_input.h b/include/vlc_input.h
index a6ea432..5b05ce8 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -617,6 +617,7 @@ static inline int input_ModifyPcrSystem( input_thread_t *p_input, bool b_absolut
VLC_API decoder_t * input_DecoderCreate( vlc_object_t *, const es_format_t *, input_resource_t * ) VLC_USED;
VLC_API void input_DecoderDelete( decoder_t * );
VLC_API void input_DecoderDecode( decoder_t *, block_t *, bool b_do_pace );
+VLC_API void input_DecoderDrain( decoder_t * );
VLC_API void input_DecoderFlush( decoder_t * );
/**
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 703ddd0..65dc511 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1925,6 +1925,24 @@ bool input_DecoderIsEmpty( decoder_t * p_dec )
return b_empty;
}
+/**
+ * Signals that there are no further blocks to decode, and requests that the
+ * decoder drain all pending buffers. This is used to ensure that all
+ * intermediate buffers empty and no samples get lost at the end of the stream.
+ *
+ * @note The function does not actually wait for draining. It just signals that
+ * draining should be performed once the decoder has emptied FIFO.
+ */
+void input_DecoderDrain( decoder_t *p_dec )
+{
+ block_t *p_block = block_Alloc(0);
+ if( unlikely(p_block == NULL) )
+ return;
+
+ p_block->i_flags |= BLOCK_FLAG_CORE_EOS;
+ input_DecoderDecode( p_dec, p_block, false );
+}
+
static void DecoderFlush( decoder_t *p_dec )
{
decoder_owner_sys_t *p_owner = p_dec->p_owner;
@@ -1951,7 +1969,7 @@ static void DecoderFlush( decoder_t *p_dec )
/**
* Requests that the decoder immediately discard all pending buffers.
- * This is useful at end of stream, when seeking or when deselecting a stream.
+ * This is useful when seeking or when deselecting a stream.
*/
void input_DecoderFlush( decoder_t *p_dec )
{
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 3cc89b5..1b39c0e 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -177,6 +177,7 @@ input_CreateFilename
input_DecoderCreate
input_DecoderDelete
input_DecoderDecode
+input_DecoderDrain
input_DecoderFlush
input_GetItem
input_item_AddInfo
More information about the vlc-commits
mailing list