[vlc-devel] libvlc_MediaPlayerMediaChanged events do not fire

Mark Lee mark.lee at capricasoftware.co.uk
Sun Apr 26 19:03:20 CEST 2020


Hi,

I am trying to debug why libvlc_MediaPlayerMediaChanged events are no
longer firing when changing media (latest master).

In a typical LibVLC application I would do this:

    libvlc_media_player_set_media(mp, md);
    libvlc_media_player_play();

The libvlc_media_player_set_media() call in lib/media_player.c does this:

    p_mi->p_md = p_md; <--- the new media reference

    vlc_player_SetCurrentMedia(p_mi->player, p_md->p_input_item); <---
input item of the new media reference

At the end of libvlc_media_player_set_media(), it will call this method in
src/player/player.c:

    vlc_player_OpenNextMedia(player);

That method will itself call:

        vlc_player_SendEvent(player, on_current_media_changed,
player->media); <--- player->media is the input item of the new media
reference

Inside the on_current_media_changed() method in lib/media_player.c:

    input_item_t *media = md ? md->p_input_item : NULL; <--- media is
assigned input item of the *new* media reference, not the prior one
    if (new_media == media) <--- always evaluates to true, both of these
variables reference the input item of the new media
            /* no changes */
            return;

This problem is that the "media" variable already has the new value for the
new media, it was set right at the start via
libvlc_media_player_set_media().

So "new_media == media" always evaluates to true, the method returns early
and the event never fires.

Regards,

-M.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200426/63ad60d1/attachment.html>


More information about the vlc-devel mailing list