[vlc-commits] gather: use vlc_list

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


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

gather: use vlc_list

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

 modules/stream_out/gather.c | 33 ++++++++++-----------------------
 1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/modules/stream_out/gather.c b/modules/stream_out/gather.c
index 1ea3776803..15264730c5 100644
--- a/modules/stream_out/gather.c
+++ b/modules/stream_out/gather.c
@@ -32,6 +32,7 @@
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_block.h>
+#include <vlc_list.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -60,12 +61,12 @@ typedef struct
 
     es_format_t fmt;
     void          *id;
+    struct vlc_list node;
 } sout_stream_id_sys_t;
 
 typedef struct
 {
-    int              i_id;
-    sout_stream_id_sys_t **id;
+    struct vlc_list ids;
 } sout_stream_sys_t;
 
 static const struct sout_stream_operations ops = {
@@ -84,10 +85,8 @@ static int Open( vlc_object_t *p_this )
     if( p_sys == NULL )
         return VLC_EGENERIC;
 
+    vlc_list_init(&p_sys->ids);
     p_stream->ops = &ops;
-
-    TAB_INIT( p_sys->i_id, p_sys->id );
-
     return VLC_SUCCESS;
 }
 
@@ -98,17 +97,14 @@ static void Close( vlc_object_t * p_this )
 {
     sout_stream_t     *p_stream = (sout_stream_t*)p_this;
     sout_stream_sys_t *p_sys = p_stream->p_sys;
-    int i;
+    sout_stream_id_sys_t *id;
 
-    for( i = 0; i < p_sys->i_id; i++ )
+    vlc_list_foreach (id, &p_sys->ids, node)
     {
-        sout_stream_id_sys_t *id = p_sys->id[i];
-
         sout_StreamIdDel( p_stream->p_next, id->id );
         es_format_Clean( &id->fmt );
         free( id );
     }
-    TAB_CLEAN( p_sys->i_id, p_sys->id );
 
     free( p_sys );
 }
@@ -119,13 +115,11 @@ static void Close( vlc_object_t * p_this )
 static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
-    sout_stream_id_sys_t  *id;
-    int i;
+    sout_stream_id_sys_t *id;
 
     /* search a compatible output */
-    for( i = 0; i < p_sys->i_id; i++ )
+    vlc_list_foreach (id, &p_sys->ids, node)
     {
-        id = p_sys->id[i];
         if( id->b_used )
             continue;
 
@@ -156,20 +150,13 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
     }
 
     /* destroy all outputs from the same category */
-    for( i = 0; i < p_sys->i_id; i++ )
-    {
-        id = p_sys->id[i];
+    vlc_list_foreach (id, &p_sys->ids, node)
         if( !id->b_used && id->fmt.i_cat == p_fmt->i_cat )
         {
-            TAB_REMOVE( p_sys->i_id, p_sys->id, id );
             sout_StreamIdDel( p_stream->p_next, id->id );
             es_format_Clean( &id->fmt );
             free( id );
-
-            i = 0;
-            continue;
         }
-    }
 
     msg_Dbg( p_stream, "creating new output" );
     id = malloc( sizeof( sout_stream_id_sys_t ) );
@@ -184,8 +171,8 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
         free( id );
         return NULL;
     }
-    TAB_APPEND( p_sys->i_id, p_sys->id, id );
 
+    vlc_list_append(&id->node, &p_sys->ids);
     return id;
 }
 



More information about the vlc-commits mailing list