[vlc-commits] input/input: remove input_SubtitleFileAdd

Thomas Guillem git at videolan.org
Thu May 19 15:57:27 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Mar 25 13:56:11 2016 +0100| [b38a4ef199e637a50760e3280cefe3bb33b9b64b] | committer: Thomas Guillem

input/input: remove input_SubtitleFileAdd

And replace it with input_SubtitleFile2Uri that returns a string that can be
used with input_SubtitleAdd.

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

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

diff --git a/src/input/input.c b/src/input/input.c
index be2380d..eb692d4 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -103,7 +103,7 @@ enum {
 };
 
 static void input_SubtitleAdd( input_thread_t *, const char *, unsigned );
-static void input_SubtitleFileAdd( input_thread_t *, const char *, unsigned, bool );
+static char *input_SubtitleFile2Uri( input_thread_t *, const char * );
 static void input_ChangeState( input_thread_t *p_input, int i_state ); /* TODO fix name */
 
 #undef input_Create
@@ -973,7 +973,13 @@ static void LoadSubtitles( input_thread_t *p_input )
     if( psz_subtitle != NULL )
     {
         msg_Dbg( p_input, "forced subtitle: %s", psz_subtitle );
-        input_SubtitleFileAdd( p_input, psz_subtitle, SUB_FORCED, true );
+        char *psz_uri = input_SubtitleFile2Uri( p_input, psz_subtitle );
+        if( psz_uri != NULL )
+        {
+            free( psz_subtitle );
+            psz_subtitle = psz_uri;
+            input_SubtitleAdd( p_input, psz_uri, SUB_FORCED  );
+        }
     }
 
     if( var_GetBool( p_input, "sub-autodetect-file" ) )
@@ -1903,7 +1909,14 @@ static bool Control( input_thread_t *p_input,
 
         case INPUT_CONTROL_ADD_SUBTITLE:
             if( val.psz_string )
-                input_SubtitleFileAdd( p_input, val.psz_string, SUB_FORCED, true );
+            {
+                char *psz_uri = input_SubtitleFile2Uri( p_input, val.psz_string );
+                if( psz_uri != NULL )
+                {
+                    input_SubtitleAdd( p_input, psz_uri, SUB_FORCED );
+                    free( psz_uri );
+                }
+            }
             break;
 
         case INPUT_CONTROL_ADD_SLAVE:
@@ -2847,14 +2860,13 @@ static void input_SubtitleAdd( input_thread_t *p_input,
     var_FreeList( &list, NULL );
 }
 
-static void input_SubtitleFileAdd( input_thread_t *p_input,
-                                   const char *psz_subtitle, unsigned i_flags,
-                                   bool b_check_idx )
+static char *input_SubtitleFile2Uri( input_thread_t *p_input,
+                                     const char *psz_subtitle )
 {
     /* if we are provided a subtitle.sub file,
      * see if we don't have a subtitle.idx and use it instead */
     char *psz_idxpath = NULL;
-    char *psz_extension = b_check_idx ? strrchr( psz_subtitle, '.') : NULL;
+    char *psz_extension = strrchr( psz_subtitle, '.');
     if( psz_extension && strcmp( psz_extension, ".sub" ) == 0 )
     {
         psz_idxpath = strdup( psz_subtitle );
@@ -2874,13 +2886,7 @@ static void input_SubtitleFileAdd( input_thread_t *p_input,
         }
     }
 
-    char *url = vlc_path2uri( psz_subtitle, NULL );
-    free( psz_idxpath );
-    if( url == NULL )
-        return;
-
-    input_SubtitleAdd( p_input, url, i_flags );
-    free( url );
+    return vlc_path2uri( psz_subtitle, NULL );
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list