[vlc-devel] [PATCH] lib: player: add back disabled tracks

Alexandre Janniaux ajanni at videolabs.io
Thu Jan 16 16:08:57 CET 2020


Hi,

I agree against the backward compatibility choice,
otherwise we might want to change the function naming to
enforce this change.

It doesn't feel urgent to change this behaviour for VLC 4.0.

Regards,
--
Alexandre Janniaux
Videolabs

On Thu, Jan 16, 2020 at 03:02:48PM +0100, Thomas Guillem wrote:
> Regression from vlc_player.h port. libvlc_media_player expose the "disable"
> track. A -1 id is still a good choice to disable a track, cf
> src/input/es_out.c, a valid i_id can't be negative.
> ---
>  lib/audio.c        |  7 +++++++
>  lib/media_player.c | 18 ++++++++++++++++--
>  lib/video.c        | 14 ++++++++++++++
>  3 files changed, 37 insertions(+), 2 deletions(-)
>
> diff --git a/lib/audio.c b/lib/audio.c
> index aab84cd47a9..8222300707d 100644
> --- a/lib/audio.c
> +++ b/lib/audio.c
> @@ -375,6 +375,13 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
>      vlc_player_t *player = p_mi->player;
>      vlc_player_Lock(player);
>
> +    if (i_track < 0)
> +    {
> +        vlc_player_UnselectTrackCategory(player, AUDIO_ES);
> +        i_ret = 0;
> +        goto end;
> +    }
> +
>      size_t count = vlc_player_GetAudioTrackCount(player);
>      for( size_t i = 0; i < count; i++ )
>      {
> diff --git a/lib/media_player.c b/lib/media_player.c
> index cdb6ba0b8c5..e21ab5c1998 100644
> --- a/lib/media_player.c
> +++ b/lib/media_player.c
> @@ -1671,14 +1671,28 @@ libvlc_track_description_t *
>                                        enum es_format_category_e cat )
>  {
>      vlc_player_t *player = p_mi->player;
> -    vlc_player_Lock(player);
>
>      libvlc_track_description_t *ret, **pp = &ret;
>
> +    /* Add the "Disable" track */
> +    libvlc_track_description_t *tr = malloc(sizeof (*tr));
> +    if (unlikely(tr == NULL))
> +        return NULL;
> +    tr->i_id = -1;
> +    tr->psz_name = strdup(_("Disable"));
> +    if (unlikely(!tr->psz_name))
> +    {
> +        free(tr);
> +        return NULL;
> +    }
> +    *pp = tr;
> +    pp = &tr->p_next;
> +
> +    vlc_player_Lock(player);
>      size_t count = vlc_player_GetTrackCount(player, cat);
>      for (size_t i = 0; i < count; i++)
>      {
> -        libvlc_track_description_t *tr = malloc(sizeof (*tr));
> +        tr = malloc(sizeof (*tr));
>          if (unlikely(tr == NULL))
>          {
>              libvlc_printerr("Not enough memory");
> diff --git a/lib/video.c b/lib/video.c
> index 6f8e6d7f59a..9772945a958 100644
> --- a/lib/video.c
> +++ b/lib/video.c
> @@ -317,6 +317,13 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
>      vlc_player_t *player = p_mi->player;
>      vlc_player_Lock(player);
>
> +    if (i_spu < 0)
> +    {
> +        vlc_player_UnselectTrackCategory(player, SPU_ES);
> +        i_ret = 0;
> +        goto end;
> +    }
> +
>      size_t count = vlc_player_GetSubtitleTrackCount(player);
>      for (size_t i = 0; i < count; i++)
>      {
> @@ -488,6 +495,13 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
>      vlc_player_t *player = p_mi->player;
>      vlc_player_Lock(player);
>
> +    if (i_track < 0)
> +    {
> +        vlc_player_UnselectTrackCategory(player, VIDEO_ES);
> +        i_ret = 0;
> +        goto end;
> +    }
> +
>      size_t count = vlc_player_GetVideoTrackCount(player);
>      for( size_t i = 0; i < count; i++ )
>      {
> --
> 2.20.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