mirror of https://github.com/mpv-player/mpv
add support for macosx finder argument support (let you bundle mplayer to be a finder compliant .app) patch by Chris Roccati <roccati@pobox.com>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13910 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
20460bc1b9
commit
2cc1ec3ea4
|
@ -182,6 +182,7 @@ Optional features:
|
|||
--enable-fribidi Enable using the FriBiDi libs [disabled]
|
||||
--disable-enca Disable using ENCA charset oracle library [autodetect]
|
||||
--disable-macosx Disable Mac OS X specific features [autodetect]
|
||||
--enable-macosx-finder-support Enable Mac OS X Finder invocation parameter parsing [disabled]
|
||||
--disable-inet6 Disable IPv6 support [autodetect]
|
||||
--disable-gethostbyname2 gethostbyname() function is not provided by the C
|
||||
library [autodetect]
|
||||
|
@ -1381,6 +1382,7 @@ _shared_pp=no
|
|||
_menu=no
|
||||
_qtx=auto
|
||||
_macosx=auto
|
||||
_macosx_finder_support=no
|
||||
_sortsub=yes
|
||||
_freetypeconfig='freetype-config'
|
||||
_fribidi=no
|
||||
|
@ -1648,6 +1650,8 @@ for ac_option do
|
|||
|
||||
--enable-macosx) _macosx=yes ;;
|
||||
--disable-macosx) _macosx=no ;;
|
||||
--enable-macosx-finder-support) _macosx_finder_support=yes ;;
|
||||
--disable-macosx-finder-support) _macosx_finder_support=no ;;
|
||||
|
||||
--enable-sortsub) _sortsub=yes ;;
|
||||
--disable-sortsub) _sortsub=no ;;
|
||||
|
@ -3140,6 +3144,18 @@ EOF
|
|||
fi
|
||||
echores "$_macosx"
|
||||
|
||||
echocheck "Mac OS X Finder Support"
|
||||
if test "$_macosx_finder_support" = auto ; then
|
||||
_macosx_finder_support=$_macosx
|
||||
fi
|
||||
if test "$_macosx_finder_support" = yes; then
|
||||
_def_macosx_finder_support='#define MACOSX_FINDER_SUPPORT 1'
|
||||
_macosx_finder_support=yes
|
||||
else
|
||||
_def_macosx_finder_support='#undef MACOSX_FINDER_SUPPORT'
|
||||
_macosx_finder_support=no
|
||||
fi
|
||||
echores "$_macosx_finder_support"
|
||||
|
||||
echocheck "Samba support (libsmbclient)"
|
||||
if test "$_smbsupport" = yes; then
|
||||
|
@ -6571,6 +6587,7 @@ SMBSUPPORT_LIB = $_ld_smb
|
|||
XMMS_PLUGINS = $_xmms
|
||||
XMMS_LIB = $_xmms_lib
|
||||
MACOSX = $_macosx
|
||||
MACOSX_FINDER_SUPPORT = $_macosx_finder_support
|
||||
MACOSX_FRAMEWORKS = $_macosx_frameworks
|
||||
TOOLAME=$_toolame
|
||||
TOOLAME_EXTRAFLAGS=$_toolame_extraflags
|
||||
|
@ -6874,6 +6891,7 @@ $_def_dshow
|
|||
|
||||
/* Mac OS X specific features */
|
||||
$_def_macosx
|
||||
$_def_macosx_finder_support
|
||||
|
||||
/* Build our Win32-loader */
|
||||
$_def_win32_loader
|
||||
|
|
|
@ -1011,6 +1011,7 @@ static uint32_t preinit(const char *arg)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef MACOSX_FINDER_SUPPORT
|
||||
//this chunk of code is heavily based off SDL_macosx.m from SDL
|
||||
//it uses an Apple private function to request foreground operation
|
||||
|
||||
|
@ -1029,6 +1030,7 @@ static uint32_t preinit(const char *arg)
|
|||
SetFrontProcess(&myProc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ endif
|
|||
|
||||
getch = getch2.c
|
||||
timer = timer-lx.c
|
||||
ifeq ($(MACOSX_FINDER_SUPPORT),yes)
|
||||
SRCS += macosx_finder_args.c
|
||||
endif
|
||||
ifeq ($(TARGET_OS),Darwin)
|
||||
timer = timer-darwin.c
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
#include <Carbon/Carbon.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include "libmpdemux/url.h"
|
||||
#include "mp_msg.h"
|
||||
#include "m_option.h"
|
||||
#include "m_config.h"
|
||||
#include "playtree.h"
|
||||
|
||||
static play_tree_t *files=NULL;
|
||||
|
||||
static inline void add_entry(play_tree_t **last_parentp, play_tree_t **last_entryp, play_tree_t *entry) {
|
||||
|
||||
if(*last_entryp==NULL)
|
||||
play_tree_set_child(*last_parentp, entry);
|
||||
else
|
||||
play_tree_append_entry(*last_entryp, entry);
|
||||
|
||||
*last_entryp=entry;
|
||||
}
|
||||
|
||||
static pascal OSErr AppleEventHandlerProc(const AppleEvent *theAppleEvent, AppleEvent* reply, SInt32 handlerRefcon) {
|
||||
OSErr err=errAEEventNotHandled, res=noErr;
|
||||
AEDescList docList;
|
||||
long itemsInList;
|
||||
|
||||
AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments, NULL, FALSE);
|
||||
if((res=AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList))==noErr) {
|
||||
if((res=AECountItems(&docList, &itemsInList))==noErr) {
|
||||
Size currentSize=0;
|
||||
int valid=0,i;
|
||||
char *parm=NULL;
|
||||
play_tree_t *last_entry=NULL;
|
||||
|
||||
files=play_tree_new();
|
||||
for(i=1;i<=itemsInList;++i) {
|
||||
|
||||
for(;;) {
|
||||
OSErr e;
|
||||
Size actualSize=0;
|
||||
AEKeyword keywd;
|
||||
DescType returnedType;
|
||||
|
||||
if((e=AEGetNthPtr(&docList, i, typeFileURL, &keywd, &returnedType, (Ptr)parm, currentSize, &actualSize))==noErr) {
|
||||
if(actualSize>=currentSize) {
|
||||
currentSize=actualSize+1;
|
||||
parm=realloc(parm, currentSize);
|
||||
}
|
||||
else {
|
||||
parm[actualSize]=0;
|
||||
valid=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
valid=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(valid) {
|
||||
URL_t *url=url_new(parm);
|
||||
|
||||
if(url && !strcmp(url->protocol,"file") && !strcmp(url->hostname,"localhost")) {
|
||||
play_tree_t *entry=play_tree_new();
|
||||
|
||||
url_unescape_string(url->file, url->file);
|
||||
play_tree_add_file(entry, url->file);
|
||||
add_entry(&files, &last_entry, entry);
|
||||
}
|
||||
|
||||
url_free(url);
|
||||
}
|
||||
}
|
||||
|
||||
if(parm)
|
||||
free(parm);
|
||||
|
||||
err=noErr;
|
||||
}
|
||||
else
|
||||
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "AECountItems() error %d\n", res);
|
||||
|
||||
AEDisposeDesc(&docList);
|
||||
}
|
||||
else
|
||||
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "AEGetParamDesc() error %d\n", res);
|
||||
|
||||
QuitApplicationEventLoop();
|
||||
return err;
|
||||
}
|
||||
|
||||
play_tree_t *macosx_finder_args(m_config_t *config, int argc, char **argv) {
|
||||
ProcessSerialNumber myPsn;
|
||||
char myPsnStr[5+10+1+10+1];
|
||||
|
||||
GetCurrentProcess(&myPsn);
|
||||
snprintf(myPsnStr, 5+10+1+10+1, "-psn_%u_%u", myPsn.highLongOfPSN, myPsn.lowLongOfPSN);
|
||||
myPsnStr[5+10+1+10]=0;
|
||||
|
||||
if((argc==2) && !strcmp(myPsnStr, argv[1])) {
|
||||
m_config_set_option(config, "quiet", NULL);
|
||||
InitCursor();
|
||||
AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerUPP(AppleEventHandlerProc), 0, FALSE);
|
||||
RunApplicationEventLoop();
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
|
@ -65,6 +65,9 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
|
|||
char entbuf[10];
|
||||
int no_more_opts = 0;
|
||||
play_tree_t *last_parent, *last_entry = NULL, *root;
|
||||
#ifdef MACOSX_FINDER_SUPPORT
|
||||
extern play_tree_t *macosx_finder_args(m_config_t *, int , char **);
|
||||
#endif
|
||||
|
||||
#ifdef MP_DEBUG
|
||||
assert(config != NULL);
|
||||
|
@ -74,6 +77,12 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
|
|||
|
||||
config->mode = M_COMMAND_LINE;
|
||||
mode = GLOBAL;
|
||||
#ifdef MACOSX_FINDER_SUPPORT
|
||||
root=macosx_finder_args(config, argc, argv);
|
||||
if(root)
|
||||
return root;
|
||||
#endif
|
||||
|
||||
last_parent = root = play_tree_new();
|
||||
/* in order to work recursion detection properly in parse_config_file */
|
||||
++recursion_depth;
|
||||
|
|
Loading…
Reference in New Issue