[vlc-commits] input: handle "sub-autodetect-file" option when adding slaves

Thomas Guillem git at videolan.org
Tue May 31 16:23:34 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue May 31 14:18:51 2016 +0200| [c82d2a0dd59956ad749ff006106dc39afa2c2d95] | committer: Thomas Guillem

input: handle "sub-autodetect-file" option when adding slaves

input_item_t slaves will be always loaded from LoadSlaves(): slaves added via
libvlc won't depend on "sub-autodetect-file" option. If this option is
activated, demuxers won't add any slaves.

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

 src/input/access.c |    3 +-
 src/input/input.c  |   83 ++++++++++++++++++++++++++--------------------------
 2 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/src/input/access.c b/src/input/access.c
index ecd5f37..c48f975 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -720,7 +720,8 @@ void access_fsdir_init(struct access_fsdir *p_fsdir,
     p_fsdir->b_show_hiddenfiles = var_InheritBool(p_access, "show-hiddenfiles");
     p_fsdir->psz_ignored_exts = var_InheritString(p_access, "ignore-filetypes");
     p_fsdir->psz_sort = var_InheritString(p_access, "directory-sort");
-    p_fsdir->i_sub_autodetect_fuzzy =
+    bool b_autodetect = var_InheritBool(p_access, "sub-autodetect-file");
+    p_fsdir->i_sub_autodetect_fuzzy = !b_autodetect ? 0 : 
         var_InheritInteger(p_access, "sub-autodetect-fuzzy");
     TAB_INIT(p_fsdir->i_slaves, p_fsdir->pp_slaves);
 }
diff --git a/src/input/input.c b/src/input/input.c
index d1b9b3e..c4e02b1 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -981,6 +981,10 @@ static void SetSubtitlesOptions( input_thread_t *p_input )
 
 static void LoadSlaves( input_thread_t *p_input )
 {
+    input_item_slave_t **pp_slaves;
+    int i_slaves;
+    TAB_INIT( i_slaves, pp_slaves );
+
     /* Look for and add slaves */
 
     char *psz_subtitle = var_GetNonEmptyString( p_input, "sub-file" );
@@ -999,9 +1003,6 @@ static void LoadSlaves( input_thread_t *p_input )
     if( var_GetBool( p_input, "sub-autodetect-file" ) )
     {
         /* Add local subtitles */
-        input_item_slave_t **pp_slaves;
-        int i_slaves;
-        TAB_INIT( i_slaves, pp_slaves );
         char *psz_autopath = var_GetNonEmptyString( p_input, "sub-autodetect-path" );
 
         if( subtitles_Detect( p_input, psz_autopath, p_input->p->p_item->psz_uri,
@@ -1021,52 +1022,52 @@ static void LoadSlaves( input_thread_t *p_input )
             }
         }
         free( psz_autopath );
+    }
 
-        /* Add slaves found by the directory demuxer */
-        input_item_t *p_item = p_input->p->p_item;
-        vlc_mutex_lock( &p_item->lock );
-        for( int i = 0; i < p_item->i_slaves; i++ )
+    /* Add slaves found by the directory demuxer or via libvlc */
+    input_item_t *p_item = p_input->p->p_item;
+    vlc_mutex_lock( &p_item->lock );
+    for( int i = 0; i < p_item->i_slaves; i++ )
+    {
+        input_item_slave_t *p_slave = p_item->pp_slaves[i];
+        if( !SlaveExists( pp_slaves, i_slaves, p_slave->psz_uri )
+         && ( !psz_subtitle || strcmp( psz_subtitle, p_slave->psz_uri ) ) )
         {
-            input_item_slave_t *p_slave = p_item->pp_slaves[i];
-            if( !SlaveExists( pp_slaves, i_slaves, p_slave->psz_uri )
-             && ( !psz_subtitle || strcmp( psz_subtitle, p_slave->psz_uri ) ) )
-            {
-                input_item_slave_t *p_dup_slave =
-                    input_item_slave_New( p_slave->psz_uri, p_slave->i_type,
-                                          p_slave->i_priority );
-                if( p_dup_slave )
-                    INSERT_ELEM( pp_slaves, i_slaves, i_slaves, p_dup_slave );
-            }
+            input_item_slave_t *p_dup_slave =
+                input_item_slave_New( p_slave->psz_uri, p_slave->i_type,
+                                      p_slave->i_priority );
+            if( p_dup_slave )
+                INSERT_ELEM( pp_slaves, i_slaves, i_slaves, p_dup_slave );
         }
-        vlc_mutex_unlock( &p_item->lock );
+    }
+    vlc_mutex_unlock( &p_item->lock );
 
-        if( i_slaves > 0 )
-            qsort( pp_slaves, i_slaves, sizeof (input_item_slave_t*),
-                   SlaveCompare );
+    if( i_slaves > 0 )
+        qsort( pp_slaves, i_slaves, sizeof (input_item_slave_t*),
+               SlaveCompare );
 
-        /* add all detected slaves */
-        for( int i = 0; i < i_slaves && pp_slaves[i] != NULL; i++ )
+    /* add all detected slaves */
+    for( int i = 0; i < i_slaves && pp_slaves[i] != NULL; i++ )
+    {
+        input_item_slave_t *p_slave = pp_slaves[i];
+        if( p_slave->i_type == SLAVE_TYPE_SPU )
         {
-            input_item_slave_t *p_slave = pp_slaves[i];
-            if( p_slave->i_type == SLAVE_TYPE_SPU )
-            {
-                msg_Err( p_input, "Loading spu slave: %s", p_slave->psz_uri );
-                input_SubtitleAdd( p_input, p_slave->psz_uri, SUB_CANFAIL );
-            }
-            else
-            {
-                msg_Err( p_input, "Loading slave: %s", p_slave->psz_uri );
-                input_source_t *p_source = InputSourceNew( p_input,
-                                                           p_slave->psz_uri,
-                                                           NULL, true );
-                if( p_source )
-                    TAB_APPEND( p_input->p->i_slave, p_input->p->slave, p_source );
-            }
-            input_item_slave_Delete( pp_slaves[i] );
+            msg_Err( p_input, "Loading spu slave: %s", p_slave->psz_uri );
+            input_SubtitleAdd( p_input, p_slave->psz_uri, SUB_CANFAIL );
         }
-
-        TAB_CLEAN( i_slaves, pp_slaves );
+        else
+        {
+            msg_Err( p_input, "Loading slave: %s", p_slave->psz_uri );
+            input_source_t *p_source = InputSourceNew( p_input,
+                                                       p_slave->psz_uri,
+                                                       NULL, true );
+            if( p_source )
+                TAB_APPEND( p_input->p->i_slave, p_input->p->slave, p_source );
+        }
+        input_item_slave_Delete( pp_slaves[i] );
     }
+
+    TAB_CLEAN( i_slaves, pp_slaves );
     free( psz_subtitle );
 
     /* Load subtitles from attachments */



More information about the vlc-commits mailing list