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 )
{
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;
playlist_fetcher_Push( p_sys->p_fetcher, p_item );
playlist_preparser_fetcher_Push( p_sys->p_preparser, p_item );
return VLC_SUCCESS;
}
......@@ -233,13 +233,8 @@ static playlist_t *playlist_Create( vlc_object_t *p_parent )
pl_priv(p_playlist)->b_auto_preparse =
var_InheritBool( p_parent, "auto-preparse" );
/* Fetcher */
p->p_fetcher = playlist_fetcher_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 );
/* Preparser (and meta retriever) */
p->p_preparser = playlist_preparser_New( VLC_OBJECT(p_playlist) );
if( unlikely(p->p_preparser == NULL) )
msg_Err( p_playlist, "cannot create preparser" );
......@@ -341,8 +336,6 @@ void playlist_Destroy( playlist_t *p_playlist )
playlist_Deactivate( p_playlist );
if( 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 */
assert( p_sys->p_input == NULL );
......
......@@ -38,7 +38,6 @@
#include <assert.h>
#include "art.h"
#include "fetcher.h"
#include "preparser.h"
typedef struct vlc_sd_internal_t vlc_sd_internal_t;
......@@ -47,7 +46,6 @@ typedef struct playlist_private_t
{
playlist_t public_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
delete... At the very end. This sucks. */
......
......@@ -56,15 +56,17 @@ static void *Thread( void * );
/*****************************************************************************
* Public functions
*****************************************************************************/
playlist_preparser_t *playlist_preparser_New( vlc_object_t *parent,
playlist_fetcher_t *p_fetcher )
playlist_preparser_t *playlist_preparser_New( vlc_object_t *parent )
{
playlist_preparser_t *p_preparser = malloc( sizeof(*p_preparser) );
if( !p_preparser )
return NULL;
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_cond_init( &p_preparser->wait );
p_preparser->b_live = false;
......@@ -93,6 +95,13 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p
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 )
{
vlc_mutex_lock( &p_preparser->lock );
......@@ -110,6 +119,9 @@ void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
/* Destroy the item preparser */
vlc_cond_destroy( &p_preparser->wait );
vlc_mutex_destroy( &p_preparser->lock );
if( p_preparser->p_fetcher != NULL )
playlist_fetcher_Delete( p_preparser->p_fetcher );
free( p_preparser );
}
......
......@@ -37,8 +37,7 @@ typedef struct playlist_preparser_t playlist_preparser_t;
/**
* This function creates the preparser object and thread.
*/
playlist_preparser_t *playlist_preparser_New( vlc_object_t *,
playlist_fetcher_t * );
playlist_preparser_t *playlist_preparser_New( vlc_object_t * );
/**
* This function enqueues the provided item to be preparsed.
......@@ -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_fetcher_Push( playlist_preparser_t *, input_item_t * );
/**
* 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