* Local prototypes
*****************************************************************************/
static void* RunControlThread ( vlc_object_t * );
-static void* RunPreparse ( vlc_object_t * );
-static void* RunFetcher ( vlc_object_t * );
-static void PreparseDestructor ( vlc_object_t * );
-static void FetcherDestructor ( vlc_object_t * );
/*****************************************************************************
* Main functions for the global thread
if( !p_playlist ) return;
// Preparse
- static const char ppname[] = "preparser";
- p_playlist->p_preparse =
- vlc_custom_create( p_playlist, sizeof( playlist_preparse_t ),
- VLC_OBJECT_GENERIC, ppname );
- if( !p_playlist->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;
-
- vlc_object_set_destructor( p_playlist->p_preparse, PreparseDestructor );
-
- vlc_object_attach( p_playlist->p_preparse, p_playlist );
- if( vlc_thread_create( p_playlist->p_preparse, "preparser",
- RunPreparse, VLC_THREAD_PRIORITY_LOW, true ) )
+ playlist_preparse_t *p_preparse = &pl_priv(p_playlist)->preparse;
+ vlc_mutex_init (&p_preparse->lock);
+ vlc_cond_init (&p_preparse->wait);
+ p_preparse->i_waiting = 0;
+ p_preparse->pp_waiting = NULL;
+
+ if( vlc_clone( &p_preparse->thread, playlist_PreparseLoop, p_preparse,
+ VLC_THREAD_PRIORITY_LOW ) )
{
msg_Err( p_playlist, "cannot spawn preparse thread" );
- vlc_object_release( p_playlist->p_preparse );
+ p_preparse->up = false;
return;
}
+ p_preparse->up = true;
// Secondary Preparse
- static const char fname[] = "fetcher";
- p_playlist->p_fetcher =
- vlc_custom_create( p_playlist, sizeof( playlist_fetcher_t ),
- VLC_OBJECT_GENERIC, fname );
- if( !p_playlist->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,
- "album-art" );
-
- vlc_object_set_destructor( p_playlist->p_fetcher, FetcherDestructor );
-
- vlc_object_attach( p_playlist->p_fetcher, p_playlist );
- if( vlc_thread_create( p_playlist->p_fetcher,
- "fetcher",
- RunFetcher,
- VLC_THREAD_PRIORITY_LOW, true ) )
+ playlist_fetcher_t *p_fetcher = &pl_priv(p_playlist)->fetcher;
+ vlc_mutex_init (&p_fetcher->lock);
+ vlc_cond_init (&p_fetcher->wait);
+ p_fetcher->i_waiting = 0;
+ p_fetcher->pp_waiting = NULL;
+ p_fetcher->i_art_policy = var_CreateGetInteger( p_playlist, "album-art" );
+
+ if( vlc_clone( &p_fetcher->thread, playlist_FetcherLoop, p_fetcher,
+ VLC_THREAD_PRIORITY_LOW ) )
{
msg_Err( p_playlist, "cannot spawn secondary preparse thread" );
- vlc_object_release( p_playlist->p_fetcher );
+ p_fetcher->up = false;
return;
}
+ p_fetcher->up = true;
// Start the thread
if( vlc_thread_create( p_playlist, "playlist", RunControlThread,
- VLC_THREAD_PRIORITY_LOW, true ) )
+ VLC_THREAD_PRIORITY_LOW, false ) )
{
msg_Err( p_playlist, "cannot spawn playlist thread" );
vlc_object_release( p_playlist );
static void* RunControlThread ( vlc_object_t *p_this )
{
playlist_t *p_playlist = (playlist_t*)p_this;
- /* Tell above that we're ready */
- vlc_thread_ready( p_playlist );
int canc = vlc_savecancel ();
vlc_object_lock( p_playlist );
if( !vlc_object_alive( p_playlist ) )
break;
- if( p_playlist->b_cant_sleep )
+ if( pl_priv(p_playlist)->b_cant_sleep )
{
/* 100 ms is an acceptable delay for playlist operations */
vlc_object_unlock( p_playlist );
vlc_restorecancel (canc);
return NULL;
}
-
-/*****************************************************************************
- * Preparse-specific functions
- *****************************************************************************/
-static void* RunPreparse ( vlc_object_t *p_this )
-{
- playlist_preparse_t *p_obj = (playlist_preparse_t*)p_this;
- int canc;
-
- /* Tell above that we're ready */
- vlc_thread_ready( p_obj );
- canc = vlc_savecancel ();
- playlist_PreparseLoop( p_obj );
- vlc_restorecancel (canc);
- return NULL;
-}
-
-static void* RunFetcher( vlc_object_t *p_this )
-{
- playlist_fetcher_t *p_obj = (playlist_fetcher_t *)p_this;
- /* Tell above that we're ready */
- vlc_thread_ready( p_obj );
- int canc = vlc_savecancel ();
- playlist_FetcherLoop( p_obj );
- vlc_restorecancel (canc);
- return NULL;
-}
-
-static void PreparseDestructor( vlc_object_t * p_this )
-{
- playlist_preparse_t * p_preparse = (playlist_preparse_t *)p_this;
- free( p_preparse->pp_waiting );
- msg_Dbg( p_this, "Destroyed" );
-}
-
-static void FetcherDestructor( vlc_object_t * p_this )
-{
- playlist_fetcher_t * p_fetcher = (playlist_fetcher_t *)p_this;
- free( p_fetcher->pp_waiting );
- msg_Dbg( p_this, "Destroyed" );
-}