lib: media_player: fix libvlc_MediaPlayerMediaChanged event
commitd57a57643447577b1493342ee0a4856a66d48e0e
authorThomas Guillem <thomas@gllm.fr>
Fri, 18 Sep 2020 12:29:32 +0000 (18 14:29 +0200)
committerThomas Guillem <thomas@gllm.fr>
Mon, 5 Oct 2020 07:15:59 +0000 (5 09:15 +0200)
tree2dc72f47496faa67765a6627ae611cf2ec734359
parent094a092e22e38895f7842433967318c3886b5c22
lib: media_player: fix libvlc_MediaPlayerMediaChanged event

- Don't override the media set by the user from
  on_current_media_changed().

- Don't create a new media from an input_item. This will prevent to send
  media events with a media pointer that is unknown to the caller.

This callback is now always sending a media that is set with
libvlc_media_player_set_media().

Since the player is now fully asynchronous, a call to set_media() +
play() will be processed asynchronously if an older media is playing.
The user might want to know when its new media is actually playing.
Listening to the libvlc_MediaPlayerMediaChanged event is only way to do so.

Here is an example:

1. set_media(A) && play()
  -> get_media() -> A
2. set_media(B) && play()
  -> get_media() -> B
3. libvlc_MediaPlayerMediaChanged(A)
  -> get_media() -> B
4. libvlc_MediaPlayerMediaChanged(B)
  -> get_media() -> B
include/vlc/libvlc_media_player.h
lib/media.c
lib/media_player.c