Commit 51a26d08 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

media library: remove non-sensical use of spin locks

The code is complete and utter crap either way.
parent b287bd3d
......@@ -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);
}
}
......
......@@ -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 );
}
......
......@@ -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;
}
......
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