X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmisc%2Fqte_main.cpp;h=f97082252a00777c8b5bdd634a81bd514da454c8;hb=2396250c9a24d7cd206f2d6278b47fd3ac70e85c;hp=d3139494097286f11c230401388ab3b6fb7f3ee2;hpb=3868e3ec1cd86c1460c96b0479c8fba10269dc6b;p=vlc diff --git a/modules/misc/qte_main.cpp b/modules/misc/qte_main.cpp index d313949409..f97082252a 100644 --- a/modules/misc/qte_main.cpp +++ b/modules/misc/qte_main.cpp @@ -26,8 +26,12 @@ *****************************************************************************/ extern "C" { -#include -#include /* atexit() */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include } #include @@ -52,7 +56,7 @@ typedef struct qte_thread_t static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); -static void QteMain ( qte_thread_t * ); +static void* QteMain( vlc_object_t * ); /***************************************************************************** * Local variables (mutex-protected). @@ -69,9 +73,9 @@ static qte_thread_t * p_qte_main = NULL; "from normal Qt.") vlc_module_begin(); - set_description( _("Qt Embedded GUI helper") ); + set_description( N_("Qt Embedded GUI helper") ); set_capability( "gui-helper", 90 ); - add_bool( "qte-guiserver", 0, NULL, STANDALONE_TEXT, STANDALONE_LONGTEXT, VLC_FALSE ); + add_bool( "qte-guiserver", 0, NULL, STANDALONE_TEXT, STANDALONE_LONGTEXT, false ); add_shortcut( "qte" ); set_callbacks( Open, Close ); vlc_module_end(); @@ -83,18 +87,14 @@ vlc_module_end(); *****************************************************************************/ static int Open( vlc_object_t *p_this ) { - vlc_value_t lockval; - - /* FIXME: put this in the module (de)initialization ASAP */ - var_Create( p_this->p_libvlc_global, "qte", VLC_VAR_MUTEX ); + vlc_mutex_t *lock; - var_Get( p_this->p_libvlc_global, "qte", &lockval ); - vlc_mutex_lock( (vlc_mutex_t *) lockval.p_address ); + lock = var_AcquireMutex( "qte" ); if( i_refcount > 0 ) { i_refcount++; - vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address ); + vlc_mutex_unlock( lock ); return VLC_SUCCESS; } @@ -104,17 +104,16 @@ static int Open( vlc_object_t *p_this ) /* Launch the QApplication::exec() thread. It will not return until the * application is properly initialized, which ensures us thread safety. */ if( vlc_thread_create( p_qte_main, "qte_main", QteMain, - VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) ) + VLC_THREAD_PRIORITY_LOW, true ) ) { - vlc_object_destroy( p_qte_main ); + vlc_object_release( p_qte_main ); i_refcount--; - vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address ); - var_Destroy( p_this->p_libvlc_global, "qte" ); + vlc_mutex_unlock( lock ); return VLC_ETHREAD; } i_refcount++; - vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address ); + vlc_mutex_unlock( lock ); vlc_object_attach( p_qte_main, p_this ); msg_Dbg( p_this, "qte_main running" ); @@ -127,17 +126,15 @@ static int Open( vlc_object_t *p_this ) *****************************************************************************/ static void Close( vlc_object_t *p_this ) { - vlc_value_t lockval; + vlc_mutex_t *lock; - var_Get( p_this->p_libvlc_global, "qte", &lockval ); - vlc_mutex_lock( (vlc_mutex_t *) lockval.p_address ); + lock = var_AcquireMutex( "qte" ); i_refcount--; if( i_refcount > 0 ) { - vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address ); - var_Destroy( p_this->p_libvlc_global, "qte" ); + vlc_mutex_unlock( lock ); return; } p_qte_main->p_qte_application->quit(); @@ -149,11 +146,10 @@ static void Close( vlc_object_t *p_this ) msg_Dbg( p_this, "Detaching qte_main" ); vlc_object_detach( p_qte_main ); - vlc_object_destroy( p_qte_main ); + vlc_object_release( p_qte_main ); p_qte_main = NULL; - vlc_mutex_unlock( (vlc_mutex_t *) lockval.p_address ); - var_Destroy( p_this->p_libvlc_global, "qte" ); + vlc_mutex_unlock( lock ); } /***************************************************************************** @@ -162,15 +158,17 @@ static void Close( vlc_object_t *p_this ) * this part of the interface is in a separate thread so that we can call * qte_main() from within it without annoying the rest of the program. *****************************************************************************/ -static void QteMain( qte_thread_t *p_this ) +static void* QteMain( vlc_object_t* p_vlc_obj ) { + qte_thread_t *p_this = (qte_thread_t*)p_vlc_obj; int i_argc = 1; + int canc = vlc_savecancel (); - p_this->b_gui_server = VLC_FALSE; + p_this->b_gui_server = false; if( config_GetInt( p_this, "qte-guiserver" ) ) { msg_Dbg( p_this, "Running as Qt Embedded standalone GuiServer" ); - p_this->b_gui_server = VLC_TRUE; + p_this->b_gui_server = true; } /* Run as standalone GuiServer or as GuiClient. */ @@ -193,4 +191,7 @@ static void QteMain( qte_thread_t *p_this ) vlc_thread_ready( p_this ); p_this->p_qte_application->exec(); + + vlc_restorecancel (canc); + return NULL; }