| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
#ifdef HAVE_CONFIG_H |
|---|
| 25 |
# include "config.h" |
|---|
| 26 |
#endif |
|---|
| 27 |
|
|---|
| 28 |
#include <vlc_common.h> |
|---|
| 29 |
#include <vlc_es.h> |
|---|
| 30 |
#include <vlc_input.h> |
|---|
| 31 |
#include <vlc_interface.h> |
|---|
| 32 |
#include <vlc_playlist.h> |
|---|
| 33 |
#include "playlist_internal.h" |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
static void* RunControlThread ( vlc_object_t * ); |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
void __playlist_ThreadCreate( vlc_object_t *p_parent ) |
|---|
| 53 |
{ |
|---|
| 54 |
playlist_t *p_playlist = playlist_Create( p_parent ); |
|---|
| 55 |
if( !p_playlist ) return; |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
playlist_preparse_t *p_preparse = &pl_priv(p_playlist)->preparse; |
|---|
| 59 |
vlc_mutex_init (&p_preparse->lock); |
|---|
| 60 |
vlc_cond_init (&p_preparse->wait); |
|---|
| 61 |
p_preparse->i_waiting = 0; |
|---|
| 62 |
p_preparse->pp_waiting = NULL; |
|---|
| 63 |
|
|---|
| 64 |
if( vlc_clone( &p_preparse->thread, playlist_PreparseLoop, p_preparse, |
|---|
| 65 |
VLC_THREAD_PRIORITY_LOW ) ) |
|---|
| 66 |
{ |
|---|
| 67 |
msg_Err( p_playlist, "cannot spawn preparse thread" ); |
|---|
| 68 |
p_preparse->up = false; |
|---|
| 69 |
return; |
|---|
| 70 |
} |
|---|
| 71 |
p_preparse->up = true; |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
playlist_fetcher_t *p_fetcher = &pl_priv(p_playlist)->fetcher; |
|---|
| 75 |
vlc_mutex_init (&p_fetcher->lock); |
|---|
| 76 |
vlc_cond_init (&p_fetcher->wait); |
|---|
| 77 |
p_fetcher->i_waiting = 0; |
|---|
| 78 |
p_fetcher->pp_waiting = NULL; |
|---|
| 79 |
p_fetcher->i_art_policy = var_CreateGetInteger( p_playlist, "album-art" ); |
|---|
| 80 |
|
|---|
| 81 |
if( vlc_clone( &p_fetcher->thread, playlist_FetcherLoop, p_fetcher, |
|---|
| 82 |
VLC_THREAD_PRIORITY_LOW ) ) |
|---|
| 83 |
{ |
|---|
| 84 |
msg_Err( p_playlist, "cannot spawn secondary preparse thread" ); |
|---|
| 85 |
p_fetcher->up = false; |
|---|
| 86 |
return; |
|---|
| 87 |
} |
|---|
| 88 |
p_fetcher->up = true; |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
if( vlc_thread_create( p_playlist, "playlist", RunControlThread, |
|---|
| 92 |
VLC_THREAD_PRIORITY_LOW, false ) ) |
|---|
| 93 |
{ |
|---|
| 94 |
msg_Err( p_playlist, "cannot spawn playlist thread" ); |
|---|
| 95 |
vlc_object_release( p_playlist ); |
|---|
| 96 |
return; |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
vlc_object_attach( p_playlist, p_parent ); |
|---|
| 101 |
|
|---|
| 102 |
return; |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
static void* RunControlThread ( vlc_object_t *p_this ) |
|---|
| 109 |
{ |
|---|
| 110 |
playlist_t *p_playlist = (playlist_t*)p_this; |
|---|
| 111 |
|
|---|
| 112 |
int canc = vlc_savecancel (); |
|---|
| 113 |
vlc_object_lock( p_playlist ); |
|---|
| 114 |
while( vlc_object_alive( p_playlist ) ) |
|---|
| 115 |
{ |
|---|
| 116 |
playlist_MainLoop( p_playlist ); |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
if( !vlc_object_alive( p_playlist ) ) |
|---|
| 121 |
break; |
|---|
| 122 |
|
|---|
| 123 |
if( p_playlist->b_cant_sleep ) |
|---|
| 124 |
{ |
|---|
| 125 |
|
|---|
| 126 |
vlc_object_unlock( p_playlist ); |
|---|
| 127 |
|
|---|
| 128 |
msleep( INTF_IDLE_SLEEP*2 ); |
|---|
| 129 |
|
|---|
| 130 |
vlc_object_lock( p_playlist ); |
|---|
| 131 |
} |
|---|
| 132 |
else |
|---|
| 133 |
{ |
|---|
| 134 |
vlc_object_wait( p_playlist ); |
|---|
| 135 |
} |
|---|
| 136 |
} |
|---|
| 137 |
vlc_object_unlock( p_playlist ); |
|---|
| 138 |
|
|---|
| 139 |
playlist_LastLoop( p_playlist ); |
|---|
| 140 |
vlc_restorecancel (canc); |
|---|
| 141 |
return NULL; |
|---|
| 142 |
} |
|---|