Commit 31d471de authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

preparser: use vlc_object_t instead of playlist_t

parent f6671b3e
...@@ -239,16 +239,12 @@ playlist_t * playlist_Create( vlc_object_t *p_parent ) ...@@ -239,16 +239,12 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
/* Fetcher */ /* Fetcher */
p->p_fetcher = playlist_fetcher_New( VLC_OBJECT(p_playlist) ); p->p_fetcher = playlist_fetcher_New( VLC_OBJECT(p_playlist) );
if( unlikely(p->p_fetcher == NULL) ) if( unlikely(p->p_fetcher == NULL) )
{
msg_Err( p_playlist, "cannot create fetcher" ); msg_Err( p_playlist, "cannot create fetcher" );
p->p_preparser = NULL; /* Preparser */
} p->p_preparser = playlist_preparser_New( VLC_OBJECT(p_playlist),
else p->p_fetcher );
{ /* Preparse */ if( unlikely(p->p_preparser == NULL) )
p->p_preparser = playlist_preparser_New( p_playlist, p->p_fetcher ); msg_Err( p_playlist, "cannot create preparser" );
if( unlikely(p->p_preparser == NULL) )
msg_Err( p_playlist, "cannot create preparser" );
}
/* Create the root node */ /* Create the root node */
PL_LOCK; PL_LOCK;
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
*****************************************************************************/ *****************************************************************************/
struct playlist_preparser_t struct playlist_preparser_t
{ {
playlist_t *p_playlist; vlc_object_t *object;
playlist_fetcher_t *p_fetcher; playlist_fetcher_t *p_fetcher;
vlc_mutex_t lock; vlc_mutex_t lock;
...@@ -56,18 +56,19 @@ static void *Thread( void * ); ...@@ -56,18 +56,19 @@ static void *Thread( void * );
/***************************************************************************** /*****************************************************************************
* Public functions * Public functions
*****************************************************************************/ *****************************************************************************/
playlist_preparser_t *playlist_preparser_New( playlist_t *p_playlist, playlist_fetcher_t *p_fetcher ) playlist_preparser_t *playlist_preparser_New( vlc_object_t *parent,
playlist_fetcher_t *p_fetcher )
{ {
playlist_preparser_t *p_preparser = malloc( sizeof(*p_preparser) ); playlist_preparser_t *p_preparser = malloc( sizeof(*p_preparser) );
if( !p_preparser ) if( !p_preparser )
return NULL; return NULL;
p_preparser->p_playlist = p_playlist; p_preparser->object = parent;
p_preparser->p_fetcher = p_fetcher; p_preparser->p_fetcher = p_fetcher;
vlc_mutex_init( &p_preparser->lock ); vlc_mutex_init( &p_preparser->lock );
vlc_cond_init( &p_preparser->wait ); vlc_cond_init( &p_preparser->wait );
p_preparser->b_live = false; p_preparser->b_live = false;
p_preparser->i_art_policy = var_GetInteger( p_playlist, "album-art" ); p_preparser->i_art_policy = var_InheritInteger( parent, "album-art" );
p_preparser->i_waiting = 0; p_preparser->i_waiting = 0;
p_preparser->pp_waiting = NULL; p_preparser->pp_waiting = NULL;
...@@ -85,8 +86,7 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p ...@@ -85,8 +86,7 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p
{ {
if( vlc_clone_detach( NULL, Thread, p_preparser, if( vlc_clone_detach( NULL, Thread, p_preparser,
VLC_THREAD_PRIORITY_LOW ) ) VLC_THREAD_PRIORITY_LOW ) )
msg_Warn( p_preparser->p_playlist, msg_Warn( p_preparser->object, "cannot spawn pre-parser thread" );
"cannot spawn pre-parser thread" );
else else
p_preparser->b_live = true; p_preparser->b_live = true;
} }
...@@ -119,7 +119,7 @@ void playlist_preparser_Delete( playlist_preparser_t *p_preparser ) ...@@ -119,7 +119,7 @@ void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
/** /**
* This function preparses an item when needed. * This function preparses an item when needed.
*/ */
static void Preparse( playlist_t *p_playlist, input_item_t *p_item ) static void Preparse( vlc_object_t *obj, input_item_t *p_item )
{ {
vlc_mutex_lock( &p_item->lock ); vlc_mutex_lock( &p_item->lock );
int i_type = p_item->i_type; int i_type = p_item->i_type;
...@@ -134,10 +134,10 @@ static void Preparse( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -134,10 +134,10 @@ static void Preparse( playlist_t *p_playlist, input_item_t *p_item )
/* Do not preparse if it is already done (like by playing it) */ /* Do not preparse if it is already done (like by playing it) */
if( !input_item_IsPreparsed( p_item ) ) if( !input_item_IsPreparsed( p_item ) )
{ {
input_Preparse( VLC_OBJECT(p_playlist), p_item ); input_Preparse( obj, p_item );
input_item_SetPreparsed( p_item, true ); input_item_SetPreparsed( p_item, true );
var_SetAddress( p_playlist, "item-change", p_item ); var_SetAddress( obj, "item-change", p_item );
} }
} }
...@@ -146,7 +146,7 @@ static void Preparse( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -146,7 +146,7 @@ static void Preparse( playlist_t *p_playlist, input_item_t *p_item )
*/ */
static void Art( playlist_preparser_t *p_preparser, input_item_t *p_item ) static void Art( playlist_preparser_t *p_preparser, input_item_t *p_item )
{ {
playlist_t *p_playlist = p_preparser->p_playlist; vlc_object_t *obj = p_preparser->object;
playlist_fetcher_t *p_fetcher = p_preparser->p_fetcher; playlist_fetcher_t *p_fetcher = p_preparser->p_fetcher;
bool b_fetch = false; bool b_fetch = false;
...@@ -167,13 +167,13 @@ static void Art( playlist_preparser_t *p_preparser, input_item_t *p_item ) ...@@ -167,13 +167,13 @@ static void Art( playlist_preparser_t *p_preparser, input_item_t *p_item )
( strncmp( psz_arturl, "file://", 7 ) && ( strncmp( psz_arturl, "file://", 7 ) &&
strncmp( psz_arturl, "attachment://", 13 ) ) ) ) strncmp( psz_arturl, "attachment://", 13 ) ) ) )
{ {
msg_Dbg( p_playlist, "meta ok for %s, need to fetch art", msg_Dbg( obj, "meta ok for %s, need to fetch art",
psz_name ? psz_name : "(null)" ); psz_name ? psz_name : "(null)" );
b_fetch = true; b_fetch = true;
} }
else else
{ {
msg_Dbg( p_playlist, "no fetch required for %s (art currently %s)", msg_Dbg( obj, "no fetch required for %s (art currently %s)",
psz_name ? psz_name : "(null)", psz_name ? psz_name : "(null)",
psz_arturl ? psz_arturl : "(null)" ); psz_arturl ? psz_arturl : "(null)" );
} }
...@@ -190,7 +190,7 @@ static void Art( playlist_preparser_t *p_preparser, input_item_t *p_item ) ...@@ -190,7 +190,7 @@ static void Art( playlist_preparser_t *p_preparser, input_item_t *p_item )
static void *Thread( void *data ) static void *Thread( void *data )
{ {
playlist_preparser_t *p_preparser = data; playlist_preparser_t *p_preparser = data;
playlist_t *p_playlist = p_preparser->p_playlist; vlc_object_t *obj = p_preparser->object;
for( ;; ) for( ;; )
{ {
...@@ -214,7 +214,7 @@ static void *Thread( void *data ) ...@@ -214,7 +214,7 @@ static void *Thread( void *data )
if( !p_current ) if( !p_current )
break; break;
Preparse( p_playlist, p_current ); Preparse( obj, p_current );
Art( p_preparser, p_current ); Art( p_preparser, p_current );
vlc_gc_decref(p_current); vlc_gc_decref(p_current);
......
...@@ -37,7 +37,8 @@ typedef struct playlist_preparser_t playlist_preparser_t; ...@@ -37,7 +37,8 @@ typedef struct playlist_preparser_t playlist_preparser_t;
/** /**
* This function creates the preparser object and thread. * This function creates the preparser object and thread.
*/ */
playlist_preparser_t *playlist_preparser_New( playlist_t *, playlist_fetcher_t * ); playlist_preparser_t *playlist_preparser_New( vlc_object_t *,
playlist_fetcher_t * );
/** /**
* This function enqueues the provided item to be preparsed. * This function enqueues the provided item to be preparsed.
......
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