[vlc-devel] [PATCH 02/21] libvlc: include other selected tracks(if any) in osd_message when unselecting an es
Thomas Guillem
thomas at gllm.fr
Mon Oct 26 10:33:48 CET 2020
Hello,
libvlc code is in lib/, vlccore is in src/
This is not a libvlc patch. Just put "player: " as a commit prefix.
On Fri, Oct 23, 2020, at 15:20, Prince Gupta wrote:
> ---
> 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 );
You can return here. vlc_player_GetEsIdList() fails in case or error alloc or if there is not tracks. Nothing you can do if it happens.
> + 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"));
> + }
This should be moved in a new functions: vlc_player_osd_Tracks().
> + }
> }
>
> void
> --
> 2.25.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list