122
119
p_intf->p_sys->p_vlcProc = NULL;
123
120
p_intf->p_sys->p_repository = NULL;
126
p_intf->p_sys->b_exitRequested = false;
127
p_intf->p_sys->b_exitOK = false;
131
123
p_intf->p_sys->p_theme = NULL;
133
125
// Create a variable to be notified of skins to be loaded
134
126
var_Create( p_intf, "skin-to-load", VLC_VAR_STRING );
128
vlc_mutex_init( &p_intf->p_sys->vout_lock );
129
vlc_cond_init( &p_intf->p_sys->vout_wait );
131
vlc_mutex_init( &p_intf->p_sys->init_lock );
132
vlc_cond_init( &p_intf->p_sys->init_wait );
134
vlc_mutex_lock( &p_intf->p_sys->init_lock );
135
p_intf->p_sys->b_ready = false;
137
if( vlc_clone( &p_intf->p_sys->thread, Run, p_intf,
138
VLC_THREAD_PRIORITY_LOW ) )
140
vlc_mutex_unlock( &p_intf->p_sys->init_lock );
142
vlc_cond_destroy( &p_intf->p_sys->init_wait );
143
vlc_mutex_destroy( &p_intf->p_sys->init_lock );
144
vlc_cond_destroy( &p_intf->p_sys->vout_wait );
145
vlc_mutex_destroy( &p_intf->p_sys->vout_lock );
146
free( p_intf->p_sys );
150
while( !p_intf->p_sys->b_ready )
151
vlc_cond_wait( &p_intf->p_sys->init_wait, &p_intf->p_sys->init_lock );
152
vlc_mutex_unlock( &p_intf->p_sys->init_lock );
154
vlc_mutex_lock( &skin_load.mutex );
155
skin_load.intf = p_intf;
156
vlc_mutex_unlock( &skin_load.mutex );
161
//---------------------------------------------------------------------------
162
// Close: destroy interface
163
//---------------------------------------------------------------------------
164
static void Close( vlc_object_t *p_this )
166
intf_thread_t *p_intf = (intf_thread_t *)p_this;
168
msg_Dbg( p_intf, "closing skins2 module" );
170
vlc_mutex_lock( &skin_load.mutex );
171
skin_load.intf = NULL;
172
vlc_mutex_unlock( &skin_load.mutex);
174
vlc_join( p_intf->p_sys->thread, NULL );
176
vlc_mutex_destroy( &p_intf->p_sys->init_lock );
177
vlc_cond_destroy( &p_intf->p_sys->init_wait );
179
// Unsubscribe from messages bank
181
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
184
vlc_cond_destroy( &p_intf->p_sys->vout_wait );
185
vlc_mutex_destroy( &p_intf->p_sys->vout_lock );
188
free( p_intf->p_sys );
192
//---------------------------------------------------------------------------
194
//---------------------------------------------------------------------------
195
static void *Run( void * p_obj )
197
int canc = vlc_savecancel();
199
intf_thread_t *p_intf = (intf_thread_t *)p_obj;
201
bool b_error = false;
202
char *skin_last = NULL;
203
ThemeLoader *pLoader = NULL;
206
vlc_mutex_lock( &p_intf->p_sys->init_lock );
136
208
// Initialize singletons
137
209
if( OSFactory::instance( p_intf ) == NULL )
139
211
msg_Err( p_intf, "cannot initialize OSFactory" );
140
vlc_object_release( p_intf->p_sys->p_playlist );
142
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
146
215
if( AsyncQueue::instance( p_intf ) == NULL )
148
217
msg_Err( p_intf, "cannot initialize AsyncQueue" );
149
vlc_object_release( p_intf->p_sys->p_playlist );
151
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
155
221
if( Interpreter::instance( p_intf ) == NULL )
157
223
msg_Err( p_intf, "cannot instanciate Interpreter" );
158
vlc_object_release( p_intf->p_sys->p_playlist );
160
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
164
227
if( VarManager::instance( p_intf ) == NULL )
166
229
msg_Err( p_intf, "cannot instanciate VarManager" );
167
vlc_object_release( p_intf->p_sys->p_playlist );
169
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
173
233
if( VlcProc::instance( p_intf ) == NULL )
175
235
msg_Err( p_intf, "cannot initialize VLCProc" );
176
vlc_object_release( p_intf->p_sys->p_playlist );
178
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
182
239
if( VoutManager::instance( p_intf ) == NULL )
184
241
msg_Err( p_intf, "cannot instanciate VoutManager" );
185
vlc_object_release( p_intf->p_sys->p_playlist );
188
vlc_mutex_lock( &skin_load.mutex );
189
skin_load.intf = p_intf;
190
vlc_mutex_unlock( &skin_load.mutex );
192
Dialogs::instance( p_intf );
193
ThemeRepository::instance( p_intf );
245
if( ThemeRepository::instance( p_intf ) == NULL )
247
msg_Err( p_intf, "cannot instanciate ThemeRepository" );
251
if( Dialogs::instance( p_intf ) == NULL )
253
msg_Err( p_intf, "cannot instanciate qt4 dialogs provider" );
196
char *skin_last = config_GetPsz( p_intf, "skins2-last" );
198
ThemeLoader *pLoader = new ThemeLoader( p_intf );
200
if( !skin_last || !*skin_last || !pLoader->load( skin_last ) )
259
skin_last = config_GetPsz( p_intf, "skins2-last" );
260
pLoader = new ThemeLoader( p_intf );
262
if( !skin_last || !pLoader->load( skin_last ) )
202
// Get the resource path and try to load the default skin
203
OSFactory *pOSFactory = OSFactory::instance( p_intf );
204
const list<string> &resPath = pOSFactory->getResourcePath();
205
const string &sep = pOSFactory->getDirSeparator();
207
list<string>::const_iterator it;
208
for( it = resPath.begin(); it != resPath.end(); it++ )
210
string path = (*it) + sep + "default.vlt";
211
if( pLoader->load( path ) )
213
// Theme loaded successfully
217
if( it == resPath.end() )
219
// Last chance: the user can select a new theme file
220
if( Dialogs::instance( p_intf ) )
222
CmdDlgChangeSkin *pCmd = new CmdDlgChangeSkin( p_intf );
223
AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
224
pQueue->push( CmdGenericPtr( pCmd ) );
228
// No dialogs provider, just quit...
229
CmdQuit *pCmd = new CmdQuit( p_intf );
230
AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
231
pQueue->push( CmdGenericPtr( pCmd ) );
233
"cannot show the \"open skin\" dialog: exiting...");
264
// No skins (not even the default one). let's quit
265
CmdQuit *pCmd = new CmdQuit( p_intf );
266
AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
267
pQueue->push( CmdGenericPtr( pCmd ) );
268
msg_Err( p_intf, "no skins found : exiting");
239
272
free( skin_last );
243
p_intf->b_should_run_on_first_thread = true;
245
// enqueue a command to automatically start the first playlist item
246
AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
247
CmdPlaylistFirst *pCmd = new CmdPlaylistFirst( p_intf );
248
pQueue->push( CmdGenericPtr( pCmd ) );
252
return( VLC_SUCCESS );
255
//---------------------------------------------------------------------------
256
// Close: destroy interface
257
//---------------------------------------------------------------------------
258
static void Close( vlc_object_t *p_this )
260
intf_thread_t *p_intf = (intf_thread_t *)p_this;
262
msg_Dbg( p_intf, "closing skins2 module" );
264
vlc_mutex_lock( &skin_load.mutex );
265
skin_load.intf = NULL;
266
vlc_mutex_unlock( &skin_load.mutex);
274
// Get the instance of OSLoop
275
loop = OSFactory::instance( p_intf )->getOSLoop();
277
// Signal the main thread this thread is now ready
278
p_intf->p_sys->b_ready = true;
279
vlc_cond_signal( &p_intf->p_sys->init_wait );
280
vlc_mutex_unlock( &p_intf->p_sys->init_lock );
282
// Enter the main event loop
286
OSFactory::instance( p_intf )->destroyOSLoop();
288
// save and delete the theme
268
289
if( p_intf->p_sys->p_theme )
291
p_intf->p_sys->p_theme->saveConfig();
270
293
delete p_intf->p_sys->p_theme;
271
294
p_intf->p_sys->p_theme = NULL;
272
296
msg_Dbg( p_intf, "current theme deleted" );
300
config_SaveConfigFile( p_intf, NULL );
275
303
// Destroy "singleton" objects
276
OSFactory::instance( p_intf )->destroyOSLoop();
304
Dialogs::destroy( p_intf );
277
305
ThemeRepository::destroy( p_intf );
278
306
VoutManager::destroy( p_intf );
279
//Dialogs::destroy( p_intf );
307
VlcProc::destroy( p_intf );
308
VarManager::destroy( p_intf );
280
309
Interpreter::destroy( p_intf );
281
310
AsyncQueue::destroy( p_intf );
282
VarManager::destroy( p_intf );
283
VlcProc::destroy( p_intf );
284
311
OSFactory::destroy( p_intf );
286
if( p_intf->p_sys->p_playlist )
288
vlc_object_release( p_intf->p_sys->p_playlist );
291
// Unsubscribe from messages bank
293
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
297
free( p_intf->p_sys );
301
//---------------------------------------------------------------------------
303
//---------------------------------------------------------------------------
304
static void Run( intf_thread_t *p_intf )
306
int canc = vlc_savecancel();
308
// Get the instance of OSLoop
309
OSLoop *loop = OSFactory::instance( p_intf )->getOSLoop();
311
// Enter the main event loop
314
// Delete the theme and save the configuration of the windows
315
if( p_intf->p_sys->p_theme )
317
p_intf->p_sys->p_theme->saveConfig();
320
// cannot be called in "Close", because it refcounts skins2
321
Dialogs::destroy( p_intf );
324
config_SaveConfigFile( p_intf, NULL );
315
p_intf->p_sys->b_ready = true;
316
vlc_cond_signal( &p_intf->p_sys->init_wait );
317
vlc_mutex_unlock( &p_intf->p_sys->init_lock );
319
libvlc_Quit( p_intf->p_libvlc );
326
322
vlc_restorecancel(canc);
326
static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
330
328
// Callbacks for vout requests
331
329
static int WindowOpen( vlc_object_t *p_this )
333
331
vout_window_t *pWnd = (vout_window_t *)p_this;
334
intf_thread_t *pIntf = (intf_thread_t *)
335
vlc_object_find_name( p_this, "skins2", FIND_ANYWHERE );
333
vlc_mutex_lock( &skin_load.mutex );
334
intf_thread_t *pIntf = skin_load.intf;
336
vlc_object_hold( pIntf );
337
vlc_mutex_unlock( &skin_load.mutex );
337
339
if( pIntf == NULL )
338
340
return VLC_EGENERIC;
340
if( !config_GetInt( pIntf, "skinned-video") )
342
if( !vlc_object_alive( pIntf ) ||
343
!var_InheritBool( pIntf, "skinned-video") ||
344
pWnd->cfg->is_standalone )
342
346
vlc_object_release( pIntf );
343
347
return VLC_EGENERIC;
346
vlc_object_release( pIntf );
350
vlc_mutex_lock( &serializer );
348
352
pWnd->handle.hwnd = VoutManager::getWindow( pIntf, pWnd );
350
354
if( pWnd->handle.hwnd )
352
pWnd->p_private = pIntf;
353
356
pWnd->control = &VoutManager::controlWindow;
357
pWnd->sys = (vout_window_sys_t*)pIntf;
359
vlc_mutex_unlock( &serializer );
354
360
return VLC_SUCCESS;
364
vlc_object_release( pIntf );
365
vlc_mutex_unlock( &serializer );
358
366
return VLC_EGENERIC;