Commit cc07bce0 authored by David Fuhrmann's avatar David Fuhrmann

darwinvlc/macosx: rework binary, start main loop in darwinvlc

This moves the main loop out of the macosx interface module.
Instead, the open callback only initializes the interface and the
close callback cleans up stuff. The mainloop is now started in
darwinvlc.m. In case the mac interface is not used, a CoreFoundation
mainloop is solely started to wait for termination events.

Additionally, this cleans up darwinvlc.m, and fixes signal
handling, which was dead code so far (in case the interface was used).
Now, GCD is used to catch SIGINT and SIGTERM in order to allow
ordinary shutdown.

refs #14362
close #6354
parent 021f50d9
...@@ -32,7 +32,7 @@ vlc_SOURCES = winvlc.c ...@@ -32,7 +32,7 @@ vlc_SOURCES = winvlc.c
noinst_DATA += vlc_win32_rc.rc noinst_DATA += vlc_win32_rc.rc
endif endif
if HAVE_DARWIN if HAVE_DARWIN
vlc_osx_SOURCES = darwinvlc.m override.c vlc_osx_SOURCES = darwinvlc.m
vlc_osx_LDFLAGS = $(LDFLAGS_vlc) -Wl,-framework,CoreFoundation,-framework,Cocoa vlc_osx_LDFLAGS = $(LDFLAGS_vlc) -Wl,-framework,CoreFoundation,-framework,Cocoa
vlc_osx_LDADD = ../lib/libvlc.la vlc_osx_LDADD = ../lib/libvlc.la
endif endif
......
This diff is collapsed.
...@@ -77,7 +77,6 @@ ...@@ -77,7 +77,6 @@
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
*****************************************************************************/ *****************************************************************************/
static void Run (intf_thread_t *p_intf);
static void updateProgressPanel (void *, const char *, float); static void updateProgressPanel (void *, const char *, float);
static bool checkProgressPanel (void *); static bool checkProgressPanel (void *);
...@@ -104,6 +103,10 @@ static bool b_intf_starting = false; ...@@ -104,6 +103,10 @@ static bool b_intf_starting = false;
static vlc_mutex_t start_mutex = VLC_STATIC_MUTEX; static vlc_mutex_t start_mutex = VLC_STATIC_MUTEX;
static vlc_cond_t start_cond = VLC_STATIC_COND; static vlc_cond_t start_cond = VLC_STATIC_COND;
static NSLock * o_appLock = nil; // controls access to f_appExit
static NSLock * o_vout_provider_lock = nil;
/***************************************************************************** /*****************************************************************************
* OpenIntf: initialize interface * OpenIntf: initialize interface
*****************************************************************************/ *****************************************************************************/
...@@ -114,13 +117,36 @@ int OpenIntf (vlc_object_t *p_this) ...@@ -114,13 +117,36 @@ int OpenIntf (vlc_object_t *p_this)
intf_thread_t *p_intf = (intf_thread_t*) p_this; intf_thread_t *p_intf = (intf_thread_t*) p_this;
msg_Dbg(p_intf, "Starting macosx interface"); msg_Dbg(p_intf, "Starting macosx interface");
Run(p_intf);
[VLCApplication sharedApplication];
o_appLock = [[NSLock alloc] init];
o_vout_provider_lock = [[NSLock alloc] init];
[[VLCMain sharedInstance] setIntf: p_intf];
vlc_mutex_lock(&start_mutex);
b_intf_starting = true;
vlc_cond_signal(&start_cond);
vlc_mutex_unlock(&start_mutex);
[NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
[o_pool release]; [o_pool release];
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static NSLock * o_vout_provider_lock = nil; void CloseIntf (vlc_object_t *p_this)
{
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
msg_Dbg(p_this, "Closing macosx interface");
[[VLCMain sharedInstance] applicationWillTerminate:nil];
[o_appLock release];
[o_vout_provider_lock release];
o_vout_provider_lock = nil;
[o_pool release];
}
static int WindowControl(vout_window_t *, int i_query, va_list); static int WindowControl(vout_window_t *, int i_query, va_list);
...@@ -306,48 +332,6 @@ void WindowClose(vout_window_t *p_wnd) ...@@ -306,48 +332,6 @@ void WindowClose(vout_window_t *p_wnd)
[o_pool release]; [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
*****************************************************************************/
static NSLock * o_appLock = nil; // controls access to f_appExit
static void Run(intf_thread_t *p_intf)
{
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
[VLCApplication sharedApplication];
o_appLock = [[NSLock alloc] init];
o_vout_provider_lock = [[NSLock alloc] init];
libvlc_SetExitHandler(p_intf->p_libvlc, QuitVLC, p_intf);
[[VLCMain sharedInstance] setIntf: p_intf];
vlc_mutex_lock(&start_mutex);
b_intf_starting = true;
vlc_cond_signal(&start_cond);
vlc_mutex_unlock(&start_mutex);
[NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
[NSApp run];
msg_Dbg(p_intf, "Run loop has been stopped");
[[VLCMain sharedInstance] applicationWillTerminate:nil];
[o_appLock release];
[o_vout_provider_lock release];
o_vout_provider_lock = nil;
[o_pool release];
raise(SIGTERM);
}
#pragma mark - #pragma mark -
#pragma mark Variables Callback #pragma mark Variables Callback
......
...@@ -148,7 +148,7 @@ static const char *const continue_playback_list_text[] = { ...@@ -148,7 +148,7 @@ static const char *const continue_playback_list_text[] = {
vlc_module_begin() vlc_module_begin()
set_description(N_("Mac OS X interface")) set_description(N_("Mac OS X interface"))
set_capability("interface", 200) set_capability("interface", 200)
set_callbacks(OpenIntf, NULL) set_callbacks(OpenIntf, CloseIntf)
set_category(CAT_INTERFACE) set_category(CAT_INTERFACE)
set_subcategory(SUBCAT_INTERFACE_MAIN) set_subcategory(SUBCAT_INTERFACE_MAIN)
cannot_unload_broken_library() cannot_unload_broken_library()
......
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