Commit 4a17358a 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
parent 5598f816
...@@ -98,6 +98,10 @@ static int BossCallback(vlc_object_t *, const char *, ...@@ -98,6 +98,10 @@ static int BossCallback(vlc_object_t *, const char *,
#pragma mark - #pragma mark -
#pragma mark VLC Interface Object Callbacks #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 * OpenIntf: initialize interface
*****************************************************************************/ *****************************************************************************/
...@@ -107,6 +111,7 @@ int OpenIntf (vlc_object_t *p_this) ...@@ -107,6 +111,7 @@ int OpenIntf (vlc_object_t *p_this)
[VLCApplication sharedApplication]; [VLCApplication sharedApplication];
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");
Run(p_intf); Run(p_intf);
[o_pool release]; [o_pool release];
...@@ -123,13 +128,34 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg) ...@@ -123,13 +128,34 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
&& cfg->type != VOUT_WINDOW_TYPE_NSOBJECT) && cfg->type != VOUT_WINDOW_TYPE_NSOBJECT)
return VLC_EGENERIC; return VLC_EGENERIC;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; msg_Dbg(p_wnd, "Opening video window");
intf_thread_t *p_intf = VLCIntf;
if (!p_intf) { /*
msg_Err(p_wnd, "Mac OS X interface not found"); * HACK: Wait 200ms for the interface to come up.
[o_pool release]; * 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; 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); NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
[o_vout_provider_lock lock]; [o_vout_provider_lock lock];
...@@ -300,9 +326,13 @@ static void Run(intf_thread_t *p_intf) ...@@ -300,9 +326,13 @@ static void Run(intf_thread_t *p_intf)
o_vout_provider_lock = [[NSLock alloc] init]; o_vout_provider_lock = [[NSLock alloc] init];
libvlc_SetExitHandler(p_intf->p_libvlc, QuitVLC, p_intf); libvlc_SetExitHandler(p_intf->p_libvlc, QuitVLC, p_intf);
[[VLCMain sharedInstance] setIntf: 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]; [NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
[NSApp run]; [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