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

Rémi Denis-Courmont remi at remlab.net
Thu Jan 16 15:55:06 CET 2020


Hi,

It's certainly useful to be able to disable tracks but I don't think that choice should be listed as a track per se.

Le 16 janvier 2020 16:02:48 GMT+02:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>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

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200116/266a88d6/attachment.html>


More information about the vlc-devel mailing list