[vlc-devel] [PATCH 1/3] Qt: Run mainloop on the main thread on OSX

Juho Vähä-Herttua juhovh at iki.fi
Sat Jul 31 17:47:31 CEST 2010


---
 modules/gui/qt4/qt4.cpp |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 5965c05..9582a80 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -327,6 +327,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 thread on first thread instead */
+    p_intf->b_should_run_on_first_thread = true;
+    p_intf->pf_run = (void(*)(intf_thread_t *))Thread;
+#else
     if( vlc_clone( &p_sys->thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW ) )
     {
         delete p_sys;
@@ -337,9 +342,9 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
         return VLC_ENOMEM;
     }
 
-    /* */
+    /* Wait until the interface is initialized */
     vlc_sem_wait (&ready);
-    vlc_sem_destroy (&ready);
+#endif
 
     if( !p_sys->b_isDialogProvider )
     {
@@ -377,7 +382,11 @@ static void Close( vlc_object_t *p_this )
 
     QVLCApp::triggerQuit();
 
+    vlc_sem_wait (&ready);
+#ifndef Q_WS_MAC
     vlc_join (p_sys->thread, NULL);
+#endif
+    vlc_sem_destroy (&ready);
 #ifdef Q_WS_X11
     free (x11_display);
     x11_display = NULL;
@@ -463,9 +472,14 @@ static void *Thread( void *obj )
     /* Explain how to show a dialog :D */
     p_intf->pf_show_dialog = ShowDialog;
 
-    /* */
+    /* Notify that the interface is initialized */
     vlc_sem_post (&ready);
 
+#ifdef Q_WS_MAC
+    /* Start playlist here, because we took over main thread */
+    playlist_Play( p_intf->p_sys->p_playlist );
+#endif Q_WS_MAC
+
     /* Last settings */
     app.setQuitOnLastWindowClosed( false );
 
@@ -515,6 +529,9 @@ static void *Thread( void *obj )
     /* Destroy the MainInputManager */
     MainInputManager::killInstance();
 
+    /* Notify that the interface is cleaned up */
+    vlc_sem_post (&ready);
+
     /* Delete the application automatically */
     return NULL;
 }
-- 
1.6.5.7




More information about the vlc-devel mailing list