Commit 4f4d1a58 authored by Juho Vähä-Herttua's avatar Juho Vähä-Herttua Committed by Rémi Denis-Courmont

Qt: Run mainloop on the main thread on OSX

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent b0ad9149
...@@ -282,6 +282,24 @@ static struct ...@@ -282,6 +282,24 @@ static struct
* Module callbacks * Module callbacks
*****************************************************************************/ *****************************************************************************/
#ifdef Q_WS_MAC
/* Used to abort the app.exec() on OSX after libvlc_Quit is called */
#include "../../../src/control/libvlc_internal.h" /* libvlc_SetExitHandler */
static void Abort( void *obj )
{
QVLCApp::triggerQuit();
}
#endif
static void RegisterIntf( vlc_object_t *p_this )
{
playlist_t *pl = pl_Get(p_this);
var_Create (pl, "qt4-iface", VLC_VAR_ADDRESS);
var_SetAddress (pl, "qt4-iface", p_this);
var_Create (pl, "window", VLC_VAR_STRING);
var_SetString (pl, "window", "qt4,any");
}
/* Open Interface */ /* Open Interface */
static int Open( vlc_object_t *p_this, bool isDialogProvider ) static int Open( vlc_object_t *p_this, bool isDialogProvider )
{ {
...@@ -327,6 +345,11 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider ) ...@@ -327,6 +345,11 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
x11_display = display; x11_display = display;
#endif #endif
vlc_sem_init (&ready, 0); vlc_sem_init (&ready, 0);
#ifdef Q_WS_MAC
/* Run mainloop on the main thread as Cocoa requires */
libvlc_SetExitHandler( p_intf->p_libvlc, Abort, p_intf );
Thread( (void *)p_intf );
#else
if( vlc_clone( &p_sys->thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW ) ) if( vlc_clone( &p_sys->thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW ) )
{ {
delete p_sys; delete p_sys;
...@@ -336,19 +359,19 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider ) ...@@ -336,19 +359,19 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
vlc_mutex_unlock (&one.lock); vlc_mutex_unlock (&one.lock);
return VLC_ENOMEM; return VLC_ENOMEM;
} }
#endif
/* */ /* */
vlc_sem_wait (&ready); vlc_sem_wait (&ready);
vlc_sem_destroy (&ready); vlc_sem_destroy (&ready);
#ifndef Q_WS_MAC
if( !p_sys->b_isDialogProvider ) if( !p_sys->b_isDialogProvider )
{ {
playlist_t *pl = pl_Get(p_this); RegisterIntf( p_this );
var_Create (pl, "qt4-iface", VLC_VAR_ADDRESS);
var_SetAddress (pl, "qt4-iface", p_this);
var_Create (pl, "window", VLC_VAR_STRING);
var_SetString (pl, "window", "qt4,any");
} }
#endif
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -377,7 +400,9 @@ static void Close( vlc_object_t *p_this ) ...@@ -377,7 +400,9 @@ static void Close( vlc_object_t *p_this )
QVLCApp::triggerQuit(); QVLCApp::triggerQuit();
#ifndef Q_WS_MAC
vlc_join (p_sys->thread, NULL); vlc_join (p_sys->thread, NULL);
#endif
#ifdef Q_WS_X11 #ifdef Q_WS_X11
free (x11_display); free (x11_display);
x11_display = NULL; x11_display = NULL;
...@@ -466,6 +491,15 @@ static void *Thread( void *obj ) ...@@ -466,6 +491,15 @@ static void *Thread( void *obj )
/* */ /* */
vlc_sem_post (&ready); vlc_sem_post (&ready);
#ifdef Q_WS_MAC
/* We took over main thread, register and start here */
if( !p_intf->p_sys->b_isDialogProvider )
{
RegisterIntf( (vlc_object_t *)p_intf );
playlist_Play( p_intf->p_sys->p_playlist );
}
#endif
/* Last settings */ /* Last settings */
app.setQuitOnLastWindowClosed( false ); app.setQuitOnLastWindowClosed( false );
......
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