[vlc-commits] input: deduplicate code

Rémi Denis-Courmont git at videolan.org
Mon Sep 22 23:52:11 CEST 2014


vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Aug 15 20:16:58 2014 +0300| [1d1bf7886bb1837579675e259b74c26752d05f04] | committer: Jean-Baptiste Kempf

input: deduplicate code

(cherry picked from commit 04a366e3e6d83495c76452c9fdc2bb6e2c869b77)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=1d1bf7886bb1837579675e259b74c26752d05f04
---

 src/input/input.c |   34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 03c9dcf..8affd94 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -93,7 +93,7 @@ static void SlaveDemux( input_thread_t *p_input, bool *pb_demux_polled );
 static void SlaveSeek( input_thread_t *p_input );
 
 static void InputMetaUser( input_thread_t *p_input, vlc_meta_t *p_meta );
-static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta );
+static void InputUpdateMeta( input_thread_t *p_input, demux_t *p_demux );
 static void InputGetExtraFiles( input_thread_t *p_input,
                                 int *pi_list, char ***pppsz_list,
                                 const char *psz_access, const char *psz_path );
@@ -1961,7 +1961,6 @@ static bool Control( input_thread_t *p_input,
 
                 if( slave && !InputSourceInit( p_input, slave, uri, NULL, false ) )
                 {
-                    vlc_meta_t *p_meta;
                     int64_t i_time;
 
                     /* Add the slave */
@@ -1986,12 +1985,7 @@ static bool Control( input_thread_t *p_input,
                     }
 
                     /* Get meta (access and demux) */
-                    p_meta = vlc_meta_New();
-                    if( p_meta )
-                    {
-                        demux_Control( slave->p_demux, DEMUX_GET_META, p_meta );
-                        InputUpdateMeta( p_input, p_meta );
-                    }
+                    InputUpdateMeta( p_input, slave->p_demux );
 
                     TAB_APPEND( p_input->p->i_slave, p_input->p->slave, slave );
                 }
@@ -2147,12 +2141,7 @@ static void UpdateGenericFromDemux( input_thread_t *p_input )
 
     if( p_demux->info.i_update & INPUT_UPDATE_META )
     {
-        vlc_meta_t *p_meta = vlc_meta_New();
-        if( p_meta )
-        {
-            demux_Control( p_input->p->input.p_demux, DEMUX_GET_META, p_meta );
-            InputUpdateMeta( p_input, p_meta );
-        }
+        InputUpdateMeta( p_input, p_demux );
         p_demux->info.i_update &= ~INPUT_UPDATE_META;
     }
     {
@@ -2723,15 +2712,21 @@ static void AppendAttachment( int *pi_attachment, input_attachment_t ***ppp_atta
  * InputUpdateMeta: merge p_item meta data with p_meta taking care of
  * arturl and locking issue.
  *****************************************************************************/
-static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
+static void InputUpdateMeta( input_thread_t *p_input, demux_t *p_demux )
 {
+    vlc_meta_t *p_meta = vlc_meta_New();
+    if( unlikely(p_meta == NULL) )
+        return;
+
+    demux_Control( p_demux, DEMUX_GET_META, p_meta );
+
     /* If metadata changed, then the attachments might have changed.
        We need to update them in case they contain album art. */
-    input_source_t *in = &p_input->p->input;
-    int i_attachment;
     input_attachment_t **attachment;
-    if( !demux_Control( in->p_demux, DEMUX_GET_ATTACHMENTS,
-                         &attachment, &i_attachment ) )
+    int i_attachment;
+
+    if( !demux_Control( p_demux, DEMUX_GET_ATTACHMENTS,
+                        &attachment, &i_attachment ) )
     {
         vlc_mutex_lock( &p_input->p->p_item->lock );
         if( p_input->p->i_attachment > 0 )
@@ -2744,6 +2739,7 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
                           i_attachment, attachment );
         vlc_mutex_unlock( &p_input->p->p_item->lock );
     }
+
     es_out_ControlSetMeta( p_input->p->p_es_out, p_meta );
     vlc_meta_Delete( p_meta );
 }



More information about the vlc-commits mailing list