Thomas Guillem pushed to branch master at VideoLAN / VLC


Commits:
8538decd by Timshel at 2024-07-05T14:35:15+00:00
es_out: send vout_order to ES events

Secondary subtitles cycling is broken because `trackpriv->vout_order`
is never set.

Add `vlc_vout_order` in `vlc_input_event_es` to keep track of it.

Additionnaly to limit modifications when selecting multiples tracks
(Ex: `EsOutSelectList`) we consider that the PRIMARY is always in
first position.

- - - - -
4b043ab2 by Timshel at 2024-07-05T14:35:15+00:00
hotkeys: order selected sub tracks by vout

- - - - -
976f8473 by Timshel at 2024-07-05T14:35:15+00:00
player: support vout_order in vlc_player_CycleTrack

- - - - -


11 changed files:

- include/vlc_player.h
- modules/control/gestures.c
- modules/control/hotkeys.c
- modules/gui/macosx/playlist/VLCPlayerController.m
- modules/gui/ncurses.c
- src/input/es_out.c
- src/input/input_internal.h
- src/libvlccore.sym
- src/player/input.c
- src/player/player.c
- test/src/player/player.c


Changes:

=====================================
include/vlc_player.h
=====================================
@@ -1585,39 +1585,55 @@ vlc_player_SelectEsIdList(vlc_player_t *player,
                           enum es_format_category_e cat,
                           vlc_es_id_t *const es_id_list[]);
 
+
 /**
- * Select the next track
+ * Cycle through the tracks
  *
  * If the last track is already selected, a call to this function will disable
  * this last track. And a second call will select the first track.
- *
- * @warning This function has no effects if there are several tracks selected
- * for a same category. Therefore the default policy is
- * VLC_PLAYER_SELECT_EXCLUSIVE.
+ * Unless called on the PRIMARY with a SECONDARY selected, it will cycle 
through
  *
  * @param player locked player instance
  * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
+ * @param next the cycle order
  */
 VLC_API void
-vlc_player_SelectNextTrack(vlc_player_t *player,
-                           enum es_format_category_e cat);
+vlc_player_CycleTrack(vlc_player_t *player, enum es_format_category_e cat,
+                      enum vlc_vout_order vout_order, bool next);
 
 /**
- * Select the Previous track
+ * Helper to select the next track
+ *
+ * If the last track is already selected, a call to this function will disable
+ * this last track. And a second call will select the first track.
+ * Unless called on the PRIMARY with a SECONDARY selected, it will cycle 
through
+ *
+ * @param player locked player instance
+ * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
+ */
+static inline void
+vlc_player_SelectNextTrack(vlc_player_t *player, enum es_format_category_e cat,
+                           enum vlc_vout_order vout_order)
+{
+    vlc_player_CycleTrack(player, cat, vout_order, true);
+}
+
+/**
+ * Helper to select the Previous track
  *
  * If the first track is already selected, a call to this function will disable
  * this first track. And a second call will select the last track.
- *
- * @warning This function has no effects if there are several tracks selected
- * for a same category. Therefore the default policy is
- * VLC_PLAYER_SELECT_EXCLUSIVE.
+ * Unless called on the PRIMARY with a SECONDARY selected, it will cycle 
through
  *
  * @param player locked player instance
  * @param cat VIDEO_ES, AUDIO_ES or SPU_ES
  */
-VLC_API void
-vlc_player_SelectPrevTrack(vlc_player_t *player,
-                           enum es_format_category_e cat);
+static inline void
+vlc_player_SelectPrevTrack(vlc_player_t *player, enum es_format_category_e cat,
+                           enum vlc_vout_order vout_order)
+{
+    vlc_player_CycleTrack(player, cat, vout_order, false);
+}
 
 /**
  * Unselect a track from an ES identifier


=====================================
modules/control/gestures.c
=====================================
@@ -274,7 +274,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
             enum es_format_category_e cat =
                 p_sys->i_pattern == GESTURE(UP,RIGHT,NONE,NONE) ?
                 AUDIO_ES : SPU_ES;
-            vlc_player_SelectNextTrack(player, cat);
+            vlc_player_SelectNextTrack(player, cat, VLC_VOUT_ORDER_PRIMARY);
             break;
         }
 


=====================================
modules/control/hotkeys.c
=====================================
@@ -365,109 +365,17 @@ PLAYER_ACTION_HANDLER(NavigateMedia)
     }
 }
 
-static void CycleSecondarySubtitles(intf_thread_t *intf, vlc_player_t *player,
-                                    bool next)
-{
-    intf_sys_t *sys = intf->p_sys;
-    const enum es_format_category_e cat = SPU_ES;
-    size_t count = vlc_player_GetTrackCount(player, cat);
-    if (!count)
-        return;
-
-    vlc_es_id_t *cycle_id = NULL;
-    vlc_es_id_t *keep_id = NULL;
-
-    /* Check how many subtitle tracks are already selected */
-    size_t selected_count = 0;
-    for (size_t i = 0; i < count; ++i)
-    {
-        const struct vlc_player_track *track =
-            vlc_player_GetTrackAt(player, cat, i);
-        assert(track);
-
-        if (track->selected)
-        {
-            enum vlc_vout_order order;
-            if (vlc_player_GetEsIdVout(player, track->es_id, &order)
-             && order == sys->spu_channel_order)
-                cycle_id = track->es_id;
-            else
-                keep_id = track->es_id;
-            ++selected_count;
-        }
-    }
-
-    if ((sys->spu_channel_order == VLC_VOUT_ORDER_PRIMARY
-      && selected_count == 1) || selected_count == 0)
-    {
-        /* Only cycle the primary subtitle track */
-        if (next)
-            vlc_player_SelectNextTrack(player, cat);
-        else
-            vlc_player_SelectPrevTrack(player, cat);
-    }
-    else
-    {
-        /* Find out the current selected index.
-           If no track selected, select the first or the last track */
-        size_t index = next ? 0 : count - 1;
-        for (size_t i = 0; i < count; ++i)
-        {
-            const struct vlc_player_track *track =
-                vlc_player_GetTrackAt(player, cat, i);
-            assert(track);
-
-            if (track->es_id == cycle_id)
-            {
-                index = i;
-                break;
-            }
-        }
-
-        /* Look for the next free (unselected) track */
-        while (true)
-        {
-            const struct vlc_player_track *track =
-                vlc_player_GetTrackAt(player, cat, index);
-
-            if (!track->selected)
-            {
-                cycle_id = track->es_id;
-                break;
-            }
-            /* Unselect if we reach the end of the cycle */
-            else if ((next && index + 1 == count) || (!next && index == 0))
-            {
-                cycle_id = NULL;
-                break;
-            }
-            else /* Switch to the next or previous track */
-                index = index + (next ? 1 : -1);
-        }
-
-        /* Make sure the list never contains NULL before a valid id */
-        if ( !keep_id )
-        {
-            keep_id = cycle_id;
-            cycle_id = NULL;
-        }
-
-        vlc_es_id_t *esIds[] = { keep_id, cycle_id, NULL };
-        vlc_player_SelectEsIdList(player, cat, esIds);
-    }
-}
-
 PLAYER_ACTION_HANDLER(Track)
 {
     switch (action_id)
     {
         case ACTIONID_AUDIO_TRACK:
-            vlc_player_SelectNextTrack(player, AUDIO_ES);
+            vlc_player_SelectNextTrack(player, AUDIO_ES, 
VLC_VOUT_ORDER_PRIMARY);
             break;
         case ACTIONID_SUBTITLE_REVERSE_TRACK:
         case ACTIONID_SUBTITLE_TRACK:
-            CycleSecondarySubtitles(intf, player,
-                                    action_id == ACTIONID_SUBTITLE_TRACK);
+            vlc_player_CycleTrack(player, SPU_ES, 
intf->p_sys->spu_channel_order,
+                                  action_id == ACTIONID_SUBTITLE_TRACK);
             break;
         default:
             vlc_assert_unreachable();


=====================================
modules/gui/macosx/playlist/VLCPlayerController.m
=====================================
@@ -1423,14 +1423,14 @@ static int BossCallback(vlc_object_t *p_this,
 - (void)selectPreviousTrackForCategory:(enum es_format_category_e)category
 {
     vlc_player_Lock(_p_player);
-    vlc_player_SelectPrevTrack(_p_player, category);
+    vlc_player_SelectPrevTrack(_p_player, category, VLC_VOUT_ORDER_PRIMARY);
     vlc_player_Unlock(_p_player);
 }
 
 - (void)selectNextTrackForCategory:(enum es_format_category_e)category
 {
     vlc_player_Lock(_p_player);
-    vlc_player_SelectNextTrack(_p_player, category);
+    vlc_player_SelectNextTrack(_p_player, category, VLC_VOUT_ORDER_PRIMARY);
     vlc_player_Unlock(_p_player);
 }
 


=====================================
modules/gui/ncurses.c
=====================================
@@ -1503,17 +1503,17 @@ static void HandleCommonKey(intf_thread_t *intf, 
vlc_player_t *player, int key)
 
     case 'c':
         vlc_player_Lock(player);
-        vlc_player_SelectNextTrack(player, AUDIO_ES);
+        vlc_player_SelectNextTrack(player, AUDIO_ES, VLC_VOUT_ORDER_PRIMARY);
         vlc_player_Unlock(player);
         break;
     case 'v':
         vlc_player_Lock(player);
-        vlc_player_SelectNextTrack(player, SPU_ES);
+        vlc_player_SelectNextTrack(player, SPU_ES, VLC_VOUT_ORDER_PRIMARY);
         vlc_player_Unlock(player);
         break;
     case 'b':
         vlc_player_Lock(player);
-        vlc_player_SelectNextTrack(player, VIDEO_ES);
+        vlc_player_SelectNextTrack(player, VIDEO_ES, VLC_VOUT_ORDER_PRIMARY);
         vlc_player_Unlock(player);
         break;
 


=====================================
src/input/es_out.c
=====================================
@@ -251,7 +251,7 @@ static void         EsOutUpdateInfo(es_out_sys_t *, 
es_out_id_t *es, const vlc_m
 static int          EsOutSetRecord(es_out_sys_t *, bool b_record, const char 
*dir_path);
 
 static bool EsIsSelected( es_out_id_t *es );
-static void EsOutSelectEs(es_out_sys_t *out, es_out_id_t *es, bool b_force);
+static void EsOutSelectEs(es_out_sys_t *out, es_out_id_t *es, bool b_force, 
enum vlc_vout_order vout_order);
 static void EsOutDeleteInfoEs(es_out_sys_t *, es_out_id_t *es);
 static void EsOutUnselectEs(es_out_sys_t *out, es_out_id_t *es, bool b_update);
 static void EsOutDecoderChangeDelay(es_out_sys_t *out, es_out_id_t *p_es);
@@ -1206,7 +1206,7 @@ static vlc_tick_t EsOutGetBuffering(es_out_sys_t *p_sys)
 }
 
 static void EsOutSendEsEvent(es_out_sys_t *p_sys, es_out_id_t *es, int action,
-                             bool forced)
+                             bool forced, enum vlc_vout_order vout_order)
 {
     input_thread_t *p_input = p_sys->p_input;
 
@@ -1234,6 +1234,7 @@ static void EsOutSendEsEvent(es_out_sys_t *p_sys, 
es_out_id_t *es, int action,
         .title = es->psz_title ? es->psz_title : "",
         .fmt = es->fmt_out.i_cat != UNKNOWN_ES ? &es->fmt_out : &es->fmt,
         .forced = forced,
+        .vout_order = vout_order,
     });
 }
 
@@ -1391,7 +1392,7 @@ static void EsOutProgramSelect(es_out_sys_t *p_sys, 
es_out_pgrm_t *p_pgrm)
                 /* ES tracks are deleted (and unselected) when their programs
                  * are unselected (they will be added back when their programs
                  * are selected back). */
-                EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_DELETED, false);
+                EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_DELETED, false, 
VLC_VOUT_ORDER_PRIMARY);
             }
 
         }
@@ -1426,7 +1427,7 @@ static void EsOutProgramSelect(es_out_sys_t *p_sys, 
es_out_pgrm_t *p_pgrm)
         }
         else if (es->p_pgrm == p_sys->p_pgrm)
         {
-            EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_ADDED, false);
+            EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_ADDED, false, 
VLC_VOUT_ORDER_PRIMARY);
             EsOutUpdateInfo(p_sys, es, NULL);
         }
 
@@ -2192,7 +2193,7 @@ static es_out_id_t *EsOutAddLocked(es_out_sys_t *p_sys,
     vlc_atomic_rc_init(&es->rc);
 
     if( es->p_pgrm == p_sys->p_pgrm )
-        EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_ADDED, false);
+        EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_ADDED, false, 
VLC_VOUT_ORDER_PRIMARY);
 
     EsOutUpdateInfo(p_sys, es, NULL);
     EsOutSelect(p_sys, es, false);
@@ -2400,7 +2401,7 @@ static void EsOutDestroyDecoder(es_out_sys_t *sys,
     es_format_Clean( &p_es->fmt_out );
 }
 
-static void EsOutSelectEs(es_out_sys_t *p_sys, es_out_id_t *es, bool b_force)
+static void EsOutSelectEs(es_out_sys_t *p_sys, es_out_id_t *es, bool b_force, 
enum vlc_vout_order vout_order)
 {
     input_thread_t *p_input = p_sys->p_input;
     bool b_thumbnailing = p_sys->input_type == INPUT_TYPE_THUMBNAILING;
@@ -2456,7 +2457,7 @@ static void EsOutSelectEs(es_out_sys_t *p_sys, 
es_out_id_t *es, bool b_force)
         return;
 
     /* Mark it as selected */
-    EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_SELECTED, b_force);
+    EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_SELECTED, b_force, vout_order);
 
     /* Special case of the zvbi decoder for teletext: send the initial selected
      * page and transparency */
@@ -2505,7 +2506,7 @@ static void EsOutUnselectEs(es_out_sys_t *p_sys, 
es_out_id_t *es, bool b_update)
         return;
 
     /* Mark it as unselected */
-    EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_UNSELECTED, false);
+    EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_UNSELECTED, false, 
VLC_VOUT_ORDER_PRIMARY);
 }
 
 static bool EsOutSelectMatchPrioritized( const es_out_es_props_t *p_esprops,
@@ -2602,7 +2603,7 @@ static void EsOutSelect(es_out_sys_t *p_sys, es_out_id_t 
*es, bool b_force)
             if( b_auto_unselect )
                 EsOutUnselectEs(p_sys, p_esprops->p_main_es, true);
 
-            EsOutSelectEs(p_sys, es, b_force);
+            EsOutSelectEs(p_sys, es, b_force, VLC_VOUT_ORDER_PRIMARY);
         }
     }
     else if( p_sys->i_mode == ES_OUT_MODE_PARTIAL )
@@ -2619,7 +2620,7 @@ static void EsOutSelect(es_out_sys_t *p_sys, es_out_id_t 
*es, bool b_force)
                 if( atoi( prgm ) == es->p_pgrm->i_id )
                 {
                     if( !EsIsSelected( es ) )
-                        EsOutSelectEs(p_sys, es, b_force);
+                        EsOutSelectEs(p_sys, es, b_force, 
VLC_VOUT_ORDER_PRIMARY);
                     break;
                 }
             }
@@ -2690,7 +2691,7 @@ static void EsOutSelect(es_out_sys_t *p_sys, es_out_id_t 
*es, bool b_force)
             if( b_auto_unselect )
                 EsOutUnselectEs(p_sys, p_esprops->p_main_es, true);
 
-            EsOutSelectEs(p_sys, es, b_force);
+            EsOutSelectEs(p_sys, es, b_force, VLC_VOUT_ORDER_PRIMARY);
         }
     }
 
@@ -2735,7 +2736,7 @@ static void EsOutSelectListFromProps(es_out_sys_t *p_sys, 
enum es_format_categor
         strcpy( buffer, esprops->str_ids );
         if( EsOutIdMatchStrIds( other, buffer ) && !EsIsSelected( other ) )
         {
-            EsOutSelectEs(p_sys, other, true);
+            EsOutSelectEs(p_sys, other, true, VLC_VOUT_ORDER_PRIMARY);
 
             if( esprops->e_policy == ES_OUT_ES_POLICY_EXCLUSIVE )
                 break;
@@ -2784,7 +2785,11 @@ static void EsOutSelectList(es_out_sys_t *p_sys, enum 
es_format_category_e cat,
             continue;
         }
 
-        EsOutSelectEs(p_sys, other, true);
+        /* First ID is considered to be the PRIMARY */
+        enum vlc_vout_order vout_oder = ( es_id_list[0] == &other->id )
+            ? VLC_VOUT_ORDER_PRIMARY
+            : VLC_VOUT_ORDER_SECONDARY;
+        EsOutSelectEs(p_sys, other, true, vout_oder);
 
         if (p_esprops->e_policy == ES_OUT_ES_POLICY_EXCLUSIVE)
             break;
@@ -2967,7 +2972,7 @@ static int EsOutSend(es_out_t *out, es_out_id_t *es, 
block_t *p_block )
         if (ret == VLC_SUCCESS)
         {
             EsOutUpdateInfo(p_sys, es, status.format.meta);
-            EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_UPDATED, false);
+            EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_UPDATED, false, 
VLC_VOUT_ORDER_PRIMARY);
         }
 
         es_format_Clean( &status.format.fmt );
@@ -3030,7 +3035,7 @@ static void EsOutDelLocked(es_out_sys_t *p_sys, 
es_out_id_t *es)
     EsTerminate(es);
 
     if( es->p_pgrm == p_sys->p_pgrm )
-        EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_DELETED, false);
+        EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_DELETED, false, 
VLC_VOUT_ORDER_PRIMARY);
 
     EsOutDeleteInfoEs(p_sys, es);
 
@@ -3067,7 +3072,7 @@ static void EsOutDelLocked(es_out_sys_t *p_sys, 
es_out_id_t *es)
             {
                 if (EsIsSelected(other))
                 {
-                    EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_SELECTED, false);
+                    EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_SELECTED, false, 
VLC_VOUT_ORDER_PRIMARY);
                     if( p_esprops->p_main_es == NULL )
                         p_esprops->p_main_es = other;
                 }
@@ -3156,7 +3161,7 @@ static int EsOutVaControlLocked(es_out_sys_t *p_sys, 
input_source_t *source,
         bool is_selected = EsIsSelected(es);
         if(request_select && !is_selected)
         {
-            EsOutSelectEs(p_sys, es, true);
+            EsOutSelectEs(p_sys, es, true, VLC_VOUT_ORDER_PRIMARY);
             return EsIsSelected( es ) ? VLC_SUCCESS : VLC_EGENERIC;
         }
 
@@ -3488,7 +3493,7 @@ static int EsOutVaControlLocked(es_out_sys_t *p_sys, 
input_source_t *source,
         if(b_was_selected)
             EsOutCreateDecoder(p_sys, es);
 
-        EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_UPDATED, false);
+        EsOutSendEsEvent(p_sys, es, VLC_INPUT_ES_UPDATED, false, 
VLC_VOUT_ORDER_PRIMARY);
 
         return VLC_SUCCESS;
     }


=====================================
src/input/input_internal.h
=====================================
@@ -245,6 +245,8 @@ struct vlc_input_event_es {
      * the user.
      */
     bool forced;
+
+    enum vlc_vout_order vout_order;
 };
 
 struct vlc_input_event_signal {


=====================================
src/libvlccore.sym
=====================================
@@ -854,6 +854,7 @@ vlc_player_aout_RemoveListener
 vlc_player_aout_SetVolume
 vlc_player_ChangeRate
 vlc_player_CondWait
+vlc_player_CycleTrack
 vlc_player_DisplayPosition
 vlc_player_DecrementRate
 vlc_player_Delete
@@ -916,11 +917,9 @@ vlc_player_SelectEsId
 vlc_player_SelectEsIdList
 vlc_player_SelectNextChapter
 vlc_player_SelectNextTitle
-vlc_player_SelectNextTrack
 vlc_player_SelectNextProgram
 vlc_player_SelectPrevChapter
 vlc_player_SelectPrevTitle
-vlc_player_SelectPrevTrack
 vlc_player_SelectPrevProgram
 vlc_player_SelectProgram
 vlc_player_SelectTeletextPage


=====================================
src/player/input.c
=====================================
@@ -640,6 +640,7 @@ vlc_player_input_HandleEsEvent(struct vlc_player_input 
*input,
             {
                 trackpriv->t.selected = true;
                 trackpriv->selected_by_user = ev->forced;
+                trackpriv->vout_order = ev->vout_order;
                 vlc_player_SendEvent(player, on_track_selection_changed,
                                      NULL, trackpriv->t.es_id);
                 vlc_player_input_HandleTeletextMenu(input, ev, trackpriv);


=====================================
src/player/player.c
=====================================
@@ -596,69 +596,77 @@ vlc_player_SelectTracksByStringIds(vlc_player_t *player,
         vlc_player_input_SelectTracksByStringIds(input, cat, str_ids);
 }
 
-static void
+void
 vlc_player_CycleTrack(vlc_player_t *player, enum es_format_category_e cat,
-                      bool next)
+                      enum vlc_vout_order vout_order, bool next)
 {
     size_t count = vlc_player_GetTrackCount(player, cat);
     if (!count)
         return;
 
-    size_t index;
-    bool selected = false;
-    for (size_t i = 0; i < count; ++i)
+    vlc_es_id_t *keep_id = NULL;
+
+    /* Check how many tracks are already selected */
+    size_t selected_count = 0;
+
+    /* Find out the current selected index.
+     * If no track selected, select the first or the last track */
+    size_t cycle_index = next ? count-1 : count;
+
+    for (size_t i = 0; i < count && selected_count < 2; ++i)
     {
         const struct vlc_player_track *track =
             vlc_player_GetTrackAt(player, cat, i);
         assert(track);
+
         if (track->selected)
         {
-            if (selected)
-            {
-                /* Can't cycle through tracks if there are more than one
-                 * selected */
-                return;
-            }
-            index = i;
-            selected = true;
+            enum vlc_vout_order order;
+            vlc_player_GetEsIdVout(player, track->es_id, &order);
+            if (order == vout_order)
+                cycle_index = i;
+            else
+                keep_id = track->es_id;
+            ++selected_count;
         }
     }
 
-    if (!selected)
+    vlc_es_id_t * cycle_id = NULL;
+    /* Look for the next free (unselected) track */
+    for (size_t i = 0; i < count; ++i)
     {
-        /* No track selected: select the first or the last track */
-        index = next ? 0 : count - 1;
-        selected = true;
+        cycle_index = (cycle_index + (next ? 1 : -1) + count) % count;
+
+        /* Unselect if we reach the end of the cycle
+         * Unless cycling PRIMARY with a selected SECONDARY then wrap around */
+        if (((next && cycle_index == 0) || (!next && cycle_index + 1 == count))
+         && ((selected_count == 1 && vout_order == VLC_VOUT_ORDER_PRIMARY)
+          || (selected_count == 2 && vout_order == VLC_VOUT_ORDER_SECONDARY)))
+            break;
+
+        const struct vlc_player_track *track =
+            vlc_player_GetTrackAt(player, cat, cycle_index);
+        if (!track->selected)
+        {
+            cycle_id = track->es_id;
+            break;
+        }
     }
-    else
+
+    // We want the PRIMARY in first position
+    vlc_es_id_t *esIds[] = { cycle_id, keep_id, NULL };
+    if (vout_order == VLC_VOUT_ORDER_SECONDARY)
     {
-        /* Unselect if we reach the end of the cycle */
-        if ((next && index + 1 == count) || (!next && index == 0))
-            selected = false;
-        else /* Switch to the next or previous track */
-            index = index + (next ? 1 : -1);
+        esIds[0] = keep_id;
+        esIds[1] = cycle_id;
+    }
+    if (!esIds[0])
+    {
+        esIds[0] = esIds[1];
+        esIds[1] = NULL;
     }
 
-    const struct vlc_player_track *track =
-        vlc_player_GetTrackAt(player, cat, index);
-    if (selected)
-        vlc_player_SelectTrack(player, track, VLC_PLAYER_SELECT_EXCLUSIVE);
-    else
-        vlc_player_UnselectTrack(player, track);
-}
-
-void
-vlc_player_SelectNextTrack(vlc_player_t *player,
-                           enum es_format_category_e cat)
-{
-    vlc_player_CycleTrack(player, cat, true);
-}
-
-void
-vlc_player_SelectPrevTrack(vlc_player_t *player,
-                           enum es_format_category_e cat)
-{
-    vlc_player_CycleTrack(player, cat, false);
+    vlc_player_SelectEsIdList(player, cat, esIds);
 }
 
 void


=====================================
test/src/player/player.c
=====================================
@@ -1421,7 +1421,7 @@ test_tracks(struct ctx *ctx, bool packetized)
         /* Select all track via next calls */
         for (size_t j = 0; j < params.track_count[cat]; ++j)
         {
-            vlc_player_SelectNextTrack(player, cat);
+            vlc_player_SelectNextTrack(player, cat, VLC_VOUT_ORDER_PRIMARY);
 
             /* Wait that the next track is selected */
             const struct vlc_player_track *track =
@@ -1435,7 +1435,7 @@ test_tracks(struct ctx *ctx, bool packetized)
         /* Select all track via previous calls */
         for (size_t j = params.track_count[cat] - 1; j > 0; --j)
         {
-            vlc_player_SelectPrevTrack(player, cat);
+            vlc_player_SelectPrevTrack(player, cat, VLC_VOUT_ORDER_PRIMARY);
 
             const struct vlc_player_track *track =
                 vlc_player_GetTrackAt(player, cat, j - 1);
@@ -1448,7 +1448,7 @@ test_tracks(struct ctx *ctx, bool packetized)
 
         }
         /* Current track index is 0, a previous will unselect the track */
-        vlc_player_SelectPrevTrack(player, cat);
+        vlc_player_SelectPrevTrack(player, cat, VLC_VOUT_ORDER_PRIMARY);
         const struct vlc_player_track *track =
             vlc_player_GetTrackAt(player, cat, 0);
         /* Wait that the track is unselected */



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/fe26ba9b11d30b8ca2f6682fef47dbed0c1f51c3...976f847333fbf97fc16c85902d764a14b61163fc

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/fe26ba9b11d30b8ca2f6682fef47dbed0c1f51c3...976f847333fbf97fc16c85902d764a14b61163fc
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to