Commit 9cb61ac9 authored by David Fuhrmann's avatar David Fuhrmann

macosx: wait in vout provider for the interface to be initialized

Because the playlist is started before the interface is up,
the vout window provider waits until basic initalization is done
in the interface (initialization of VLCIntf, NSApp, static vars).

This is still sort of a hack, ideally the playlist should be
started only after all interfaces are fully initialized.

close #11585

(cherry picked from commit 4a17358abea2b8fce47e8af3888aec638debfb42)
Signed-off-by: default avatarDavid Fuhrmann <dfuhrmann@videolan.org>
parent 04714baa
......@@ -99,6 +99,10 @@ static int BossCallback(vlc_object_t *, const char *,
#pragma mark -
#pragma mark VLC Interface Object Callbacks
static bool b_intf_starting = false;
static vlc_mutex_t start_mutex = VLC_STATIC_MUTEX;
static vlc_cond_t start_cond = VLC_STATIC_COND;
/*****************************************************************************
* OpenIntf: initialize interface
*****************************************************************************/
......@@ -108,6 +112,7 @@ int OpenIntf (vlc_object_t *p_this)
[VLCApplication sharedApplication];
intf_thread_t *p_intf = (intf_thread_t*) p_this;
msg_Dbg(p_intf, "Starting macosx interface");
Run(p_intf);
[o_pool release];
......@@ -120,13 +125,34 @@ static int WindowControl(vout_window_t *, int i_query, va_list);
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
intf_thread_t *p_intf = VLCIntf;
if (!p_intf) {
msg_Err(p_wnd, "Mac OS X interface not found");
[o_pool release];
msg_Dbg(p_wnd, "Opening video window");
/*
* HACK: Wait 200ms for the interface to come up.
* WindowOpen might be called before the mac intf is started. Lets wait until OpenIntf gets called
* and does basic initialization. Enqueuing the vout controller request into the main loop later on
* ensures that the actual window is created after the interface is fully initialized
* (applicationDidFinishLaunching).
*
* Timeout is needed as the mac intf is not always started at all.
*/
mtime_t deadline = mdate() + 200000;
vlc_mutex_lock(&start_mutex);
while (!b_intf_starting) {
if (vlc_cond_timedwait(&start_cond, &start_mutex, deadline)) {
break; // timeout
}
}
if (!b_intf_starting) {
msg_Err(p_wnd, "Cannot create vout as Mac OS X interface was not found");
vlc_mutex_unlock(&start_mutex);
return VLC_EGENERIC;
}
vlc_mutex_unlock(&start_mutex);
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
[o_vout_provider_lock lock];
......@@ -296,9 +322,13 @@ static void Run(intf_thread_t *p_intf)
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];
......
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