[vlc-devel] [PATCH 4/5] player: add support for program pre-selection
Thomas Guillem
thomas at gllm.fr
Mon Feb 1 15:52:24 UTC 2021
And don't check for program existence before selecting it.
---
include/vlc_player.h | 9 ++++++++-
src/player/player.c | 9 +++------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/include/vlc_player.h b/include/vlc_player.h
index 601605de86..0d1545df82 100644
--- a/include/vlc_player.h
+++ b/include/vlc_player.h
@@ -1244,6 +1244,13 @@ vlc_player_GetProgram(vlc_player_t *player, int group_id);
/**
* Select a program from an ES group identifier
*
+ * This function can be used to pre-select a program by its id before starting
+ * the player. It has only effect for the current media. It can also be used
+ * when the player is already started.
+ *
+ * @note Selecting a non-existing program will cause the player to no select
+ * any programs. Therefore, all tracks will be disabled.
+ *
* @param player locked player instance
* @param group_id a program ID (retrieved from
* vlc_player_cbs.on_program_list_changed or vlc_player_GetProgramAt())
@@ -1519,7 +1526,7 @@ vlc_player_GetSelectedTrack(vlc_player_t *player, enum es_format_category_e cat)
/**
* Select tracks by their string identifier
*
- * This function can be used pre-select a list of tracks before starting the
+ * This function can be used to pre-select a list of tracks before starting the
* player. It has only effect for the current media. It can also be used when
* the player is already started.
diff --git a/src/player/player.c b/src/player/player.c
index c4ba5b120d..688a577701 100644
--- a/src/player/player.c
+++ b/src/player/player.c
@@ -295,15 +295,12 @@ vlc_player_SelectProgram(vlc_player_t *player, int id)
if (!input)
return;
+ input_SetProgramId(input->thread, id);
+
const struct vlc_player_program *prgm =
vlc_player_program_vector_FindById(&input->program_vector,
id, NULL);
- if (!prgm)
- return;
- int ret = input_ControlPushHelper(input->thread,
- INPUT_CONTROL_SET_PROGRAM,
- &(vlc_value_t) { .i_int = id });
- if (ret == VLC_SUCCESS)
+ if (prgm != NULL)
vlc_player_osd_Program(player, prgm->name);
}
--
2.29.2
More information about the vlc-devel
mailing list