[vlc-commits] decoder: remove BLOCK_FLAG_CORE_EOS
Rémi Denis-Courmont
git at videolan.org
Sat Mar 21 19:56:36 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 21 20:06:26 2015 +0200| [ea86f2792a3ede61b5794c9e70233e135c82b62b] | committer: Rémi Denis-Courmont
decoder: remove BLOCK_FLAG_CORE_EOS
Do not rely on allocating a block for draining the decoder and output.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ea86f2792a3ede61b5794c9e70233e135c82b62b
---
src/input/decoder.c | 42 +++++++++++++++++++++++-------------------
src/input/decoder.h | 1 -
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index fdf8b18..476b190 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -112,6 +112,7 @@ struct decoder_owner_sys_t
/* Flushing */
bool b_flushing;
+ bool b_draining;
/* CC */
struct
@@ -1426,14 +1427,23 @@ static void *DecoderThread( void *p_data )
for( ;; )
{
block_t *p_block;
+ bool draining = false;
vlc_fifo_Lock( p_owner->p_fifo );
vlc_fifo_CleanupPush( p_owner->p_fifo );
while( vlc_fifo_IsEmpty( p_owner->p_fifo ) )
{
- if( p_owner->b_woken )
+ if( p_owner->b_draining )
+ { /* We have emptied the FIFO and there is a pending request to
+ * drain. Pass p_block = NULL to decoder just once. */
+ p_owner->b_draining = false;
+ draining = true;
break;
+ }
+ if( p_owner->b_woken )
+ break;
+
vlc_fifo_Wait( p_owner->p_fifo );
/* Make sure there is no cancellation point other than this one^^.
* If you need one, be sure to push cleanup of p_block. */
@@ -1446,23 +1456,13 @@ static void *DecoderThread( void *p_data )
p_owner->b_woken = false;
vlc_cleanup_run();
- if( p_block == NULL || p_block->i_flags & BLOCK_FLAG_CORE_EOS )
+ if( p_block == NULL )
DecoderSignalWait( p_dec );
- if( p_block )
+ if( p_block != NULL || draining )
{
int canc = vlc_savecancel();
-
- if( p_block->i_flags & BLOCK_FLAG_CORE_EOS )
- {
- /* calling DecoderProcess() with NULL block will make
- * decoders/packetizers flush their buffers */
- block_Release( p_block );
- p_block = NULL;
- }
-
DecoderProcess( p_dec, p_block );
-
vlc_restorecancel( canc );
}
}
@@ -1616,6 +1616,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
p_owner->b_has_data = false;
p_owner->b_flushing = false;
+ p_owner->b_draining = false;
/* */
p_owner->cc.b_supported = false;
@@ -1920,12 +1921,12 @@ bool input_DecoderIsEmpty( decoder_t * p_dec )
*/
void input_DecoderDrain( decoder_t *p_dec )
{
- block_t *p_block = block_Alloc(0);
- if( unlikely(p_block == NULL) )
- return;
+ decoder_owner_sys_t *p_owner = p_dec->p_owner;
- p_block->i_flags |= BLOCK_FLAG_CORE_EOS;
- input_DecoderDecode( p_dec, p_block, false );
+ vlc_fifo_Lock( p_owner->p_fifo );
+ p_owner->b_draining = true;
+ vlc_fifo_Signal( p_owner->p_fifo );
+ vlc_fifo_Unlock( p_owner->p_fifo );
}
static void DecoderFlush( decoder_t *p_dec )
@@ -1934,8 +1935,11 @@ static void DecoderFlush( decoder_t *p_dec )
vlc_assert_locked( &p_owner->lock );
+ vlc_fifo_Lock( p_owner->p_fifo );
/* Empty the fifo */
- block_FifoEmpty( p_owner->p_fifo );
+ block_ChainRelease( vlc_fifo_DequeueAllUnlocked( p_owner->p_fifo ) );
+ p_owner->b_draining = false; /* flush supersedes drain */
+ vlc_fifo_Unlock( p_owner->p_fifo );
/* Monitor for flush end */
p_owner->b_flushing = true;
diff --git a/src/input/decoder.h b/src/input/decoder.h
index bc3499b..8508874 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -29,7 +29,6 @@
#include <vlc_codec.h>
#define BLOCK_FLAG_CORE_FLUSH (1 <<BLOCK_FLAG_CORE_PRIVATE_SHIFT)
-#define BLOCK_FLAG_CORE_EOS (1 <<(BLOCK_FLAG_CORE_PRIVATE_SHIFT + 1))
decoder_t *input_DecoderNew( input_thread_t *, es_format_t *, input_clock_t *,
sout_instance_t * ) VLC_USED;
More information about the vlc-commits
mailing list