[vlc-devel] [PATCH 4/5] sout/es: update pace control in stream object

RĂ©mi Denis-Courmont remi at remlab.net
Sun Mar 1 13:11:58 CET 2020


...instead of wildly directly into the sout instance.

This now works because the previous patch handles it properly.
---
 modules/stream_out/es.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/modules/stream_out/es.c b/modules/stream_out/es.c
index 03d1f671e1..54aac70d1c 100644
--- a/modules/stream_out/es.c
+++ b/modules/stream_out/es.c
@@ -28,6 +28,7 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
@@ -127,6 +128,7 @@ typedef struct
     int  i_count_audio;
     int  i_count_video;
     int  i_count;
+    unsigned pace_nocontrol;
 
     char *psz_mux;
     char *psz_mux_audio;
@@ -155,6 +157,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_count          = 0;
     p_sys->i_count_audio    = 0;
     p_sys->i_count_video    = 0;
+    p_sys->pace_nocontrol   = 0;
 
     p_sys->psz_access = var_GetString( p_stream, SOUT_CFG_PREFIX "access" );
     p_sys->psz_access_audio = var_GetString( p_stream, SOUT_CFG_PREFIX "access-audio" );
@@ -186,6 +189,8 @@ 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;
 
+    assert( p_sys->pace_nocontrol == 0 );
+
     free( p_sys->psz_access );
     free( p_sys->psz_access_audio );
     free( p_sys->psz_access_video );
@@ -387,21 +392,28 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
     }
 
     if( !pace_control )
-        p_stream->p_sout->i_out_pace_nocontrol++;
+    {
+        p_sys->pace_nocontrol++;
+        p_stream->pace_nocontrol = true;
+    }
 
     return id;
 }
 
 static void Del( sout_stream_t *p_stream, void *_id )
 {
-    VLC_UNUSED(p_stream);
+    sout_stream_sys_t *sys = p_stream->p_sys;
     sout_stream_id_sys_t *id = (sout_stream_id_sys_t *)_id;
     sout_access_out_t *p_access = id->p_mux->p_access;
 
     sout_MuxDeleteStream( id->p_mux, id->p_input );
     sout_MuxDelete( id->p_mux );
     if( !sout_AccessOutCanControlPace( p_access ) )
-        p_stream->p_sout->i_out_pace_nocontrol--;
+    {
+        assert( sys->pace_nocontrol > 0 );
+        sys->pace_nocontrol--;
+        p_stream->pace_nocontrol = sys->pace_nocontrol > 0;
+    }
     sout_AccessOutDelete( p_access );
 
     free( id );
-- 
2.20.1



More information about the vlc-devel mailing list