[vlc-devel] [PATCH 10/11] decoder: simplify code

Steve Lhomme robux4 at ycbcr.xyz
Fri Aug 30 07:55:47 CEST 2019


No need for a label to jump to if it's only used at one location.

And reorder DecoderPlayAudio() to match the same logic as the Video one.
---
 src/input/decoder.c | 50 ++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index f3b74f592f..6dafc8e0e2 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1032,7 +1032,10 @@ static int DecoderPlayVideo( struct decoder_owner *p_owner, picture_t *p_picture
 
     /* */
     if( p_vout == NULL )
-        goto discard;
+    {
+        picture_Release( p_picture );
+        return VLC_SUCCESS;
+    }
 
     if( p_picture->b_force || p_picture->date != VLC_TICK_INVALID )
         /* FIXME: VLC_TICK_INVALID -- verify video_output */
@@ -1043,15 +1046,10 @@ static int DecoderPlayVideo( struct decoder_owner *p_owner, picture_t *p_picture
             vout_Flush( p_vout, p_picture->date );
         }
         vout_PutPicture( p_vout, p_picture );
-    }
-    else
-    {
-        msg_Warn( p_dec, "early picture skipped" );
-        goto discard;
+        return VLC_SUCCESS;
     }
 
-    return VLC_SUCCESS;
-discard:
+    msg_Warn( p_dec, "early picture skipped" );
     picture_Release( p_picture );
     return VLC_EGENERIC;
 }
@@ -1155,27 +1153,27 @@ static int DecoderPlayAudio( struct decoder_owner *p_owner, block_t *p_audio )
     audio_output_t *p_aout = p_owner->p_aout;
     vlc_mutex_unlock( &p_owner->lock );
 
-    if( p_aout != NULL )
+    if( p_aout == NULL )
     {
-        int status = aout_DecPlay( p_aout, p_audio );
-        if( status == AOUT_DEC_CHANGED )
-        {
-            /* Only reload the decoder */
-            RequestReload( p_owner );
-        }
-        else if( status == AOUT_DEC_FAILED )
-        {
-            /* If we reload because the aout failed, we should release it. That
-             * way, a next call to aout_update_format() won't re-use the
-             * previous (failing) aout but will try to create a new one. */
-            atomic_store( &p_owner->reload, RELOAD_DECODER_AOUT );
-        }
-        return VLC_EGENERIC;
+        msg_Dbg( p_dec, "discarded audio buffer" );
+        block_Release( p_audio );
+        return VLC_SUCCESS;
     }
 
-    msg_Dbg( p_dec, "discarded audio buffer" );
-    block_Release( p_audio );
-    return VLC_SUCCESS;
+    int status = aout_DecPlay( p_aout, p_audio );
+    if( status == AOUT_DEC_CHANGED )
+    {
+        /* Only reload the decoder */
+        RequestReload( p_owner );
+    }
+    else if( status == AOUT_DEC_FAILED )
+    {
+        /* If we reload because the aout failed, we should release it. That
+            * way, a next call to aout_update_format() won't re-use the
+            * previous (failing) aout but will try to create a new one. */
+        atomic_store( &p_owner->reload, RELOAD_DECODER_AOUT );
+    }
+    return VLC_EGENERIC;
 }
 
 static void DecoderUpdateStatAudio( struct decoder_owner *p_owner,
-- 
2.17.1



More information about the vlc-devel mailing list