[vlc-devel] [PATCH 02/21] libvlc: include other selected tracks(if any) in osd_message when unselecting an es
Prince Gupta
guptaprince8832 at gmail.com
Fri Oct 23 15:20:56 CEST 2020
---
src/player/player.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/player/player.c b/src/player/player.c
index 669df87649..4ca7332516 100644
--- a/src/player/player.c
+++ b/src/player/player.c
@@ -701,8 +701,44 @@ vlc_player_UnselectEsId(vlc_player_t *player, vlc_es_id_t *id)
int ret = input_ControlPushEsHelper(input->thread, INPUT_CONTROL_UNSET_ES,
id);
- if (ret == VLC_SUCCESS)
- vlc_player_osd_Track(player, id, false);
+ if ( ret != VLC_SUCCESS )
+ return;
+
+ const enum es_format_category_e cat = vlc_es_id_GetCat( id );
+ vlc_es_id_t ** selectedEs = vlc_player_GetEsIdList( player, cat, NULL );
+ if ( !selectedEs )
+ vlc_player_osd_Track( player, id, false );
+ else
+ {
+ struct vlc_memstream stream;
+ const char *cat_name = es_format_category_to_string(cat);
+ int tracks_count = 0;
+ vlc_memstream_open(&stream);
+ for (size_t i = 0; selectedEs[i] != NULL; i++)
+ {
+ if ( !strcmp(vlc_es_id_GetStrId(selectedEs[i]), vlc_es_id_GetStrId(id)) )
+ continue;
+
+ const struct vlc_player_track *track =
+ vlc_player_GetTrack(player, selectedEs[i]);
+
+ if ( track )
+ {
+ if (i != 0)
+ vlc_memstream_puts(&stream, ", ");
+ vlc_memstream_puts(&stream, track->name);
+ tracks_count++;
+ }
+ }
+ if (vlc_memstream_close(&stream) == 0 && tracks_count != 0)
+ {
+ vlc_player_osd_Message(player, _("%s tracks: %s"), cat_name,
+ stream.ptr);
+ free(stream.ptr);
+ } else if (tracks_count == 0) {
+ vlc_player_osd_Message(player, _("%s track: %s"), cat_name, _("N/A"));
+ }
+ }
}
void
--
2.25.1
More information about the vlc-devel
mailing list