Commit 25698d34 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont Committed by Rémi Denis-Courmont

libvlc: Use a separate lock for media_list_lock and refcounting.

Those finer grained locks help the media_list_player.
(cherry picked from commit 6dbf7ce4)
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent ac3acc83
......@@ -90,6 +90,7 @@ struct libvlc_media_list_t
libvlc_instance_t * p_libvlc_instance;
int i_refcount;
vlc_mutex_t object_lock;
vlc_mutex_t refcount_lock;
libvlc_media_t * p_md; /* The media from which the
* mlist comes, if any. */
vlc_array_t items;
......
......@@ -170,6 +170,7 @@ libvlc_media_list_new( libvlc_instance_t * p_inst,
}
vlc_mutex_init( &p_mlist->object_lock );
vlc_mutex_init( &p_mlist->refcount_lock ); // FIXME: spinlock?
vlc_array_init( &p_mlist->items );
p_mlist->i_refcount = 1;
......@@ -188,14 +189,14 @@ void libvlc_media_list_release( libvlc_media_list_t * p_mlist )
libvlc_media_t * p_md;
int i;
vlc_mutex_lock( &p_mlist->object_lock );
vlc_mutex_lock( &p_mlist->refcount_lock );
p_mlist->i_refcount--;
if( p_mlist->i_refcount > 0 )
{
vlc_mutex_unlock( &p_mlist->object_lock );
vlc_mutex_unlock( &p_mlist->refcount_lock );
return;
}
vlc_mutex_unlock( &p_mlist->object_lock );
vlc_mutex_unlock( &p_mlist->refcount_lock );
/* Refcount null, time to free */
......@@ -223,9 +224,9 @@ void libvlc_media_list_release( libvlc_media_list_t * p_mlist )
**************************************************************************/
void libvlc_media_list_retain( libvlc_media_list_t * p_mlist )
{
vlc_mutex_lock( &p_mlist->object_lock );
vlc_mutex_lock( &p_mlist->refcount_lock );
p_mlist->i_refcount++;
vlc_mutex_unlock( &p_mlist->object_lock );
vlc_mutex_unlock( &p_mlist->refcount_lock );
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment