[vlc-commits] duplicate: simplify select= handling

Rémi Denis-Courmont git at videolan.org
Sun Oct 11 21:23:27 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Oct 11 22:21:21 2020 +0300| [bc4fafb713c8d1636ebea6dc0c9002aca35b2429] | committer: Rémi Denis-Courmont

duplicate: simplify select= handling

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bc4fafb713c8d1636ebea6dc0c9002aca35b2429
---

 modules/stream_out/duplicate.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules/stream_out/duplicate.c b/modules/stream_out/duplicate.c
index 21fbbfbe1f..63e186ee35 100644
--- a/modules/stream_out/duplicate.c
+++ b/modules/stream_out/duplicate.c
@@ -131,6 +131,8 @@ static int Open( vlc_object_t *p_this )
     TAB_INIT( p_sys->i_nb_last_streams, p_sys->pp_last_streams );
     TAB_INIT( p_sys->i_nb_select, p_sys->ppsz_select );
 
+    char **ppsz_select = NULL;
+
     for( p_cfg = p_stream->p_cfg; p_cfg != NULL; p_cfg = p_cfg->p_next )
     {
         if( !strncmp( p_cfg->psz_name, "dst", strlen( "dst" ) ) )
@@ -147,24 +149,24 @@ static int Open( vlc_object_t *p_this )
                 TAB_APPEND( p_sys->i_nb_last_streams, p_sys->pp_last_streams,
                     p_last );
                 TAB_APPEND( p_sys->i_nb_select,  p_sys->ppsz_select, NULL );
+                ppsz_select = &p_sys->ppsz_select[p_sys->i_nb_select - 1];
             }
         }
         else if( !strncmp( p_cfg->psz_name, "select", strlen( "select" ) ) )
         {
             char *psz = p_cfg->psz_value;
-            if( p_sys->i_nb_select > 0 && psz && *psz )
-            {
-                char **ppsz_select = &p_sys->ppsz_select[p_sys->i_nb_select - 1];
 
-                if( *ppsz_select )
+            if( psz && *psz )
+            {
+                if( ppsz_select == NULL )
                 {
-                    msg_Err( p_stream, " * ignore selection `%s' (it already has `%s')",
-                             psz, *ppsz_select );
+                    msg_Err( p_stream, " * ignore selection `%s'", psz );
                 }
                 else
                 {
                     msg_Dbg( p_stream, " * apply selection `%s'", psz );
                     *ppsz_select = strdup( psz );
+                    ppsz_select = NULL;
                 }
             }
         }



More information about the vlc-commits mailing list