[vlc-devel] [PATCH] libvlc: fix "media changed" notification
Thomas Guillem
thomas at gllm.fr
Mon Apr 27 19:59:00 CEST 2020
LGTM
On Mon, Apr 27, 2020, at 18:02, Romain Vimont wrote:
> ---
>
> Thank you very much for the provided details. Here is a proposal to fix the
> reported issue (see code comments for details).
>
> (I'm not very happy with core item wrapping into LibVLC media, but it is
> necessary to keep a stable LibVLC API while the core can change.)
>
> Regards,
> Romain
>
> lib/media_player.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/lib/media_player.c b/lib/media_player.c
> index 96af310c340..65eee704f64 100644
> --- a/lib/media_player.c
> +++ b/lib/media_player.c
> @@ -872,6 +872,27 @@ void libvlc_media_player_set_media(
> }
> p_mi->p_md = p_md;
>
> + /*
> + * The input_item_t wrapped in the libvlc_media_t is set to the core player
> + * via vlc_player_SetCurrentMedia(), which notifies the
> + * libvlc_media_player_t of the change.
> + *
> + * But the notification only provides the core input_item_t instance, it
> + * may not provide the LibVLC wrapper libvlc_media_t.
> + *
> + * As a consequence, to avoid resetting p_mi->p_md by a new instance of
> + * libvlc_media_t wrapping the same input_item_t, the notification handler
> + * (on_current_media_changed) keeps the existing instance if it already
> + * wraps the expected input_item_t, and ignore the change.
> + *
> + * But the listeners registered by LibVLC client must still be notified, so
> + * send an event separately here.
> + */
> + libvlc_event_t event;
> + event.type = libvlc_MediaPlayerMediaChanged;
> + event.u.media_player_media_changed.new_media = p_md;
> + libvlc_event_send(&p_mi->event_manager, &event);
> +
> vlc_player_SetCurrentMedia(p_mi->player, p_md->p_input_item);
>
> /* The policy here is to ignore that we were created using a different
> --
> 2.26.2
>
> _______________________________________________
> 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