Commit bad878b5 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

playlist: Fetcher and parser are playlist private.

parent 54166d1b
......@@ -153,6 +153,8 @@ struct playlist_item_t
typedef enum
{ PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t;
typedef struct playlist_private_t playlist_private_t;
/** Structure containing information about the playlist */
struct playlist_t
{
......@@ -200,8 +202,6 @@ struct playlist_t
int i_order; /**< Last ordering applied to the playlist */
mtime_t gc_date;
bool b_cant_sleep;
playlist_preparse_t *p_preparse; /**< Preparser object */
playlist_fetcher_t *p_fetcher;/**< Meta and art fetcher object */
struct {
/* Current status. These fields are readonly, only the playlist
......@@ -224,6 +224,10 @@ struct playlist_t
when processing the request */
vlc_mutex_t lock; /**< Lock to protect request */
} request;
/* All other data is PRIVATE. You can't access it
* outside of src/input */
playlist_private_t *p;
};
/** Helper to add an item */
......
......@@ -99,7 +99,7 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
/* If we already checked this album in this session, skip */
if( psz_artist && psz_album )
{
FOREACH_ARRAY( playlist_album_t album, p_playlist->p_fetcher->albums )
FOREACH_ARRAY( playlist_album_t album, p_playlist->p->p_fetcher->albums )
if( !strcmp( album.psz_artist, psz_artist ) &&
!strcmp( album.psz_album, psz_album ) )
{
......@@ -179,7 +179,7 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
a.psz_album = psz_album;
a.psz_arturl = input_item_GetArtURL( p_item );
a.b_found = (i_ret == VLC_EGENERIC ? false : true );
ARRAY_APPEND( p_playlist->p_fetcher->albums, a );
ARRAY_APPEND( p_playlist->p->p_fetcher->albums, a );
}
else
{
......
......@@ -190,19 +190,19 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
int playlist_PreparseEnqueue( playlist_t *p_playlist,
input_item_t *p_item )
{
vlc_object_lock( p_playlist->p_preparse );
if( !vlc_object_alive( p_playlist->p_preparse ) )
vlc_object_lock( p_playlist->p->p_preparse );
if( !vlc_object_alive( p_playlist->p->p_preparse ) )
{
vlc_object_unlock( p_playlist->p_preparse );
vlc_object_unlock( p_playlist->p->p_preparse );
return VLC_EGENERIC;
}
vlc_gc_incref( p_item );
INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
p_playlist->p_preparse->i_waiting,
p_playlist->p_preparse->i_waiting,
INSERT_ELEM( p_playlist->p->p_preparse->pp_waiting,
p_playlist->p->p_preparse->i_waiting,
p_playlist->p->p_preparse->i_waiting,
p_item );
vlc_object_signal_unlocked( p_playlist->p_preparse );
vlc_object_unlock( p_playlist->p_preparse );
vlc_object_signal_unlocked( p_playlist->p->p_preparse );
vlc_object_unlock( p_playlist->p->p_preparse );
return VLC_SUCCESS;
}
......@@ -212,15 +212,15 @@ int playlist_PreparseEnqueueItem( playlist_t *p_playlist,
playlist_item_t *p_item )
{
vlc_object_lock( p_playlist );
vlc_object_lock( p_playlist->p_preparse );
if( !vlc_object_alive( p_playlist->p_preparse ) )
vlc_object_lock( p_playlist->p->p_preparse );
if( !vlc_object_alive( p_playlist->p->p_preparse ) )
{
vlc_object_unlock( p_playlist->p_preparse );
vlc_object_unlock( p_playlist->p->p_preparse );
vlc_object_unlock( p_playlist );
return VLC_EGENERIC;
}
PreparseEnqueueItemSub( p_playlist, p_item );
vlc_object_unlock( p_playlist->p_preparse );
vlc_object_unlock( p_playlist->p->p_preparse );
vlc_object_unlock( p_playlist );
return VLC_SUCCESS;
}
......@@ -228,19 +228,19 @@ int playlist_PreparseEnqueueItem( playlist_t *p_playlist,
int playlist_AskForArtEnqueue( playlist_t *p_playlist,
input_item_t *p_item )
{
vlc_object_lock( p_playlist->p_fetcher );
if( !vlc_object_alive( p_playlist->p_fetcher ) )
vlc_object_lock( p_playlist->p->p_fetcher );
if( !vlc_object_alive( p_playlist->p->p_fetcher ) )
{
vlc_object_unlock( p_playlist->p_fetcher );
vlc_object_unlock( p_playlist->p->p_fetcher );
return VLC_EGENERIC;
}
vlc_gc_incref( p_item );
INSERT_ELEM( p_playlist->p_fetcher->pp_waiting,
p_playlist->p_fetcher->i_waiting,
p_playlist->p_fetcher->i_waiting, p_item );
vlc_object_signal_unlocked( p_playlist->p_fetcher );
vlc_object_unlock( p_playlist->p_fetcher );
INSERT_ELEM( p_playlist->p->p_fetcher->pp_waiting,
p_playlist->p->p_fetcher->i_waiting,
p_playlist->p->p_fetcher->i_waiting, p_item );
vlc_object_signal_unlocked( p_playlist->p->p_fetcher );
vlc_object_unlock( p_playlist->p->p_fetcher );
return VLC_SUCCESS;
}
......@@ -251,9 +251,9 @@ static void PreparseEnqueueItemSub( playlist_t *p_playlist,
if( p_item->i_children == -1 )
{
vlc_gc_incref( p_item->p_input );
INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
p_playlist->p_preparse->i_waiting,
p_playlist->p_preparse->i_waiting,
INSERT_ELEM( p_playlist->p->p_preparse->pp_waiting,
p_playlist->p->p_preparse->i_waiting,
p_playlist->p->p_preparse->i_waiting,
p_item->p_input );
}
else
......@@ -540,8 +540,8 @@ int playlist_PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
}
free( psz_uri );
if( p_playlist->p_fetcher &&
p_playlist->p_fetcher->i_art_policy == ALBUM_ART_WHEN_PLAYED )
if( p_playlist->p->p_fetcher &&
p_playlist->p->p_fetcher->i_art_policy == ALBUM_ART_WHEN_PLAYED )
{
bool b_has_art;
......
......@@ -174,14 +174,14 @@ static void playlist_Destructor( vlc_object_t * p_this )
{
playlist_t * p_playlist = (playlist_t *)p_this;
if( p_playlist->p_preparse )
if( p_playlist->p->p_preparse )
{
vlc_object_release( p_playlist->p_preparse );
vlc_object_release( p_playlist->p->p_preparse );
}
if( p_playlist->p_fetcher )
if( p_playlist->p->p_fetcher )
{
vlc_object_release( p_playlist->p_fetcher );
vlc_object_release( p_playlist->p->p_fetcher );
}
msg_Dbg( p_this, "Destroyed" );
}
......@@ -517,10 +517,10 @@ void playlist_LastLoop( playlist_t *p_playlist )
playlist_ServicesDiscoveryKillAll( p_playlist );
playlist_MLDump( p_playlist );
vlc_object_kill( p_playlist->p_preparse );
vlc_thread_join( p_playlist->p_preparse );
vlc_object_kill( p_playlist->p_fetcher );
vlc_thread_join( p_playlist->p_fetcher );
vlc_object_kill( p_playlist->p->p_preparse );
vlc_thread_join( p_playlist->p->p_preparse );
vlc_object_kill( p_playlist->p->p_fetcher );
vlc_thread_join( p_playlist->p->p_fetcher );
PL_LOCK;
......@@ -603,21 +603,21 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
*/
char *psz_arturl = input_item_GetArtURL( p_current );
char *psz_name = input_item_GetName( p_current );
if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
if( p_playlist->p->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
( !psz_arturl || strncmp( psz_arturl, "file://", 7 ) ) )
{
PL_DEBUG("meta ok for %s, need to fetch art", psz_name );
vlc_object_lock( p_playlist->p_fetcher );
if( vlc_object_alive( p_playlist->p_fetcher ) )
vlc_object_lock( p_playlist->p->p_fetcher );
if( vlc_object_alive( p_playlist->p->p_fetcher ) )
{
INSERT_ELEM( p_playlist->p_fetcher->pp_waiting,
p_playlist->p_fetcher->i_waiting,
p_playlist->p_fetcher->i_waiting, p_current);
vlc_object_signal_unlocked( p_playlist->p_fetcher );
INSERT_ELEM( p_playlist->p->p_fetcher->pp_waiting,
p_playlist->p->p_fetcher->i_waiting,
p_playlist->p->p_fetcher->i_waiting, p_current);
vlc_object_signal_unlocked( p_playlist->p->p_fetcher );
}
else
vlc_gc_decref( p_current );
vlc_object_unlock( p_playlist->p_fetcher );
vlc_object_unlock( p_playlist->p->p_fetcher );
}
else
{
......
......@@ -37,6 +37,12 @@
#include "input/input_internal.h"
#include <assert.h>
struct playlist_private_t
{
playlist_preparse_t *p_preparse; /**< Preparser object */
playlist_fetcher_t *p_fetcher; /**< Meta and art fetcher object */
};
struct playlist_preparse_t
{
VLC_COMMON_MEMBERS
......
......@@ -60,57 +60,57 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent )
// Preparse
static const char ppname[] = "preparser";
p_playlist->p_preparse =
p_playlist->p->p_preparse =
vlc_custom_create( p_playlist, sizeof( playlist_preparse_t ),
VLC_OBJECT_GENERIC, ppname );
if( !p_playlist->p_preparse )
if( !p_playlist->p->p_preparse )
{
msg_Err( p_playlist, "unable to create preparser" );
vlc_object_release( p_playlist );
return;
}
p_playlist->p_preparse->psz_object_name = strdup( "preparser" );
p_playlist->p_preparse->i_waiting = 0;
p_playlist->p_preparse->pp_waiting = NULL;
p_playlist->p->p_preparse->psz_object_name = strdup( "preparser" );
p_playlist->p->p_preparse->i_waiting = 0;
p_playlist->p->p_preparse->pp_waiting = NULL;
vlc_object_set_destructor( p_playlist->p_preparse, PreparseDestructor );
vlc_object_set_destructor( p_playlist->p->p_preparse, PreparseDestructor );
vlc_object_attach( p_playlist->p_preparse, p_playlist );
if( vlc_thread_create( p_playlist->p_preparse, "preparser",
vlc_object_attach( p_playlist->p->p_preparse, p_playlist );
if( vlc_thread_create( p_playlist->p->p_preparse, "preparser",
RunPreparse, VLC_THREAD_PRIORITY_LOW, true ) )
{
msg_Err( p_playlist, "cannot spawn preparse thread" );
vlc_object_release( p_playlist->p_preparse );
vlc_object_release( p_playlist->p->p_preparse );
return;
}
// Secondary Preparse
static const char fname[] = "fetcher";
p_playlist->p_fetcher =
p_playlist->p->p_fetcher =
vlc_custom_create( p_playlist, sizeof( playlist_fetcher_t ),
VLC_OBJECT_GENERIC, fname );
if( !p_playlist->p_fetcher )
if( !p_playlist->p->p_fetcher )
{
msg_Err( p_playlist, "unable to create secondary preparser" );
vlc_object_release( p_playlist );
return;
}
p_playlist->p_fetcher->psz_object_name = strdup( "fetcher" );
p_playlist->p_fetcher->i_waiting = 0;
p_playlist->p_fetcher->pp_waiting = NULL;
p_playlist->p_fetcher->i_art_policy = var_CreateGetInteger( p_playlist,
p_playlist->p->p_fetcher->psz_object_name = strdup( "fetcher" );
p_playlist->p->p_fetcher->i_waiting = 0;
p_playlist->p->p_fetcher->pp_waiting = NULL;
p_playlist->p->p_fetcher->i_art_policy = var_CreateGetInteger( p_playlist,
"album-art" );
vlc_object_set_destructor( p_playlist->p_fetcher, FetcherDestructor );
vlc_object_set_destructor( p_playlist->p->p_fetcher, FetcherDestructor );
vlc_object_attach( p_playlist->p_fetcher, p_playlist );
if( vlc_thread_create( p_playlist->p_fetcher,
vlc_object_attach( p_playlist->p->p_fetcher, p_playlist );
if( vlc_thread_create( p_playlist->p->p_fetcher,
"fetcher",
RunFetcher,
VLC_THREAD_PRIORITY_LOW, true ) )
{
msg_Err( p_playlist, "cannot spawn secondary preparse thread" );
vlc_object_release( p_playlist->p_fetcher );
vlc_object_release( p_playlist->p->p_fetcher );
return;
}
......
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