Don't call libvlc_media_list_set_media from media since it causes
p_md->p_subitems to retain p_md while p_md is already retaining
p_md->p_subitems, therefore these 2 objects won't be releasable.
Add a new internal variable: p_internal_md that is set from media without
retaining it.
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
if( p_md->p_subitems != NULL )
{
p_md->p_subitems->b_read_only = true;
- libvlc_media_list_set_media( p_md->p_subitems, p_md );
+ p_md->p_subitems->p_internal_md = p_md;
}
}
p_subitems = p_md->p_subitems;
assert( p_mlist->items.i_count == 0 );
p_mlist->i_refcount = 1;
p_mlist->p_md = NULL;
+ p_mlist->p_internal_md = NULL;
return p_mlist;
}
{
vlc_mutex_lock( &p_mlist->object_lock );
+ if( p_mlist->p_internal_md )
+ {
+ vlc_mutex_unlock( &p_mlist->object_lock );
+ return;
+ }
libvlc_media_release( p_mlist->p_md );
libvlc_media_retain( p_md );
p_mlist->p_md = p_md;
libvlc_media_t *p_md;
vlc_mutex_lock( &p_mlist->object_lock );
- p_md = p_mlist->p_md;
+ p_md = p_mlist->p_internal_md ? p_mlist->p_internal_md : p_mlist->p_md;
if( p_md )
libvlc_media_retain( p_md );
vlc_mutex_unlock( &p_mlist->object_lock );
vlc_mutex_t refcount_lock;
libvlc_media_t * p_md; /* The media from which the
* mlist comes, if any. */
+ libvlc_media_t * p_internal_md; /* media set from media.c */
vlc_array_t items;
/* This indicates if this media list is read-only