Commit f263178f authored by Thomas Guillem's avatar Thomas Guillem

lib: media_player: split libvlc_media_player_select_track

More than one users reported that they would prefer having a new function to
unselect. Furthermore, having a type and a track of the same type as arguments
feels confusing.
parent 635ecd1f
Pipeline #22337 passed with stages
in 19 minutes and 38 seconds
......@@ -1345,21 +1345,33 @@ libvlc_media_player_get_track_from_id( libvlc_media_player_t *p_mi,
/**
* Select a track or unselect all tracks for one type
* Select a track
*
* This will unselected the current track.
*
* \version LibVLC 4.0.0 and later.
*
* \note Use libvlc_media_player_select_tracks() for multiple selection
*
* \param p_mi the media player
* \param type type of the selected track
* \param track track to select or NULL to unselect all tracks of for this type
* \param track track to select, can't be NULL
*/
LIBVLC_API void
libvlc_media_player_select_track( libvlc_media_player_t *p_mi,
libvlc_track_type_t type,
const libvlc_media_track_t *track );
/**
* Unselect all tracks for a given type
*
* \version LibVLC 4.0.0 and later.
*
* \param p_mi the media player
* \param type type to unselect
*/
LIBVLC_API void
libvlc_media_player_unselect_track_type( libvlc_media_player_t *p_mi,
libvlc_track_type_t type );
/**
* Select multiple tracks for one type
*
......@@ -1374,7 +1386,7 @@ libvlc_media_player_select_track( libvlc_media_player_t *p_mi,
*
* \param p_mi the media player
* \param type type of the selected track
* \param tracks pointer to the track array
* \param tracks pointer to the track array, or NULL if track_count is 0
* \param track_count number of tracks in the track array
*/
LIBVLC_API void
......
......@@ -187,6 +187,7 @@ libvlc_media_player_get_tracklist
libvlc_media_player_get_track_from_id
libvlc_media_player_get_selected_track
libvlc_media_player_select_track
libvlc_media_player_unselect_track_type
libvlc_media_player_select_tracks
libvlc_media_player_select_tracks_by_ids
libvlc_media_release
......
......@@ -1898,27 +1898,30 @@ libvlc_media_player_get_track_from_id( libvlc_media_player_t *p_mi,
void
libvlc_media_player_select_track(libvlc_media_player_t *p_mi,
libvlc_track_type_t type,
const libvlc_media_track_t *track)
{
assert( track == NULL || type == track->i_type );
assert( track != NULL );
vlc_player_t *player = p_mi->player;
vlc_player_Lock(player);
if (track != NULL)
{
const libvlc_media_trackpriv_t *trackpriv =
libvlc_media_track_to_priv(track);
vlc_player_SelectEsId(player, trackpriv->es_id,
VLC_PLAYER_SELECT_EXCLUSIVE);
}
else
{
const enum es_format_category_e cat = libvlc_track_type_to_escat(type);
vlc_player_UnselectTrackCategory(player, cat);
}
const libvlc_media_trackpriv_t *trackpriv =
libvlc_media_track_to_priv(track);
vlc_player_SelectEsId(player, trackpriv->es_id,
VLC_PLAYER_SELECT_EXCLUSIVE);
vlc_player_Unlock(player);
}
void
libvlc_media_player_unselect_track_type( libvlc_media_player_t *p_mi,
libvlc_track_type_t type )
{
vlc_player_t *player = p_mi->player;
const enum es_format_category_e cat = libvlc_track_type_to_escat(type);
vlc_player_Lock(player);
vlc_player_UnselectTrackCategory(player, cat);
vlc_player_Unlock(player);
}
......
......@@ -442,7 +442,7 @@ static void test_media_player_tracks(const char** argv, int argc)
/* Select (replace) a new audio track */
libtrack = libvlc_media_player_get_track_from_id(mp, "audio/0");
assert(libtrack);
libvlc_media_player_select_track(mp, libvlc_track_audio, libtrack);
libvlc_media_player_select_track(mp, libtrack);
libvlc_media_track_release(libtrack);
atracks[0].toselect = true;
atracks[2].toselect = false;
......@@ -471,7 +471,7 @@ static void test_media_player_tracks(const char** argv, int argc)
libvlc_media_track_release(vtrack2);
/* Unselect all spu tracks */
libvlc_media_player_select_track(mp, libvlc_track_text, NULL);
libvlc_media_player_unselect_track_type(mp, libvlc_track_text);
stracks[0].toselect = stracks[1].toselect = false;
/* Check that all tracks are added and selected according to previous
......
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