]> git.sesse.net Git - vlc/blobdiff - modules/control/hotkeys.c
macosx: fix typo preventing post-processing (refs #11613)
[vlc] / modules / control / hotkeys.c
index 1e7fcdfceeff66e1ae4da41f93699806fb60086b..7a5db8cb2f2a5f4fb3a62bb38020744a8024ac20 100644 (file)
@@ -591,12 +591,63 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
                     i = 0;
                 else
                     i++;
-                var_Set( p_input, "spu-es", list.p_list->p_values[i] );
+                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 );
             }
             break;
+        case ACTIONID_SUBTITLE_TOGGLE:
+            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;
+                if( i_count <= 1 )
+                {
+                    DisplayMessage( p_vout, _("Subtitle track: %s"),
+                                    _("N/A") );
+                    var_FreeList( &list, &list2 );
+                    break;
+                }
+                for( i_sel_index = 0; i_sel_index < i_count; i_sel_index++ )
+                {
+                    if( i_sel_id == list.p_list->p_values[i_sel_index].i_int )
+                    {
+                        break;
+                    }
+                }
+                /* 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 );
+                }
+
+                i_new_index = 0;
+                if( i_old_id != i_sel_id )
+                {
+                    if( i_sel_index >= i_count )
+                    {
+                        var_SetInteger( p_input, "spu-choice", list.p_list->p_values[0].i_int );
+                    }
+                    else
+                    {
+                        i_new_index = i_sel_index;
+                    }
+                }
+                var_SetInteger( p_input, "spu-es", list.p_list->p_values[i_new_index].i_int );
+                DisplayMessage( p_vout, _("Subtitle track: %s"),
+                                list2.p_list->p_values[i_new_index].psz_string );
+                var_FreeList( &list, &list2 );
+            }
+            break;
         case ACTIONID_PROGRAM_SID_NEXT:
         case ACTIONID_PROGRAM_SID_PREV:
             if( p_input )