Commit f1016ea1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

lib: rectify SPU track IDs (refs #7645)

(cherry picked from commit e712c11f55e881fd91774921e69a2736d8fdad0b)
parent 4e41845c
...@@ -277,11 +277,6 @@ void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi, ...@@ -277,11 +277,6 @@ void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi,
int libvlc_video_get_spu( libvlc_media_player_t *p_mi ) int libvlc_video_get_spu( libvlc_media_player_t *p_mi )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_value_t val_list;
vlc_value_t val;
int i_spu = -1;
int i_ret = -1;
int i;
if( !p_input_thread ) if( !p_input_thread )
{ {
...@@ -289,24 +284,7 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi ) ...@@ -289,24 +284,7 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi )
return -1; return -1;
} }
i_ret = var_Get( p_input_thread, "spu-es", &val ); int i_spu = var_GetInteger( p_input_thread, "spu-es" );
if( i_ret < 0 )
{
vlc_object_release( p_input_thread );
libvlc_printerr( "Subtitle information not found" );
return -1;
}
var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
for( i = 0; i < val_list.p_list->i_count; i++ )
{
if( val.i_int == val_list.p_list->p_values[i].i_int )
{
i_spu = i;
break;
}
}
var_FreeList( &val_list, NULL );
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
return i_spu; return i_spu;
} }
...@@ -334,22 +312,23 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, unsigned i_spu ) ...@@ -334,22 +312,23 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, unsigned i_spu )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_value_t list; vlc_value_t list;
int i_ret = 0; int i_ret = -1;
if( !p_input_thread ) if( !p_input_thread )
return -1; return -1;
var_Change (p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &list, NULL); var_Change (p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &list, NULL);
for (int i = 0; i < list.p_list->i_count; i++)
if (i_spu > (unsigned)list.p_list->i_count)
{ {
libvlc_printerr( "Subtitle number out of range (%u/%u)", if( i_spu == list.p_list->p_values[i].i_int )
i_spu, list.p_list->i_count ); {
i_ret = -1; if( var_SetInteger( p_input_thread, "spu-es", i_spu ) < 0 )
goto end; break;
i_ret = 0;
goto end;
}
} }
var_SetInteger (p_input_thread, "spu-es", libvlc_printerr( "Track identifier not found" );
list.p_list->p_values[i_spu].i_int);
end: end:
vlc_object_release (p_input_thread); vlc_object_release (p_input_thread);
var_FreeList (&list, NULL); var_FreeList (&list, 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