[vlc-devel] [RFC PATCH 1/8] decoder: don't notify record decoders

Thomas Guillem thomas at gllm.fr
Thu Apr 21 18:24:31 CEST 2016


---
 src/input/decoder.c | 33 +++++++++++++++++++--------------
 src/input/decoder.h |  2 +-
 src/input/es_out.c  | 10 +++++++---
 3 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index a881a06..51a8f90 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -68,6 +68,8 @@ struct decoder_owner_sys_t
     sout_instance_t         *p_sout;
     sout_packetizer_input_t *p_sout_input;
 
+    bool                     b_notify_input;
+
     vlc_thread_t     thread;
 
     /* Some decoders require already packetized data (ie. not truncated) */
@@ -219,12 +221,11 @@ static vout_thread_t *aout_request_vout( void *p_private,
 {
     decoder_t *p_dec = p_private;
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
-    input_thread_t *p_input = p_owner->p_input;
 
     p_vout = input_resource_RequestVout( p_owner->p_resource, p_vout, p_fmt, 1,
                                          b_recyle );
-    if( p_input != NULL )
-        input_SendEventVout( p_input );
+    if( p_owner->b_notify_input )
+        input_SendEventVout( p_owner->p_input );
 
     return p_vout;
 }
@@ -296,7 +297,7 @@ static int aout_update_format( decoder_t *p_dec )
         aout_FormatPrepare( &p_owner->fmt.audio );
         vlc_mutex_unlock( &p_owner->lock );
 
-        if( p_owner->p_input != NULL )
+        if( p_owner->b_notify_input )
             input_SendEventAout( p_owner->p_input );
 
         if( p_aout == NULL )
@@ -432,7 +433,7 @@ static int vout_update_format( decoder_t *p_dec )
         p_owner->fmt.video.i_chroma = p_dec->fmt_out.i_codec;
         vlc_mutex_unlock( &p_owner->lock );
 
-        if( p_owner->p_input != NULL )
+        if( p_owner->b_notify_input )
             input_SendEventVout( p_owner->p_input );
         if( p_vout == NULL )
         {
@@ -1534,7 +1535,8 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
                                   input_thread_t *p_input,
                                   const es_format_t *fmt,
                                   input_resource_t *p_resource,
-                                  sout_instance_t *p_sout )
+                                  sout_instance_t *p_sout,
+                                  bool b_notify_input )
 {
     decoder_t *p_dec;
     decoder_owner_sys_t *p_owner;
@@ -1562,6 +1564,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     p_owner->p_sout = p_sout;
     p_owner->p_sout_input = NULL;
     p_owner->p_packetizer = NULL;
+    p_owner->b_notify_input = b_notify_input && p_input != NULL;
 
     p_owner->b_fmt_description = false;
     p_owner->p_description = NULL;
@@ -1697,7 +1700,7 @@ static void DeleteDecoder( decoder_t * p_dec )
         aout_DecFlush( p_owner->p_aout, false );
         aout_DecDelete( p_owner->p_aout );
         input_resource_PutAout( p_owner->p_resource, p_owner->p_aout );
-        if( p_owner->p_input != NULL )
+        if( p_owner->b_notify_input )
             input_SendEventAout( p_owner->p_input );
     }
     if( p_owner->p_vout )
@@ -1709,7 +1712,7 @@ static void DeleteDecoder( decoder_t * p_dec )
         /* */
         input_resource_RequestVout( p_owner->p_resource, p_owner->p_vout, NULL,
                                     0, true );
-        if( p_owner->p_input != NULL )
+        if( p_owner->b_notify_input )
             input_SendEventVout( p_owner->p_input );
     }
 
@@ -1774,14 +1777,16 @@ static void DecoderUnsupportedCodec( decoder_t *p_dec, const es_format_t *fmt )
 static decoder_t *decoder_New( vlc_object_t *p_parent, input_thread_t *p_input,
                                const es_format_t *fmt, input_clock_t *p_clock,
                                input_resource_t *p_resource,
-                               sout_instance_t *p_sout  )
+                               sout_instance_t *p_sout,
+                               bool b_notify_input )
 {
     decoder_t *p_dec = NULL;
     const char *psz_type = p_sout ? N_("packetizer") : N_("decoder");
     int i_priority;
 
     /* Create the decoder configuration structure */
-    p_dec = CreateDecoder( p_parent, p_input, fmt, p_resource, p_sout );
+    p_dec = CreateDecoder( p_parent, p_input, fmt, p_resource, p_sout,
+                           b_notify_input );
     if( p_dec == NULL )
     {
         msg_Err( p_parent, "could not create %s", psz_type );
@@ -1827,10 +1832,10 @@ static decoder_t *decoder_New( vlc_object_t *p_parent, input_thread_t *p_input,
  */
 decoder_t *input_DecoderNew( input_thread_t *p_input,
                              es_format_t *fmt, input_clock_t *p_clock,
-                             sout_instance_t *p_sout  )
+                             sout_instance_t *p_sout, bool b_notify_input )
 {
     return decoder_New( VLC_OBJECT(p_input), p_input, fmt, p_clock,
-                        p_input->p->p_resource, p_sout );
+                        p_input->p->p_resource, p_sout, b_notify_input );
 }
 
 /**
@@ -1839,7 +1844,7 @@ decoder_t *input_DecoderNew( input_thread_t *p_input,
 decoder_t *input_DecoderCreate( vlc_object_t *p_parent, const es_format_t *fmt,
                                 input_resource_t *p_resource )
 {
-    return decoder_New( p_parent, NULL, fmt, NULL, p_resource, NULL );
+    return decoder_New( p_parent, NULL, fmt, NULL, p_resource, NULL, false );
 }
 
 
@@ -2039,7 +2044,7 @@ int input_DecoderSetCcState( decoder_t *p_dec, bool b_decode, int i_channel )
 
         es_format_Init( &fmt, SPU_ES, fcc[i_channel] );
         p_cc = input_DecoderNew( p_owner->p_input, &fmt,
-                              p_dec->p_owner->p_clock, p_owner->p_sout );
+                                 p_dec->p_owner->p_clock, p_owner->p_sout, false );
         if( !p_cc )
         {
             msg_Err( p_dec, "could not create decoder" );
diff --git a/src/input/decoder.h b/src/input/decoder.h
index 226ecde..1cf06c3 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -29,7 +29,7 @@
 #include <vlc_codec.h>
 
 decoder_t *input_DecoderNew( input_thread_t *, es_format_t *, input_clock_t *,
-                             sout_instance_t * ) VLC_USED;
+                             sout_instance_t *, bool b_notify_input ) VLC_USED;
 
 /**
  * This function changes the pause state.
diff --git a/src/input/es_out.c b/src/input/es_out.c
index bd01c3e..7c08a5a 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -493,7 +493,8 @@ static int EsOutSetRecord(  es_out_t *out, bool b_record )
             if( !p_es->p_dec || p_es->p_master )
                 continue;
 
-            p_es->p_dec_record = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_sys->p_sout_record );
+            p_es->p_dec_record = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_sys->p_sout_record,
+                                                   false );
             if( p_es->p_dec_record && p_sys->b_buffering )
                 input_DecoderStartWait( p_es->p_dec_record );
         }
@@ -1561,12 +1562,14 @@ static bool EsIsSelected( es_out_id_t *es )
         return es->p_dec != NULL;
     }
 }
+
 static void EsCreateDecoder( es_out_t *out, es_out_id_t *p_es )
 {
     es_out_sys_t   *p_sys = out->p_sys;
     input_thread_t *p_input = p_sys->p_input;
 
-    p_es->p_dec = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_input->p->p_sout );
+    p_es->p_dec = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_input->p->p_sout,
+                                    true );
     if( p_es->p_dec )
     {
         if( p_sys->b_buffering )
@@ -1574,7 +1577,8 @@ static void EsCreateDecoder( es_out_t *out, es_out_id_t *p_es )
 
         if( !p_es->p_master && p_sys->p_sout_record )
         {
-            p_es->p_dec_record = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_sys->p_sout_record );
+            p_es->p_dec_record = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_sys->p_sout_record,
+                                                   false );
             if( p_es->p_dec_record && p_sys->b_buffering )
                 input_DecoderStartWait( p_es->p_dec_record );
         }
-- 
2.8.0.rc3



More information about the vlc-devel mailing list