Commit b38a4ef1 authored by Thomas Guillem's avatar Thomas Guillem

input/input: remove input_SubtitleFileAdd

And replace it with input_SubtitleFile2Uri that returns a string that can be
used with input_SubtitleAdd.
parent 89735248
......@@ -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 );
}
/*****************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment