X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fminimal_macosx%2Fintf.m;h=526bc708baaafa48b13e8ccdfb48037752814c36;hb=45cb15ed0f2bef96fc80f2a82b3e50351355e00e;hp=9c1483b2cae79da6c60028e98c40b50cd823a164;hpb=6ee1e193fd896ab9a4729fde14f009d9ce629815;p=vlc diff --git a/modules/gui/minimal_macosx/intf.m b/modules/gui/minimal_macosx/intf.m index 9c1483b2ca..526bc708ba 100644 --- a/modules/gui/minimal_macosx/intf.m +++ b/modules/gui/minimal_macosx/intf.m @@ -7,7 +7,7 @@ * Authors: Jon Lech Johansen * Christophe Massiot * Derk-Jan Hartman - * Felix KŸhne + * Felix Kühne * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,11 @@ #include /* malloc(), free() */ #include /* for MAXPATHLEN */ #include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include #include @@ -46,7 +50,7 @@ static void Run ( intf_thread_t *p_intf ); /***************************************************************************** * OpenIntf: initialize interface *****************************************************************************/ -int E_(OpenIntf) ( vlc_object_t *p_this ) +int OpenIntf ( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t*) p_this; @@ -59,6 +63,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this ) memset( p_intf->p_sys, 0, sizeof( *p_intf->p_sys ) ); p_intf->pf_run = Run; + p_intf->b_should_run_on_first_thread = true; return VLC_SUCCESS; } @@ -66,7 +71,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this ) /***************************************************************************** * CloseIntf: destroy interface *****************************************************************************/ -void E_(CloseIntf) ( vlc_object_t *p_this ) +void CloseIntf ( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t*) p_this; @@ -84,6 +89,28 @@ extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); +/***************************************************************************** + * KillerThread: Thread that kill the application + *****************************************************************************/ +static void * KillerThread( void *user_data ) +{ + NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; + + intf_thread_t *p_intf = user_data; + + vlc_object_lock ( p_intf ); + while( vlc_object_alive( p_intf ) ) + vlc_object_wait( p_intf ); + vlc_object_unlock( p_intf ); + + msg_Dbg( p_intf, "Killing the Mac OS X module" ); + + /* We are dead, terminate */ + [NSApp terminate: nil]; + [o_pool release]; + return NULL; +} + /***************************************************************************** * Run: main loop *****************************************************************************/ @@ -103,6 +130,11 @@ static void Run( intf_thread_t *p_intf ) sigemptyset( &set ); sigaddset( &set, SIGTERM ); pthread_sigmask( SIG_UNBLOCK, &set, NULL ); + + /* Setup a thread that will monitor the module killing */ + pthread_t killer_thread; + pthread_create( &killer_thread, NULL, KillerThread, p_intf ); + CPSProcessSerNum PSN; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApplication sharedApplication]; @@ -111,6 +143,9 @@ static void Run( intf_thread_t *p_intf ) if (!CPSSetFrontProcess(&PSN)) [NSApplication sharedApplication]; [NSApp run]; + + pthread_join( killer_thread, NULL ); + [pool release]; }