2013-02-23 17:28:22 +00:00
|
|
|
/*
|
|
|
|
* This file is part of mpv.
|
|
|
|
*
|
2017-06-24 14:08:17 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2013-02-23 17:28:22 +00:00
|
|
|
*
|
|
|
|
* mpv is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2017-06-24 14:08:17 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-02-23 17:28:22 +00:00
|
|
|
*
|
2017-06-24 14:08:17 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2013-02-23 17:28:22 +00:00
|
|
|
*/
|
|
|
|
|
2013-12-21 19:46:20 +00:00
|
|
|
#include <stdio.h>
|
2013-03-04 13:23:06 +00:00
|
|
|
#include <pthread.h>
|
2017-02-25 20:56:59 +00:00
|
|
|
#include "config.h"
|
2016-01-11 18:03:40 +00:00
|
|
|
#include "mpv_talloc.h"
|
2013-02-23 17:28:22 +00:00
|
|
|
|
2013-12-17 02:35:43 +00:00
|
|
|
#include "common/msg.h"
|
|
|
|
#include "input/input.h"
|
2017-02-25 20:56:59 +00:00
|
|
|
#include "player/client.h"
|
2013-02-23 17:28:22 +00:00
|
|
|
|
2014-04-15 23:51:40 +00:00
|
|
|
#import "osdep/macosx_application_objc.h"
|
2013-06-19 17:25:19 +00:00
|
|
|
#include "osdep/macosx_compat.h"
|
2014-04-15 23:51:40 +00:00
|
|
|
#import "osdep/macosx_events_objc.h"
|
2014-10-19 21:32:34 +00:00
|
|
|
#include "osdep/threads.h"
|
2015-05-02 16:47:57 +00:00
|
|
|
#include "osdep/main-fn.h"
|
2013-02-23 17:28:22 +00:00
|
|
|
|
2017-02-25 20:56:59 +00:00
|
|
|
#if HAVE_MACOS_TOUCHBAR
|
|
|
|
#import "osdep/macosx_touchbar.h"
|
|
|
|
#endif
|
|
|
|
|
2013-09-07 13:37:02 +00:00
|
|
|
#define MPV_PROTOCOL @"mpv://"
|
|
|
|
|
2015-05-02 16:09:01 +00:00
|
|
|
// Whether the NSApplication singleton was created. If this is false, we are
|
|
|
|
// running in libmpv mode, and cocoa_main() was never called.
|
|
|
|
static bool application_instantiated;
|
|
|
|
|
2013-03-04 13:23:06 +00:00
|
|
|
static pthread_t playback_thread_id;
|
2013-02-23 17:28:22 +00:00
|
|
|
|
2014-04-15 23:51:40 +00:00
|
|
|
@interface Application ()
|
|
|
|
{
|
|
|
|
EventsResponder *_eventsResponder;
|
|
|
|
}
|
|
|
|
|
2013-02-23 17:28:22 +00:00
|
|
|
- (NSMenuItem *)menuItemWithParent:(NSMenu *)parent
|
|
|
|
title:(NSString *)title
|
|
|
|
action:(SEL)selector
|
|
|
|
keyEquivalent:(NSString*)key;
|
|
|
|
|
|
|
|
- (NSMenuItem *)mainMenuItemWithParent:(NSMenu *)parent
|
|
|
|
child:(NSMenu *)child;
|
|
|
|
- (void)registerMenuItem:(NSMenuItem*)menuItem forKey:(MPMenuKey)key;
|
|
|
|
- (NSMenu *)appleMenuWithMainMenu:(NSMenu *)mainMenu;
|
2016-12-11 22:35:48 +00:00
|
|
|
- (NSMenu *)videoMenu;
|
2013-02-23 17:28:22 +00:00
|
|
|
- (NSMenu *)windowMenu;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSApplication (NiblessAdditions)
|
|
|
|
- (void)setAppleMenu:(NSMenu *)aMenu;
|
|
|
|
@end
|
|
|
|
|
2015-05-02 16:09:01 +00:00
|
|
|
static Application *mpv_shared_app(void)
|
2013-06-02 15:39:05 +00:00
|
|
|
{
|
|
|
|
return (Application *)[Application sharedApplication];
|
|
|
|
}
|
2013-02-23 17:28:22 +00:00
|
|
|
|
2015-05-02 16:09:01 +00:00
|
|
|
static void terminate_cocoa_application(void)
|
|
|
|
{
|
|
|
|
[NSApp hide:NSApp];
|
|
|
|
[NSApp terminate:NSApp];
|
|
|
|
}
|
|
|
|
|
2013-06-02 15:39:05 +00:00
|
|
|
@implementation Application
|
|
|
|
@synthesize menuItems = _menu_items;
|
2014-12-07 20:39:26 +00:00
|
|
|
@synthesize openCount = _open_count;
|
2013-06-02 15:39:05 +00:00
|
|
|
|
2013-06-02 15:58:48 +00:00
|
|
|
- (void)sendEvent:(NSEvent *)event
|
|
|
|
{
|
2017-03-26 18:32:04 +00:00
|
|
|
if (![_eventsResponder processKeyEvent:event])
|
|
|
|
[super sendEvent:event];
|
2015-05-26 20:39:04 +00:00
|
|
|
[_eventsResponder wakeup];
|
2013-06-02 15:58:48 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 17:28:22 +00:00
|
|
|
- (id)init
|
|
|
|
{
|
|
|
|
if (self = [super init]) {
|
|
|
|
self.menuItems = [[[NSMutableDictionary alloc] init] autorelease];
|
2014-04-15 23:51:40 +00:00
|
|
|
_eventsResponder = [EventsResponder sharedInstance];
|
2013-09-07 09:49:04 +00:00
|
|
|
|
|
|
|
NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
|
|
|
|
[em setEventHandler:self
|
|
|
|
andSelector:@selector(getUrl:withReplyEvent:)
|
|
|
|
forEventClass:kInternetEventClass
|
|
|
|
andEventID:kAEGetURL];
|
2013-02-23 17:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2013-09-07 09:49:04 +00:00
|
|
|
- (void)dealloc
|
|
|
|
{
|
|
|
|
NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
|
|
|
|
[em removeEventHandlerForEventClass:kInternetEventClass
|
|
|
|
andEventID:kAEGetURL];
|
2017-02-15 19:41:16 +00:00
|
|
|
[em removeEventHandlerForEventClass:kCoreEventClass
|
|
|
|
andEventID:kAEQuitApplication];
|
2013-09-07 09:49:04 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2017-02-25 20:56:59 +00:00
|
|
|
#if HAVE_MACOS_TOUCHBAR
|
|
|
|
- (NSTouchBar *)makeTouchBar
|
|
|
|
{
|
|
|
|
TouchBar *tBar = [[TouchBar alloc] init];
|
|
|
|
[tBar setApp:self];
|
|
|
|
tBar.delegate = tBar;
|
|
|
|
tBar.customizationIdentifier = customID;
|
|
|
|
tBar.defaultItemIdentifiers = @[play, previousItem, nextItem, seekBar];
|
|
|
|
tBar.customizationAllowedItemIdentifiers = @[play, seekBar, previousItem,
|
|
|
|
nextItem, previousChapter, nextChapter, cycleAudio, cycleSubtitle,
|
|
|
|
currentPosition, timeLeft];
|
|
|
|
return tBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)toggleTouchBarMenu
|
|
|
|
{
|
|
|
|
[NSApp toggleTouchBarCustomizationPalette:self];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
- (void)processEvent:(struct mpv_event *)event
|
|
|
|
{
|
|
|
|
#if HAVE_MACOS_TOUCHBAR
|
2017-04-02 19:02:00 +00:00
|
|
|
if ([self respondsToSelector:@selector(touchBar)])
|
|
|
|
[(TouchBar *)self.touchBar processEvent:event];
|
2017-02-25 20:56:59 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)queueCommand:(char *)cmd
|
|
|
|
{
|
|
|
|
[_eventsResponder queueCommand:cmd];
|
|
|
|
}
|
|
|
|
|
2013-02-23 17:28:22 +00:00
|
|
|
#define _R(P, T, E, K) \
|
|
|
|
{ \
|
|
|
|
NSMenuItem *tmp = [self menuItemWithParent:(P) title:(T) \
|
|
|
|
action:nil keyEquivalent:(E)]; \
|
|
|
|
[self registerMenuItem:tmp forKey:(K)]; \
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMenu *)appleMenuWithMainMenu:(NSMenu *)mainMenu
|
|
|
|
{
|
|
|
|
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Apple Menu"];
|
|
|
|
[self mainMenuItemWithParent:mainMenu child:menu];
|
2013-05-06 20:19:52 +00:00
|
|
|
[self menuItemWithParent:menu title:@"Hide mpv"
|
|
|
|
action:@selector(hide:) keyEquivalent: @"h"];
|
2016-12-11 22:35:48 +00:00
|
|
|
[menu addItem:[NSMenuItem separatorItem]];
|
2013-02-23 17:28:22 +00:00
|
|
|
[self menuItemWithParent:menu title:@"Quit mpv"
|
|
|
|
action:@selector(stopPlayback) keyEquivalent: @"q"];
|
|
|
|
return [menu autorelease];
|
|
|
|
}
|
|
|
|
|
2016-12-11 22:35:48 +00:00
|
|
|
- (NSMenu *)videoMenu
|
2013-02-23 17:28:22 +00:00
|
|
|
{
|
2016-12-11 22:35:48 +00:00
|
|
|
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Video"];
|
2013-02-23 17:28:22 +00:00
|
|
|
_R(menu, @"Half Size", @"0", MPM_H_SIZE)
|
|
|
|
_R(menu, @"Normal Size", @"1", MPM_N_SIZE)
|
|
|
|
_R(menu, @"Double Size", @"2", MPM_D_SIZE)
|
|
|
|
return [menu autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMenu *)windowMenu
|
|
|
|
{
|
|
|
|
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Window"];
|
|
|
|
_R(menu, @"Minimize", @"m", MPM_MINIMIZE)
|
|
|
|
_R(menu, @"Zoom", @"z", MPM_ZOOM)
|
2017-02-25 20:56:59 +00:00
|
|
|
|
|
|
|
#if HAVE_MACOS_TOUCHBAR
|
2017-04-02 19:02:00 +00:00
|
|
|
if ([self respondsToSelector:@selector(touchBar)]) {
|
|
|
|
[menu addItem:[NSMenuItem separatorItem]];
|
|
|
|
[self menuItemWithParent:menu title:@"Customize Touch Bar…"
|
|
|
|
action:@selector(toggleTouchBarMenu) keyEquivalent: @""];
|
|
|
|
}
|
2017-02-25 20:56:59 +00:00
|
|
|
#endif
|
|
|
|
|
2013-02-23 17:28:22 +00:00
|
|
|
return [menu autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)initialize_menu
|
|
|
|
{
|
|
|
|
NSMenu *main_menu = [[NSMenu new] autorelease];
|
|
|
|
[NSApp setMainMenu:main_menu];
|
|
|
|
[NSApp setAppleMenu:[self appleMenuWithMainMenu:main_menu]];
|
|
|
|
|
2016-12-11 22:35:48 +00:00
|
|
|
[NSApp mainMenuItemWithParent:main_menu child:[self videoMenu]];
|
2013-06-02 15:39:05 +00:00
|
|
|
[NSApp mainMenuItemWithParent:main_menu child:[self windowMenu]];
|
2013-02-23 17:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef _R
|
|
|
|
|
|
|
|
- (void)stopPlayback
|
|
|
|
{
|
2013-06-02 15:39:05 +00:00
|
|
|
[self stopMPV:"quit"];
|
2013-05-23 07:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)stopPlaybackAndRememberPosition
|
|
|
|
{
|
2016-07-14 18:04:59 +00:00
|
|
|
[self stopMPV:"quit-watch-later"];
|
2013-05-23 07:44:56 +00:00
|
|
|
}
|
|
|
|
|
2013-06-02 15:39:05 +00:00
|
|
|
- (void)stopMPV:(char *)cmd
|
2013-05-23 07:44:56 +00:00
|
|
|
{
|
2015-05-26 20:39:04 +00:00
|
|
|
if (![_eventsResponder queueCommand:cmd])
|
2013-05-12 18:29:23 +00:00
|
|
|
terminate_cocoa_application();
|
2013-02-23 17:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)registerMenuItem:(NSMenuItem*)menuItem forKey:(MPMenuKey)key
|
|
|
|
{
|
|
|
|
[self.menuItems setObject:menuItem forKey:[NSNumber numberWithInt:key]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)registerSelector:(SEL)action forKey:(MPMenuKey)key
|
|
|
|
{
|
|
|
|
NSNumber *boxedKey = [NSNumber numberWithInt:key];
|
|
|
|
NSMenuItem *item = [self.menuItems objectForKey:boxedKey];
|
|
|
|
if (item) {
|
|
|
|
[item setAction:action];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMenuItem *)menuItemWithParent:(NSMenu *)parent
|
|
|
|
title:(NSString *)title
|
|
|
|
action:(SEL)action
|
|
|
|
keyEquivalent:(NSString*)key
|
|
|
|
{
|
|
|
|
|
|
|
|
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title
|
|
|
|
action:action
|
|
|
|
keyEquivalent:key];
|
|
|
|
[parent addItem:item];
|
|
|
|
return [item autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMenuItem *)mainMenuItemWithParent:(NSMenu *)parent
|
|
|
|
child:(NSMenu *)child
|
|
|
|
{
|
|
|
|
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@""
|
|
|
|
action:nil
|
|
|
|
keyEquivalent:@""];
|
|
|
|
[item setSubmenu:child];
|
|
|
|
[parent addItem:item];
|
|
|
|
return [item autorelease];
|
|
|
|
}
|
|
|
|
|
2017-02-15 19:41:16 +00:00
|
|
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
2016-12-15 22:06:04 +00:00
|
|
|
{
|
2017-02-15 19:41:16 +00:00
|
|
|
NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
|
|
|
|
[em setEventHandler:self
|
|
|
|
andSelector:@selector(handleQuitEvent:withReplyEvent:)
|
|
|
|
forEventClass:kCoreEventClass
|
|
|
|
andEventID:kAEQuitApplication];
|
2013-02-23 17:28:22 +00:00
|
|
|
}
|
|
|
|
|
2017-02-15 19:41:16 +00:00
|
|
|
- (void)handleQuitEvent:(NSAppleEventDescriptor *)event
|
|
|
|
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
2013-02-23 17:28:22 +00:00
|
|
|
{
|
|
|
|
[self stopPlayback];
|
|
|
|
}
|
|
|
|
|
2013-09-07 09:49:04 +00:00
|
|
|
- (void)getUrl:(NSAppleEventDescriptor *)event
|
|
|
|
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
|
|
|
{
|
|
|
|
NSString *url =
|
|
|
|
[[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
|
|
|
|
2013-09-07 13:37:02 +00:00
|
|
|
url = [url stringByReplacingOccurrencesOfString:MPV_PROTOCOL
|
|
|
|
withString:@""
|
|
|
|
options:NSAnchoredSearch
|
|
|
|
range:NSMakeRange(0, [MPV_PROTOCOL length])];
|
|
|
|
|
2014-12-02 21:27:33 +00:00
|
|
|
url = [url stringByRemovingPercentEncoding];
|
2014-12-06 11:48:18 +00:00
|
|
|
[_eventsResponder handleFilesArray:@[url]];
|
2013-09-07 09:49:04 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 17:28:22 +00:00
|
|
|
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
|
|
|
|
{
|
2014-12-07 20:39:26 +00:00
|
|
|
if (mpv_shared_app().openCount > 0) {
|
|
|
|
mpv_shared_app().openCount--;
|
|
|
|
return;
|
|
|
|
}
|
2014-01-19 23:06:07 +00:00
|
|
|
SEL cmpsel = @selector(localizedStandardCompare:);
|
2014-12-06 11:48:18 +00:00
|
|
|
NSArray *files = [filenames sortedArrayUsingSelector:cmpsel];
|
|
|
|
[_eventsResponder handleFilesArray:files];
|
2013-02-23 17:28:22 +00:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2013-03-04 13:23:06 +00:00
|
|
|
struct playback_thread_ctx {
|
|
|
|
int *argc;
|
|
|
|
char ***argv;
|
|
|
|
};
|
|
|
|
|
2014-12-06 11:48:18 +00:00
|
|
|
static void cocoa_run_runloop(void)
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
[NSApp run];
|
|
|
|
[pool drain];
|
|
|
|
}
|
|
|
|
|
2013-03-04 13:23:06 +00:00
|
|
|
static void *playback_thread(void *ctx_obj)
|
|
|
|
{
|
2014-10-19 21:32:34 +00:00
|
|
|
mpthread_set_name("playback core (OSX)");
|
2013-05-29 19:43:21 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
struct playback_thread_ctx *ctx = (struct playback_thread_ctx*) ctx_obj;
|
2015-05-02 16:47:57 +00:00
|
|
|
int r = mpv_main(*ctx->argc, *ctx->argv);
|
2015-02-12 17:20:29 +00:00
|
|
|
terminate_cocoa_application();
|
2015-02-13 09:47:07 +00:00
|
|
|
// normally never reached - unless the cocoa mainloop hasn't started yet
|
|
|
|
exit(r);
|
2013-05-29 19:43:21 +00:00
|
|
|
}
|
2013-03-04 13:23:06 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 17:28:22 +00:00
|
|
|
void cocoa_register_menu_item_action(MPMenuKey key, void* action)
|
|
|
|
{
|
2015-05-02 16:09:01 +00:00
|
|
|
if (application_instantiated)
|
|
|
|
[NSApp registerSelector:(SEL)action forKey:key];
|
2013-02-23 17:28:22 +00:00
|
|
|
}
|
|
|
|
|
2014-12-06 11:48:18 +00:00
|
|
|
static void init_cocoa_application(bool regular)
|
2013-02-23 17:28:22 +00:00
|
|
|
{
|
2013-06-02 15:39:05 +00:00
|
|
|
NSApp = mpv_shared_app();
|
|
|
|
[NSApp setDelegate:NSApp];
|
|
|
|
[NSApp initialize_menu];
|
2014-12-05 21:58:02 +00:00
|
|
|
|
|
|
|
// Will be set to Regular from cocoa_common during UI creation so that we
|
|
|
|
// don't create an icon when playing audio only files.
|
2014-12-06 11:48:18 +00:00
|
|
|
[NSApp setActivationPolicy: regular ?
|
|
|
|
NSApplicationActivationPolicyRegular :
|
|
|
|
NSApplicationActivationPolicyAccessory];
|
2013-05-26 20:03:16 +00:00
|
|
|
|
|
|
|
atexit_b(^{
|
|
|
|
// Because activation policy has just been set to behave like a real
|
|
|
|
// application, that policy must be reset on exit to prevent, among
|
|
|
|
// other things, the menubar created here from remaining on screen.
|
|
|
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
|
|
|
|
});
|
2013-02-23 17:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void macosx_redirect_output_to_logfile(const char *filename)
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
NSString *log_path = [NSHomeDirectory() stringByAppendingPathComponent:
|
|
|
|
[@"Library/Logs/" stringByAppendingFormat:@"%s.log", filename]];
|
|
|
|
freopen([log_path fileSystemRepresentation], "a", stdout);
|
|
|
|
freopen([log_path fileSystemRepresentation], "a", stderr);
|
|
|
|
[pool release];
|
|
|
|
}
|
|
|
|
|
2017-02-01 20:42:58 +00:00
|
|
|
static bool bundle_started_from_finder()
|
2013-09-16 17:35:01 +00:00
|
|
|
{
|
2017-02-01 20:42:58 +00:00
|
|
|
NSDictionary *env = [[NSProcessInfo processInfo] environment];
|
|
|
|
NSString *is_bundle = [env objectForKey:@"MPVBUNDLE"];
|
2013-02-23 17:28:22 +00:00
|
|
|
|
2017-02-01 20:42:58 +00:00
|
|
|
return is_bundle ? [is_bundle boolValue] : false;
|
2013-09-12 06:26:47 +00:00
|
|
|
}
|
|
|
|
|
2015-05-02 16:47:57 +00:00
|
|
|
int cocoa_main(int argc, char *argv[])
|
2013-02-23 17:28:22 +00:00
|
|
|
{
|
2014-12-06 11:48:18 +00:00
|
|
|
@autoreleasepool {
|
2015-05-02 16:09:01 +00:00
|
|
|
application_instantiated = true;
|
2017-02-25 20:56:59 +00:00
|
|
|
[[EventsResponder sharedInstance] setIsApplication:YES];
|
2015-05-02 16:09:01 +00:00
|
|
|
|
2014-12-06 11:48:18 +00:00
|
|
|
struct playback_thread_ctx ctx = {0};
|
|
|
|
ctx.argc = &argc;
|
|
|
|
ctx.argv = &argv;
|
2013-02-23 17:28:22 +00:00
|
|
|
|
2017-02-01 20:42:58 +00:00
|
|
|
if (bundle_started_from_finder()) {
|
2014-12-06 11:48:18 +00:00
|
|
|
macosx_redirect_output_to_logfile("mpv");
|
|
|
|
init_cocoa_application(true);
|
|
|
|
} else {
|
2014-12-07 20:39:26 +00:00
|
|
|
for (int i = 1; i < argc; i++)
|
|
|
|
if (argv[i][0] != '-')
|
|
|
|
mpv_shared_app().openCount++;
|
2014-12-06 11:48:18 +00:00
|
|
|
init_cocoa_application(false);
|
2013-02-23 17:28:22 +00:00
|
|
|
}
|
|
|
|
|
2014-12-06 11:48:18 +00:00
|
|
|
pthread_create(&playback_thread_id, NULL, playback_thread, &ctx);
|
|
|
|
[[EventsResponder sharedInstance] waitForInputContext];
|
|
|
|
cocoa_run_runloop();
|
|
|
|
|
|
|
|
// This should never be reached: cocoa_run_runloop blocks until the
|
|
|
|
// process is quit
|
|
|
|
fprintf(stderr, "There was either a problem "
|
|
|
|
"initializing Cocoa or the Runloop was stopped unexpectedly. "
|
|
|
|
"Please report this issues to a developer.\n");
|
|
|
|
pthread_join(playback_thread_id, NULL);
|
|
|
|
return 1;
|
2013-02-23 17:28:22 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-06 11:48:18 +00:00
|
|
|
|