[vlc-devel] [PATCH 7/8] sout_mux/avformat: handle drain by draining the sout_access

Thomas Guillem thomas at gllm.fr
Mon Jan 29 18:25:55 CET 2018


---
 modules/demux/avformat/mux.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 9500c915b4..b6676bd1f7 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -168,11 +168,6 @@ void avformat_CloseMux( vlc_object_t *p_this )
     sout_mux_t *p_mux = (sout_mux_t*)p_this;
     sout_mux_sys_t *p_sys = p_mux->p_sys;
 
-    if( !p_sys->b_write_header && !p_sys->b_error && av_write_trailer( p_sys->oc ) < 0 )
-    {
-        msg_Err( p_mux, "could not write trailer" );
-    }
-
     avformat_free_context(p_sys->oc);
     av_free(p_sys->io);
 
@@ -329,8 +324,19 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
  *****************************************************************************/
 static void DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
 {
-    msg_Dbg( p_mux, "removing input" );
+    sout_mux_sys_t *p_sys = p_mux->p_sys;
+
     free( p_input->p_sys );
+    if( sout_MuxIsDrained( p_mux ) )
+    {
+        if( !p_sys->b_write_header && !p_sys->b_error && av_write_trailer( p_sys->oc ) < 0 )
+        {
+            msg_Err( p_mux, "could not write trailer" );
+        }
+
+        /* Drain */
+        sout_AccessOutWrite( p_mux->p_access, NULL );
+    }
 }
 
 static int MuxBlock( sout_mux_t *p_mux, sout_input_t *p_input )
-- 
2.11.0



More information about the vlc-devel mailing list