[vlc-devel] [RFC-PATCH 09/12] core: refactored prerolling related to audio

Filip Roséen filip at videolabs.io
Wed May 11 18:56:54 CEST 2016


See previous commit named "core: refactored prerolling related to video".
---
 src/input/decoder.c | 56 ++++++++++++++++++++++++++---------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 4fa81d0..0169c91 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1058,30 +1058,9 @@ static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
                              unsigned *restrict pi_lost_sum )
 {
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
-    bool prerolled;
 
     assert( p_audio != NULL );
 
-    vlc_mutex_lock( &p_owner->lock );
-    if( p_owner->i_preroll_end > p_audio->i_pts )
-    {
-        vlc_mutex_unlock( &p_owner->lock );
-        block_Release( p_audio );
-        return -1;
-    }
-
-    prerolled = p_owner->i_preroll_end > INT64_MIN;
-    p_owner->i_preroll_end = INT64_MIN;
-    vlc_mutex_unlock( &p_owner->lock );
-
-    if( unlikely(prerolled) )
-    {
-        msg_Dbg( p_dec, "end of audio preroll" );
-
-        if( p_owner->p_aout )
-            aout_DecFlush( p_owner->p_aout, false );
-    }
-
     /* */
     if( p_audio->i_pts <= VLC_TS_INVALID ) // FIXME --VLC_TS_INVALID verify audio_output/*
     {
@@ -1162,20 +1141,41 @@ static int DecoderQueueAudio( decoder_t *p_dec, block_t *p_aout_buf )
     return ret;
 }
 
+static void DecoderPrerolledAudio( decoder_t * p_dec )
+{
+    audio_output_t * p_aout = p_dec->p_owner->p_aout;
+
+    msg_Dbg( p_dec, "end of audio preroll" );
+
+    if( p_aout )
+        aout_DecFlush( p_aout, false );
+}
+
 static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
 {
-    block_t *p_aout_buf;
-    block_t **pp_block = p_block ? &p_block : NULL;
-    unsigned decoded = 0, lost = 0;
+    unsigned i_decoded = 0;
+    unsigned i_lost = 0;
 
-    while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, pp_block ) ) )
+    for( ;; )
     {
-        decoded++;
+        uint32_t  i_flags = ( p_block ? p_block->i_flags : 0 );
+        block_t * p_audio = p_dec->pf_decode_audio( p_dec, &p_block );
+
+        if( !p_audio )
+            break;
+
+        ++i_decoded;
+
+        if( DecoderPrerollBlock( p_dec, i_flags, p_audio->i_pts, p_audio->i_pts + p_audio->i_length, &DecoderPrerolledAudio ) )
+        {
+            block_Release( p_audio );
+            continue;
+        }
 
-        DecoderPlayAudio( p_dec, p_aout_buf, &lost );
+        DecoderPlayAudio( p_dec, p_audio, &i_lost );
     }
 
-    DecoderUpdateStatAudio( p_dec, decoded, lost );
+    DecoderUpdateStatAudio( p_dec, i_decoded, i_lost );
 }
 
 /* This function process a audio block
-- 
2.8.2



More information about the vlc-devel mailing list