[vlc-devel] commit: libvlc: Use a separate lock for media_list_lock and refcounting. ( Pierre d'Herbemont )
git version control
git at videolan.org
Thu May 21 08:35:04 CEST 2009
vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Wed May 20 23:19:35 2009 -0700| [6dbf7ce48289298f21f56e2e77b95f221641a38f] | committer: Pierre d'Herbemont
libvlc: Use a separate lock for media_list_lock and refcounting.
Those finer grained locks help the media_list_player.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6dbf7ce48289298f21f56e2e77b95f221641a38f
---
src/control/libvlc_internal.h | 1 +
src/control/media_list.c | 11 ++++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/control/libvlc_internal.h b/src/control/libvlc_internal.h
index 2079d50..ada07d0 100644
--- a/src/control/libvlc_internal.h
+++ b/src/control/libvlc_internal.h
@@ -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;
diff --git a/src/control/media_list.c b/src/control/media_list.c
index 75389c6..e8ae52b 100644
--- a/src/control/media_list.c
+++ b/src/control/media_list.c
@@ -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 */
@@ -222,9 +223,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 );
}
More information about the vlc-devel
mailing list