[vlc-commits] decoder: avoid block_FifoWake()
Rémi Denis-Courmont
git at videolan.org
Thu Mar 19 18:56:15 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Mar 17 20:19:04 2015 +0200| [cb925bf2a0d3c10f739ee6afac7892d0e2bb62b1] | committer: Rémi Denis-Courmont
decoder: avoid block_FifoWake()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cb925bf2a0d3c10f739ee6afac7892d0e2bb62b1
---
src/input/decoder.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 8e565b3..b14da25 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -125,6 +125,7 @@ struct decoder_owner_sys_t
} pause;
/* Waiting */
+ bool b_woken;
bool b_waiting;
bool b_first;
bool b_has_data;
@@ -545,7 +546,10 @@ void input_DecoderWait( decoder_t *p_dec )
vlc_mutex_lock( &p_owner->lock );
while( !p_owner->b_has_data )
{
- block_FifoWake( p_owner->p_fifo );
+ vlc_fifo_Lock( p_owner->p_fifo );
+ p_owner->b_woken = true;
+ vlc_fifo_Signal( p_owner->p_fifo );
+ vlc_fifo_Unlock( p_owner->p_fifo );
vlc_cond_wait( &p_owner->wait_acknowledge, &p_owner->lock );
}
vlc_mutex_unlock( &p_owner->lock );
@@ -744,6 +748,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
es_format_Init( &p_owner->fmt, UNKNOWN_ES, 0 );
/* decoder fifo */
+ p_owner->b_woken = false;
p_owner->p_fifo = block_FifoNew();
if( unlikely(p_owner->p_fifo == NULL) )
{
@@ -865,10 +870,24 @@ static void *DecoderThread( void *p_data )
/* The decoder's main loop */
for( ;; )
{
- block_t *p_block = block_FifoGet( p_owner->p_fifo );
+ block_t *p_block;
+
+ 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 )
+ 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. */
+ }
+
+ p_block = vlc_fifo_DequeueUnlocked( p_owner->p_fifo );
+ p_owner->b_woken = false;
+ vlc_cleanup_run();
- /* Make sure there is no cancellation point other than this one^^.
- * If you need one, be sure to push cleanup of p_block. */
bool end_wait = !p_block || p_block->i_flags & BLOCK_FLAG_CORE_EOS;
DecoderSignalWait( p_dec, end_wait );
More information about the vlc-commits
mailing list