stream_output: add sout_InputFlush()
authorSteve Lhomme <robux4@videolabs.io>
Fri, 18 Dec 2015 09:39:38 +0000 (10:39 +0100)
committerThomas Guillem <thomas@gllm.fr>
Tue, 22 Dec 2015 13:39:44 +0000 (14:39 +0100)
when seeking during stream output we need to be able to flush internal buffers

Signed-off-by: Thomas Guillem <thomas@gllm.fr>
include/vlc_sout.h
src/input/decoder.c
src/stream_output/stream_output.c
src/stream_output/stream_output.h

index 8147131..0569e28 100644 (file)
@@ -210,6 +210,7 @@ struct sout_stream_t
     /* manage a packet */
     int               (*pf_send)( sout_stream_t *, sout_stream_id_sys_t *, block_t* );
     int               (*pf_control)( sout_stream_t *, int, va_list );
+    void              (*pf_flush)( sout_stream_t *, sout_stream_id_sys_t * );
 
     sout_stream_sys_t *p_sys;
     bool pace_nocontrol;
@@ -237,6 +238,13 @@ static inline int sout_StreamIdSend( sout_stream_t *s,
     return s->pf_send( s, id, b );
 }
 
+static inline void sout_StreamFlush( sout_stream_t *s,
+                                     sout_stream_id_sys_t *id )
+{
+    if (s->pf_flush)
+        s->pf_flush( s, id );
+}
+
 static inline int sout_StreamControl( sout_stream_t *s, int i_query, ... )
 {
     va_list args;
index 12f97a5..5be414d 100644 (file)
@@ -1389,6 +1389,12 @@ static void DecoderProcessFlush( decoder_t *p_dec )
     if ( p_dec->pf_flush != NULL )
         p_dec->pf_flush( p_dec );
 
+#ifdef ENABLE_SOUT
+    if ( p_owner->p_sout_input != NULL )
+    {
+        sout_InputFlush( p_owner->p_sout_input );
+    }
+#endif
     if( p_dec->fmt_out.i_cat == AUDIO_ES )
     {
         if( p_owner->p_aout )
index cf8c94f..c20f3f1 100644 (file)
@@ -223,6 +223,15 @@ bool sout_InputIsEmpty( sout_packetizer_input_t *p_input )
     return b;
 }
 
+void sout_InputFlush( sout_packetizer_input_t *p_input )
+{
+    sout_instance_t     *p_sout = p_input->p_sout;
+
+    vlc_mutex_lock( &p_sout->lock );
+    sout_StreamFlush( p_sout->p_stream, p_input->id );
+    vlc_mutex_unlock( &p_sout->lock );
+}
+
 /*****************************************************************************
  *
  *****************************************************************************/
@@ -789,6 +798,7 @@ static sout_stream_t *sout_StreamNew( sout_instance_t *p_sout, char *psz_name,
     p_stream->psz_name = psz_name;
     p_stream->p_cfg    = p_cfg;
     p_stream->p_next   = p_next;
+    p_stream->pf_flush = NULL;
     p_stream->pf_control = NULL;
     p_stream->pace_nocontrol = false;
     p_stream->p_sys = NULL;
index 1429584..f1e0fd7 100644 (file)
@@ -50,5 +50,6 @@ sout_packetizer_input_t *sout_InputNew( sout_instance_t *, es_format_t * );
 int sout_InputDelete( sout_packetizer_input_t * );
 int sout_InputSendBuffer( sout_packetizer_input_t *, block_t* );
 bool sout_InputIsEmpty(sout_packetizer_input_t *);
+void sout_InputFlush( sout_packetizer_input_t * );
 
 #endif