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

Steve Lhomme robux4 at ycbcr.xyz
Mon Sep 2 16:20:18 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 | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 24061a6618..45cc4e3024 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1033,7 +1033,10 @@ static int DecoderPlayVideo_internal( struct decoder_owner *p_owner, picture_t *
 
     /* */
     if( p_vout == NULL )
-        goto discard;
+    {
+        picture_Release( p_picture );
+        return VLC_EGENERIC;
+    }
 
     if( p_picture->b_still )
     {
@@ -1043,9 +1046,6 @@ static int DecoderPlayVideo_internal( struct decoder_owner *p_owner, picture_t *
     vout_PutPicture( p_vout, p_picture );
 
     return VLC_SUCCESS;
-discard:
-    picture_Release( p_picture );
-    return VLC_EGENERIC;
 }
 
 static void DecoderUpdateStatVideo( struct decoder_owner *p_owner,
@@ -1147,27 +1147,27 @@ static int DecoderPlayAudio_internal( struct decoder_owner *p_owner, block_t *p_
     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_internal( 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_SUCCESS;
+        msg_Dbg( p_dec, "discarded audio buffer" );
+        block_Release( p_audio );
+        return VLC_EGENERIC;
     }
 
-    msg_Dbg( p_dec, "discarded audio buffer" );
-    block_Release( p_audio );
-    return VLC_EGENERIC;
+    int status = aout_DecPlay( p_aout, p_audio );
+    if( status == AOUT_DEC_CHANGED )
+    {
+        /* Only reload the decoder */
+        RequestReload_internal( 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_SUCCESS;
 }
 
 static void DecoderUpdateStatAudio( struct decoder_owner *p_owner,
-- 
2.17.1



More information about the vlc-devel mailing list