From a03b56aeec59142672822a28ad36aba24a212664 Mon Sep 17 00:00:00 2001 From: gpoirier Date: Fri, 19 Dec 2008 20:33:54 +0000 Subject: Replace vo_macosx's custom options parsing with a subopt_parse()-based one (in the same way as vo_gl). Patch by Adrian Stutz %adrian A sttz P ch% Original thread: date: Tue, Dec 9, 2008 at 3:20 PM subject: Re: [MPlayer-dev-eng] [PATCH] vo_macosx: option to set shared buffer name to allow multiple instances git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28165 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_macosx.m | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'libvo/vo_macosx.m') diff --git a/libvo/vo_macosx.m b/libvo/vo_macosx.m index fc58d52ef9..34043de579 100644 --- a/libvo/vo_macosx.m +++ b/libvo/vo_macosx.m @@ -28,6 +28,7 @@ #include "m_option.h" #include "mp_fifo.h" #include "libvo/sub.h" +#include "subopt-helper.h" #include "input/input.h" #include "input/mouse.h" @@ -315,30 +316,31 @@ static void uninit(void) } } +static opt_t subopts[] = { +{"device_id", OPT_ARG_INT, &screen_id, (opt_test_f)int_non_neg}, +{"shared_buffer", OPT_ARG_BOOL, &shared_buffer, NULL}, +{NULL} +}; + static int preinit(const char *arg) { - int parse_err = 0; - - if(arg) - { - char *parse_pos = (char *)&arg[0]; - while (parse_pos[0] && !parse_err) - { - if (strncmp (parse_pos, "device_id=", 10) == 0) - { - parse_pos = &parse_pos[10]; - screen_id = strtol(parse_pos, &parse_pos, 0); - screen_force = YES; - } - if (strncmp (parse_pos, "shared_buffer", 13) == 0) - { - parse_pos = &parse_pos[13]; - shared_buffer = YES; - } - if (parse_pos[0] == ':') parse_pos = &parse_pos[1]; - else if (parse_pos[0]) parse_err = 1; - } - } + + // set defaults + screen_id = 0; + shared_buffer = false; + + if (subopt_parse(arg, subopts) != 0) { + mp_msg(MSGT_VO, MSGL_FATAL, + "\n-vo macosx command line help:\n" + "Example: mplayer -vo macosx:device_id=1:shared_buffer\n" + "\nOptions:\n" + " device_id=<0-...>\n" + " Set screen device id for fullscreen.\n" + " shared_buffer\n" + " Write output to a shared memory buffer instead of displaying it.\n" + "\n" ); + return -1; + } NSApplicationLoad(); autoreleasepool = [[NSAutoreleasePool alloc] init]; -- cgit v1.2.3