* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
* Derk-Jan Hartman <hartman at videolan.org>
- * Felix K\9fhne <fkuehne at videolan dot org>
+ * Felix KΓΌhne <fkuehne at videolan dot org>
*
* 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
# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <vlc_keys.h>
/*****************************************************************************
* 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;
/*****************************************************************************
* 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;
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
*****************************************************************************/
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];
if (!CPSSetFrontProcess(&PSN))
[NSApplication sharedApplication];
[NSApp run];
+
+ pthread_join( killer_thread, NULL );
+
[pool release];
}