Commit 99a19a8f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

playlist: hide fetcher underneath the preparser and simplify

parent 804defcc
...@@ -179,9 +179,8 @@ int playlist_AskForArtEnqueue( playlist_t *p_playlist, input_item_t *p_item ) ...@@ -179,9 +179,8 @@ int playlist_AskForArtEnqueue( playlist_t *p_playlist, input_item_t *p_item )
{ {
playlist_private_t *p_sys = pl_priv(p_playlist); playlist_private_t *p_sys = pl_priv(p_playlist);
if( unlikely(p_sys->p_fetcher == NULL) ) if( unlikely(p_sys->p_preparser == NULL) )
return VLC_ENOMEM; return VLC_ENOMEM;
playlist_fetcher_Push( p_sys->p_fetcher, p_item ); playlist_preparser_fetcher_Push( p_sys->p_preparser, p_item );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -233,13 +233,8 @@ static playlist_t *playlist_Create( vlc_object_t *p_parent ) ...@@ -233,13 +233,8 @@ static playlist_t *playlist_Create( vlc_object_t *p_parent )
pl_priv(p_playlist)->b_auto_preparse = pl_priv(p_playlist)->b_auto_preparse =
var_InheritBool( p_parent, "auto-preparse" ); var_InheritBool( p_parent, "auto-preparse" );
/* Fetcher */ /* Preparser (and meta retriever) */
p->p_fetcher = playlist_fetcher_New( VLC_OBJECT(p_playlist) ); p->p_preparser = playlist_preparser_New( VLC_OBJECT(p_playlist) );
if( unlikely(p->p_fetcher == NULL) )
msg_Err( p_playlist, "cannot create fetcher" );
/* Preparser */
p->p_preparser = playlist_preparser_New( VLC_OBJECT(p_playlist),
p->p_fetcher );
if( unlikely(p->p_preparser == NULL) ) if( unlikely(p->p_preparser == NULL) )
msg_Err( p_playlist, "cannot create preparser" ); msg_Err( p_playlist, "cannot create preparser" );
...@@ -341,8 +336,6 @@ void playlist_Destroy( playlist_t *p_playlist ) ...@@ -341,8 +336,6 @@ void playlist_Destroy( playlist_t *p_playlist )
playlist_Deactivate( p_playlist ); playlist_Deactivate( p_playlist );
if( p_sys->p_preparser ) if( p_sys->p_preparser )
playlist_preparser_Delete( p_sys->p_preparser ); playlist_preparser_Delete( p_sys->p_preparser );
if( p_sys->p_fetcher )
playlist_fetcher_Delete( p_sys->p_fetcher );
/* Release input resources */ /* Release input resources */
assert( p_sys->p_input == NULL ); assert( p_sys->p_input == NULL );
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <assert.h> #include <assert.h>
#include "art.h" #include "art.h"
#include "fetcher.h"
#include "preparser.h" #include "preparser.h"
typedef struct vlc_sd_internal_t vlc_sd_internal_t; typedef struct vlc_sd_internal_t vlc_sd_internal_t;
...@@ -47,7 +46,6 @@ typedef struct playlist_private_t ...@@ -47,7 +46,6 @@ typedef struct playlist_private_t
{ {
playlist_t public_data; playlist_t public_data;
playlist_preparser_t *p_preparser; /**< Preparser data */ playlist_preparser_t *p_preparser; /**< Preparser data */
playlist_fetcher_t *p_fetcher; /**< Meta and art fetcher data */
playlist_item_array_t items_to_delete; /**< Array of items and nodes to playlist_item_array_t items_to_delete; /**< Array of items and nodes to
delete... At the very end. This sucks. */ delete... At the very end. This sucks. */
......
...@@ -56,15 +56,17 @@ static void *Thread( void * ); ...@@ -56,15 +56,17 @@ static void *Thread( void * );
/***************************************************************************** /*****************************************************************************
* Public functions * Public functions
*****************************************************************************/ *****************************************************************************/
playlist_preparser_t *playlist_preparser_New( vlc_object_t *parent, 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->object = parent; p_preparser->object = parent;
p_preparser->p_fetcher = p_fetcher; p_preparser->p_fetcher = playlist_fetcher_New( parent );
if( unlikely(p_preparser->p_fetcher == NULL) )
msg_Err( parent, "cannot create 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;
...@@ -93,6 +95,13 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p ...@@ -93,6 +95,13 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p
vlc_mutex_unlock( &p_preparser->lock ); vlc_mutex_unlock( &p_preparser->lock );
} }
void playlist_preparser_fetcher_Push( playlist_preparser_t *p_preparser,
input_item_t *p_item )
{
if( p_preparser->p_fetcher != NULL )
playlist_fetcher_Push( p_preparser->p_fetcher, p_item );
}
void playlist_preparser_Delete( playlist_preparser_t *p_preparser ) void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
{ {
vlc_mutex_lock( &p_preparser->lock ); vlc_mutex_lock( &p_preparser->lock );
...@@ -110,6 +119,9 @@ void playlist_preparser_Delete( playlist_preparser_t *p_preparser ) ...@@ -110,6 +119,9 @@ void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
/* Destroy the item preparser */ /* Destroy the item preparser */
vlc_cond_destroy( &p_preparser->wait ); vlc_cond_destroy( &p_preparser->wait );
vlc_mutex_destroy( &p_preparser->lock ); vlc_mutex_destroy( &p_preparser->lock );
if( p_preparser->p_fetcher != NULL )
playlist_fetcher_Delete( p_preparser->p_fetcher );
free( p_preparser ); free( p_preparser );
} }
......
...@@ -37,8 +37,7 @@ typedef struct playlist_preparser_t playlist_preparser_t; ...@@ -37,8 +37,7 @@ 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( vlc_object_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.
...@@ -48,6 +47,8 @@ playlist_preparser_t *playlist_preparser_New( vlc_object_t *, ...@@ -48,6 +47,8 @@ playlist_preparser_t *playlist_preparser_New( vlc_object_t *,
*/ */
void playlist_preparser_Push( playlist_preparser_t *, input_item_t * ); void playlist_preparser_Push( playlist_preparser_t *, input_item_t * );
void playlist_preparser_fetcher_Push( playlist_preparser_t *, input_item_t * );
/** /**
* This function destroys the preparser object and thread. * This function destroys the preparser object and thread.
* *
......
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