[vlc-commits] player: input: Store tracks presence in the ml struct

Hugo Beauzée-Luyssen git at videolan.org
Fri Sep 18 15:24:04 CEST 2020


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Sep 17 16:15:54 2020 +0200| [d9a4f71a35d8b14a1f0596916e77d56db5db4bbe] | committer: Hugo Beauzée-Luyssen

player: input: Store tracks presence in the ml struct

In order to be able to probe the media type after it is stopped and its
track vectors have been emptied.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d9a4f71a35d8b14a1f0596916e77d56db5db4bbe
---

 src/player/input.c    | 5 +++++
 src/player/medialib.c | 4 ++--
 src/player/player.h   | 5 +++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/player/input.c b/src/player/input.c
index 59b4f7345d..cf83337dc8 100644
--- a/src/player/input.c
+++ b/src/player/input.c
@@ -498,6 +498,10 @@ vlc_player_input_HandleEsEvent(struct vlc_player_input *input,
             if (!trackpriv)
                 break;
 
+            if (ev->fmt->i_cat == VIDEO_ES)
+                input->ml.has_video_tracks = true;
+            else if (ev->fmt->i_cat == AUDIO_ES)
+                input->ml.has_audio_tracks = true;
             if (!vlc_vector_push(vec, trackpriv))
             {
                 vlc_player_track_priv_Delete(trackpriv);
@@ -949,6 +953,7 @@ vlc_player_input_New(vlc_player_t *player, input_item_t *item)
     input->ml.restore_states = false;
     input->ml.delay_restore = false;
     input->ml.pos = -1.f;
+    input->ml.has_audio_tracks = input->ml.has_video_tracks = false;
 
     input->thread = input_Create(player, input_thread_Events, input, item,
                                  player->resource, player->renderer);
diff --git a/src/player/medialib.c b/src/player/medialib.c
index b4deb94e0a..93d8414632 100644
--- a/src/player/medialib.c
+++ b/src/player/medialib.c
@@ -129,9 +129,9 @@ vlc_player_UpdateMediaType(const struct vlc_player_input* input,
 {
     assert(media->i_type == VLC_ML_MEDIA_TYPE_UNKNOWN);
     vlc_ml_media_type_t media_type;
-    if (input->video_track_vector.size > 0)
+    if (input->ml.has_video_tracks)
         media_type = VLC_ML_MEDIA_TYPE_VIDEO;
-    else if (input->audio_track_vector.size > 0)
+    else if (input->ml.has_audio_tracks)
         media_type = VLC_ML_MEDIA_TYPE_AUDIO;
     else
         return false;
diff --git a/src/player/player.h b/src/player/player.h
index 363f294e12..fde4b1dbf3 100644
--- a/src/player/player.h
+++ b/src/player/player.h
@@ -117,6 +117,11 @@ struct vlc_player_input
         float pos;
         bool restore_states;
         bool delay_restore;
+        /* Keep a trace of tracks as they appear since they won't be available
+         * for probing when the input gets stopped
+         */
+        bool has_video_tracks;
+        bool has_audio_tracks;
     } ml;
 };
 



More information about the vlc-commits mailing list