mirror of https://code.videolan.org/videolan/vlc
hotkeys: fix first subtitles toggle
A new hotkey to toggle subtitles visibility was introduced by commit
69d6f2ab18
. The idea was to save the
current track id every time the subtitles track is switched via the
hotkey (v), and restore it on toggle (Shift+v).
However, the subtitle track is not necessarily changed via the hotkey:
it may be selected as a default subtitle, or switched from the menu for
example. As a consequence, the saved track id may be invalid.
To fix the issue, do not try to save the selected track id every time it
changes; instead, save it on toggle if subtitles are enabled, and
restore the track with the saved id if subtitles are disabled.
Fixes #16721
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
This commit is contained in:
parent
a805a5d98b
commit
bb21396e96
|
@ -794,7 +794,6 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
|
|||
else
|
||||
i = (i_action == ACTIONID_SUBTITLE_TRACK) ? i+1 : i-1;
|
||||
var_SetInteger( p_input, "spu-es", list.p_list->p_values[i].i_int );
|
||||
var_SetInteger( p_input, "spu-choice", list.p_list->p_values[i].i_int );
|
||||
DisplayMessage( p_vout, _("Subtitle track: %s"),
|
||||
list2.p_list->p_values[i].psz_string );
|
||||
var_FreeList( &list, &list2 );
|
||||
|
@ -804,13 +803,9 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
|
|||
if( p_input )
|
||||
{
|
||||
vlc_value_t list, list2;
|
||||
int i_count, i_sel_index, i_sel_id, i_old_id, i_new_index;
|
||||
i_old_id = var_GetInteger( p_input, "spu-es" );
|
||||
i_sel_id = var_GetInteger( p_input, "spu-choice" );
|
||||
|
||||
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
|
||||
&list, &list2 );
|
||||
i_count = list.p_list->i_count;
|
||||
int i_count = list.p_list->i_count;
|
||||
if( i_count <= 1 )
|
||||
{
|
||||
DisplayMessage( p_vout, _("Subtitle track: %s"),
|
||||
|
@ -818,30 +813,34 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
|
|||
var_FreeList( &list, &list2 );
|
||||
break;
|
||||
}
|
||||
for( i_sel_index = 0; i_sel_index < i_count; i_sel_index++ )
|
||||
|
||||
int i_cur_id = var_GetInteger( p_input, "spu-es" );
|
||||
int i_new_id;
|
||||
if( i_cur_id == -1 )
|
||||
{
|
||||
if( i_sel_id == list.p_list->p_values[i_sel_index].i_int )
|
||||
{
|
||||
break;
|
||||
}
|
||||
/* subtitles were disabled: restore the saved track id */
|
||||
i_new_id = var_GetInteger( p_input, "spu-choice" );
|
||||
if( i_new_id != -1 )
|
||||
var_SetInteger( p_input, "spu-choice", -1 );
|
||||
}
|
||||
/* if there is nothing to toggle choose the first track */
|
||||
if( !i_sel_index ) {
|
||||
i_sel_index = 1;
|
||||
i_sel_id = list.p_list->p_values[1].i_int;
|
||||
var_SetInteger( p_input, "spu-choice", i_sel_id );
|
||||
else
|
||||
{
|
||||
/* subtitles were enabled: save the track id and disable */
|
||||
i_new_id = -1;
|
||||
var_SetInteger( p_input, "spu-choice", i_cur_id );
|
||||
}
|
||||
|
||||
i_new_index = 0;
|
||||
if( i_old_id != i_sel_id )
|
||||
int i_new_index = 1; /* select first track by default */
|
||||
/* if subtitles were disabled with no saved id, use the first track */
|
||||
if( i_cur_id != -1 || i_new_id != -1 )
|
||||
{
|
||||
if( i_sel_index >= i_count )
|
||||
for( int i = 0; i < i_count; ++i )
|
||||
{
|
||||
var_SetInteger( p_input, "spu-choice", list.p_list->p_values[0].i_int );
|
||||
}
|
||||
else
|
||||
{
|
||||
i_new_index = i_sel_index;
|
||||
if( i_new_id == list.p_list->p_values[i].i_int )
|
||||
{
|
||||
i_new_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var_SetInteger( p_input, "spu-es", list.p_list->p_values[i_new_index].i_int );
|
||||
|
|
Loading…
Reference in New Issue