Commit f36dcf5a authored by David Fuhrmann's avatar David Fuhrmann

macosx: implement libvlc exit handler to properly terminate the app when requested

This is the only supported way to terminate an cocoa application and also ensure
that the gui settings are getting saved. Adapted from similar code in the qt
module.
parent 254a5ee2
......@@ -55,12 +55,6 @@ static bool signal_ignored (int signum)
? (void *)sa.sa_sigaction : (void *)sa.sa_handler) == SIG_IGN;
}
static void vlc_kill (void *data)
{
pthread_t *ps = data;
pthread_kill (*ps, SIGTERM);
}
static void exit_timeout (int signum)
{
(void) signum;
......@@ -148,7 +142,6 @@ int main( int i_argc, const char *ppsz_argv[] )
sigaddset (&set, SIGCHLD);
/* Block all these signals */
pthread_t self = pthread_self ();
pthread_sigmask (SIG_SETMASK, &set, NULL);
const char *argv[i_argc + 3];
......@@ -217,7 +210,6 @@ int main( int i_argc, const char *ppsz_argv[] )
return 1;
int ret = 1;
libvlc_set_exit_handler (vlc, vlc_kill, &self);
libvlc_set_app_id (vlc, "org.VideoLAN.VLC", PACKAGE_VERSION, PACKAGE_NAME);
libvlc_set_user_agent (vlc, "VLC media player", "VLC/"PACKAGE_VERSION);
......
......@@ -283,6 +283,13 @@ void WindowClose(vout_window_t *p_wnd)
[o_pool release];
}
/* Used to abort the app.exec() on OSX after libvlc_Quit is called */
#include "../../../lib/libvlc_internal.h" /* libvlc_SetExitHandler */
static void QuitVLC( void *obj )
{
[[VLCApplication sharedApplication] performSelectorOnMainThread:@selector(terminate:) withObject:nil waitUntilDone:NO];
}
/*****************************************************************************
* Run: main loop
*****************************************************************************/
......@@ -298,6 +305,8 @@ static void Run(intf_thread_t *p_intf)
o_plItemChangedLock = [[NSLock alloc] init];
o_vout_provider_lock = [[NSLock alloc] init];
libvlc_SetExitHandler(p_intf->p_libvlc, QuitVLC, p_intf);
[[VLCMain sharedInstance] setIntf: p_intf];
[NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment