[vlc-commits] commit: Qt: Run mainloop on the main thread on OSX ( Juho Vähä-Herttua )

git at videolan.org git at videolan.org
Sat Jul 31 21:19:34 CEST 2010


vlc | branch: master | Juho Vähä-Herttua <juhovh at iki.fi> | Sat Jul 31 22:02:25 2010 +0300| [4f4d1a58241dd254b5d8555a4c094e5b6c3b907e] | committer: Rémi Denis-Courmont 

Qt: Run mainloop on the main thread on OSX

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4f4d1a58241dd254b5d8555a4c094e5b6c3b907e
---

 modules/gui/qt4/qt4.cpp |   44 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 5965c05..0e9ab8e 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -282,6 +282,24 @@ static struct
  * 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 */
 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;
 #endif
     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 ) )
     {
         delete p_sys;
@@ -336,19 +359,19 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
         vlc_mutex_unlock (&one.lock);
         return VLC_ENOMEM;
     }
+#endif
 
     /* */
     vlc_sem_wait (&ready);
     vlc_sem_destroy (&ready);
 
+#ifndef Q_WS_MAC
     if( !p_sys->b_isDialogProvider )
     {
-        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");
+        RegisterIntf( p_this );
     }
+#endif
+
     return VLC_SUCCESS;
 }
 
@@ -377,7 +400,9 @@ static void Close( vlc_object_t *p_this )
 
     QVLCApp::triggerQuit();
 
+#ifndef Q_WS_MAC
     vlc_join (p_sys->thread, NULL);
+#endif
 #ifdef Q_WS_X11
     free (x11_display);
     x11_display = NULL;
@@ -466,6 +491,15 @@ static void *Thread( void *obj )
     /* */
     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 */
     app.setQuitOnLastWindowClosed( false );
 



More information about the vlc-commits mailing list