[vlc-devel] [PATCH] Set the media descriptor on the MediaListPlayerNextItemSet event.

Mark Lee mark.lee at capricasoftware.co.uk
Mon May 7 22:12:05 CEST 2012


Hello Rémi,

The p_md reference is obtained by this new line of code (I put this inside
the play-list lock earlier in the same method):

+    libvlc_media_t* p_md = libvlc_media_list_item_at_path(p_mlp->p_mlist,
path);

To answer your question, no, there was no leak before.

I think p_md probably can not be NULL in this code but I added some
defensive code anyway.

My Java bindings depend on this media descriptor being set properly on the
event, and this patch fixes that issue for me.

I'm not sure my email client is configured properly for git email so
apologies if this creates a new disconnected thread.

Regards,

-M.

On 7 May 2012 20:45, Mark Lee <mark.lee at capricasoftware.co.uk> wrote:

> ---
>  lib/media_list_player.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/lib/media_list_player.c b/lib/media_list_player.c
> index 7522e5e..09109c7 100644
> --- a/lib/media_list_player.c
> +++ b/lib/media_list_player.c
> @@ -646,14 +646,21 @@
> libvlc_media_list_player_get_state(libvlc_media_list_player_t * p_mlp)
>  int
> libvlc_media_list_player_play_item_at_index(libvlc_media_list_player_t *
> p_mlp, int i_index)
>  {
>     lock(p_mlp);
> -    set_current_playing_item(p_mlp,
> libvlc_media_list_path_with_root_index(i_index));
> +    libvlc_media_list_path_t path =
> libvlc_media_list_path_with_root_index(i_index);
> +    set_current_playing_item(p_mlp, path);
>     libvlc_media_player_play(p_mlp->p_mi);
> +    libvlc_media_t* p_md = libvlc_media_list_item_at_path(p_mlp->p_mlist,
> path);
>     unlock(p_mlp);
>
>     /* Send the next item event */
>     libvlc_event_t event;
>     event.type = libvlc_MediaListPlayerNextItemSet;
> +    event.u.media_list_player_next_item_set.item = p_md;
>     libvlc_event_send(p_mlp->p_event_manager, &event);
> +
> +    if (p_md)
> +        libvlc_media_release(p_md);
> +
>     return 0;
>  }
>
> --
> 1.7.9.5
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120507/f24b7b9a/attachment.html>


More information about the vlc-devel mailing list