Commit de9d74a6 authored by zorglub's avatar zorglub

Don't loop preparse threads when idle

Compile fix
parent a0cbc6ed
......@@ -123,7 +123,7 @@ static int FindMeta( vlc_object_t *p_this )
free( psz_dir );
}
i_meta = input_GetMetaEngineFlags( p_item->p_meta );
i_meta = input_CurrentMetaFlags( p_item->p_meta );
p_me->i_mandatory &= ~i_meta;
p_me->i_optional &= ~i_meta;
if( p_me->i_mandatory )
......
......@@ -132,7 +132,7 @@ static int FindMeta( vlc_object_t *p_this )
mb_Delete( p_mb );
i_meta = input_GetMetaEngineFlags( p_item->p_meta );
i_meta = input_CurrentMetaFlags( p_item->p_meta );
p_me->i_mandatory &= ~i_meta;
p_me->i_optional &= ~i_meta;
if( p_me->i_mandatory )
......
......@@ -198,6 +198,7 @@ int playlist_PreparseEnqueue( playlist_t *p_playlist,
p_playlist->p_preparse->i_waiting,
p_item );
vlc_mutex_unlock( &p_playlist->p_preparse->object_lock );
vlc_cond_signal( &p_playlist->p_preparse->object_wait );
return VLC_SUCCESS;
}
......@@ -229,9 +230,9 @@ int playlist_AskForArtEnqueue( playlist_t *p_playlist,
vlc_gc_incref( p_item );
INSERT_ELEM( p_playlist->p_secondary_preparse->p_waiting,
p_playlist->p_secondary_preparse->i_waiting,
i,
p );
i, p );
vlc_mutex_unlock( &p_playlist->p_secondary_preparse->object_lock );
vlc_cond_signal( &p_playlist->p_secondary_preparse->object_lock );
return VLC_SUCCESS;
}
......
......@@ -446,16 +446,27 @@ void playlist_LastLoop( playlist_t *p_playlist )
void playlist_PreparseLoop( playlist_preparse_t *p_obj )
{
playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
input_item_t *p_current;
int i_activity;
uint32_t i_m, i_o;
vlc_mutex_lock( &p_obj->object_lock );
if( p_obj->i_waiting > 0 )
while( !p_playlist->b_die )
{
input_item_t *p_current = p_obj->pp_waiting[0];
vlc_mutex_lock( &p_obj->object_lock );
while( p_obj->i_waiting == 0 )
{
vlc_cond_wait( &p_obj->object_wait, &p_obj->object_lock );
if( p_playlist->b_die )
{
vlc_mutex_unlock( &p_obj->object_lock );
return;
}
}
p_current = p_obj->pp_waiting[0];
REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
vlc_mutex_unlock( &p_obj->object_lock );
PL_LOCK;
if( p_current )
{
......@@ -484,6 +495,7 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
var_SetInteger( p_playlist, "item-change", p_current->i_id );
}
PL_LOCK;
/* If we haven't retrieved enough meta, add to secondary queue
* which will run the "meta fetchers"
* TODO:
......@@ -503,6 +515,8 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
p );
vlc_mutex_unlock(
&p_playlist->p_secondary_preparse->object_lock);
vlc_cond_signal(
&p_playlist->p_secondary_preparse->object_wait );
}
else
vlc_gc_decref( p_current );
......@@ -515,23 +529,34 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
i_activity = var_GetInteger( p_playlist, "activity" );
if( i_activity < 0 ) i_activity = 0;
vlc_mutex_unlock( &p_obj->object_lock );
/* Sleep at least 1ms */
msleep( (i_activity+1) * 1000 );
return;
}
vlc_mutex_unlock( &p_obj->object_lock );
}
/** Main loop for secondary preparser queue */
void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj )
{
playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
vlc_bool_t b_fetch_art;
input_item_t *p_item;
int i_activity;
vlc_mutex_lock( &p_obj->object_lock );
if( p_obj->i_waiting > 0 )
while( !p_playlist->b_die )
{
vlc_bool_t b_fetch_art = p_obj->p_waiting->b_fetch_art;
input_item_t *p_item = p_obj->p_waiting->p_item;
vlc_mutex_lock( &p_obj->object_lock );
while( p_obj->i_waiting == 0 )
{
vlc_cond_wait( &p_obj->object_wait, &p_obj->object_lock );
if( p_playlist->b_die )
{
vlc_mutex_unlock( &p_obj->object_lock );
return;
}
}
b_fetch_art = p_obj->p_waiting->b_fetch_art;
p_item = p_obj->p_waiting->p_item;
REMOVE_ELEM( p_obj->p_waiting, p_obj->i_waiting, 0 );
vlc_mutex_unlock( &p_obj->object_lock );
if( p_item )
......@@ -549,9 +574,13 @@ void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj )
var_SetInteger( p_playlist, "item-change", p_item->i_id );
vlc_gc_decref( p_item );
}
return;
vlc_mutex_lock( &p_obj->object_lock );
i_activity = var_GetInteger( p_playlist, "activity" );
if( i_activity < 0 ) i_activity = 0;
vlc_mutex_unlock( &p_obj->object_lock );
/* Sleep at least 1ms */
msleep( (i_activity+1) * 1000 );
}
vlc_mutex_unlock( &p_obj->object_lock );
}
static void VariablesInit( playlist_t *p_playlist )
......
......@@ -142,7 +142,11 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent )
*/
int playlist_ThreadDestroy( playlist_t * p_playlist )
{
p_playlist->b_die = 1;
p_playlist->b_die = VLC_TRUE;
if( p_playlist->p_preparse )
vlc_cond_signal( &p_playlist->p_preparse->object_wait );
if( p_playlist->p_secondary_preparse )
vlc_cond_signal( &p_playlist->p_secondary_preparse->object_wait );
DestroyInteraction( p_playlist );
DestroyPlaylist( p_playlist );
......@@ -208,14 +212,7 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
/* Tell above that we're ready */
vlc_thread_ready( p_obj );
while( !p_playlist->b_die )
{
playlist_PreparseLoop( p_obj );
if( p_obj->i_waiting == 0 )
{
msleep( INTF_IDLE_SLEEP );
}
}
playlist_PreparseLoop( p_obj );
}
static void RunSecondaryPreparse( playlist_secondary_preparse_t *p_obj )
......@@ -224,14 +221,7 @@ static void RunSecondaryPreparse( playlist_secondary_preparse_t *p_obj )
/* Tell above that we're ready */
vlc_thread_ready( p_obj );
while( !p_playlist->b_die )
{
playlist_SecondaryPreparseLoop( p_obj );
if( p_obj->i_waiting == 0 )
{
msleep( INTF_IDLE_SLEEP );
}
}
playlist_SecondaryPreparseLoop( p_obj );
}
/*****************************************************************************
......
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