[vlc-commits] media library: remove non-sensical use of spin locks
Rémi Denis-Courmont
git at videolan.org
Sat Nov 10 19:51:52 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 10 20:50:11 2012 +0200| [51a26d08767f28b2b5c75f8894195b313afe587b] | committer: Rémi Denis-Courmont
media library: remove non-sensical use of spin locks
The code is complete and utter crap either way.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=51a26d08767f28b2b5c75f8894195b313afe587b
---
include/vlc_media_library.h | 6 ------
modules/media_library/media_pool.c | 6 ------
src/misc/media_library.c | 4 ----
3 files changed, 16 deletions(-)
diff --git a/include/vlc_media_library.h b/include/vlc_media_library.h
index e183529..d86f5fa 100644
--- a/include/vlc_media_library.h
+++ b/include/vlc_media_library.h
@@ -181,7 +181,6 @@ typedef struct ml_ftree_t ml_ftree_t;
typedef struct ml_gc_object_t
{
- vlc_spinlock_t spin;
bool pool;
uintptr_t refs;
void (*pf_destructor) (struct ml_gc_object_t *);
@@ -514,9 +513,7 @@ static inline void ml_gc_incref( ml_media_t* p_media )
if( p_gc == NULL )
return;
- vlc_spin_lock (&p_gc->spin);
++p_gc->refs;
- vlc_spin_unlock (&p_gc->spin);
}
/**
@@ -532,14 +529,11 @@ static inline void ml_gc_decref( ml_media_t* p_media )
if( p_gc == NULL )
return;
- vlc_spin_lock (&p_gc->spin);
refs = --p_gc->refs;
pool = p_gc->pool;
- vlc_spin_unlock (&p_gc->spin);
if( refs == 0 && !pool )
{
- vlc_spin_destroy (&p_gc->spin);
p_gc->pf_destructor (p_gc);
}
}
diff --git a/modules/media_library/media_pool.c b/modules/media_library/media_pool.c
index 0e81320..b868d4d 100644
--- a/modules/media_library/media_pool.c
+++ b/modules/media_library/media_pool.c
@@ -66,7 +66,6 @@ int pool_InsertMedia( media_library_t* p_ml, ml_media_t* p_media, bool locked )
ml_LockMedia( p_media );
assert( p_media );
assert( p_media->i_id > 0 );
- vlc_spin_lock( &p_media->ml_gc_data.spin );
if( p_media->ml_gc_data.pool )
{
msg_Dbg( p_ml, "Already in pool! %s %d", p_media->psz_uri, p_media->i_id );
@@ -74,7 +73,6 @@ int pool_InsertMedia( media_library_t* p_ml, ml_media_t* p_media, bool locked )
return VLC_EGENERIC;
}
p_media->ml_gc_data.pool = true;
- vlc_spin_unlock( &p_media->ml_gc_data.spin );
int i_ret = VLC_SUCCESS;
vlc_mutex_lock( &p_ml->p_sys->pool_mutex );
mp_foreachlist( p_ml->p_sys->p_mediapool[ (mediapool_hash(p_media->i_id)) ], p_item )
@@ -128,18 +126,14 @@ void pool_GC( media_library_t* p_ml )
{
p_media = p_item->p_media;
int refs;
- vlc_spin_lock( &p_media->ml_gc_data.spin );
refs = p_media->ml_gc_data.refs;
- vlc_spin_unlock( &p_media->ml_gc_data.spin );
if( refs == 1 )
{
if( p_prev == NULL )
p_ml->p_sys->p_mediapool[i_idx] = p_item->p_next;
else
p_prev->p_next = p_item->p_next;
- vlc_spin_lock( &p_media->ml_gc_data.spin );
p_media->ml_gc_data.pool = false;
- vlc_spin_unlock( &p_media->ml_gc_data.spin );
ml_gc_decref( p_item->p_media );//This should destroy the object
free( p_item );
}
diff --git a/src/misc/media_library.c b/src/misc/media_library.c
index d3517bc..05e9008 100644
--- a/src/misc/media_library.c
+++ b/src/misc/media_library.c
@@ -57,10 +57,6 @@ static void *ml_gc_init (ml_gc_object_t *p_gc, void (*pf_destruct) (ml_gc_object
p_gc->pool = false;
p_gc->refs = 1;
- /* Nobody else can possibly lock the spin - it's there as a barrier */
- vlc_spin_init (&p_gc->spin);
- vlc_spin_lock (&p_gc->spin);
- vlc_spin_unlock (&p_gc->spin);
return p_gc;
}
More information about the vlc-commits
mailing list