summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2011-12-18 20:02:31 +0100
committerwm4 <wm4@mplayer2.org>2012-02-09 04:58:41 +0100
commit4352f9feca37f1294c75e4bf2326e978f0e659df (patch)
treed06d9057bd01e259ff436c8cab4776729d942585 /libvo
parent93ae55c2c34357b892bff36d678a5d46c22d5a0c (diff)
downloadmpv-4352f9feca37f1294c75e4bf2326e978f0e659df.tar.bz2
mpv-4352f9feca37f1294c75e4bf2326e978f0e659df.tar.xz
vo_gl: add "backend" suboption to allow selecting the GUI backend
The "backend" suboption allows selecting the GUI backend used by vo_gl. Normally, it's auto-selected, but sometimes it's desireable to explicitly select it. Remove the gl_sdl VO. This can now be done by using: --vo=gl:backend=sdl This is based on svn commit 34438, and tries to be compatible with it. The undocumented numeric backend names serve this purpose. (They are undocumented because names are preferred.)
Diffstat (limited to 'libvo')
-rw-r--r--libvo/gl_common.c30
-rw-r--r--libvo/gl_common.h2
-rw-r--r--libvo/video_out.c4
-rw-r--r--libvo/vo_gl.c53
4 files changed, 54 insertions, 35 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index 6bb543e56b..481d21e2fe 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -2087,6 +2087,36 @@ static void new_vo_sdl_fullscreen(struct vo *vo) { vo_sdl_fullscreen(); }
#endif
+struct backend {
+ const char *name;
+ enum MPGLType type;
+};
+
+static struct backend backends[] = {
+ {"auto", GLTYPE_AUTO},
+ {"cocoa", GLTYPE_COCOA},
+ {"win", GLTYPE_W32},
+ {"x11", GLTYPE_X11},
+ {"sdl", GLTYPE_SDL},
+ // mplayer-svn aliases (note that mplayer-svn couples these with the numeric
+ // values of the internal GLTYPE_* constants)
+ {"-1", GLTYPE_AUTO},
+ { "0", GLTYPE_W32},
+ { "1", GLTYPE_X11},
+ { "2", GLTYPE_SDL},
+
+ {0}
+};
+
+int mpgl_find_backend(const char *name)
+{
+ for (const struct backend *entry = backends; entry->name; entry++) {
+ if (strcmp(entry->name, name) == 0)
+ return entry->type;
+ }
+ return -1;
+}
+
MPGLContext *init_mpglcontext(enum MPGLType type, struct vo *vo)
{
MPGLContext *ctx;
diff --git a/libvo/gl_common.h b/libvo/gl_common.h
index 8563edac7e..d0b447fab7 100644
--- a/libvo/gl_common.h
+++ b/libvo/gl_common.h
@@ -399,6 +399,8 @@ typedef struct MPGLContext {
void (*ontop)(struct vo *vo);
} MPGLContext;
+int mpgl_find_backend(const char *name);
+
MPGLContext *init_mpglcontext(enum MPGLType type, struct vo *vo);
void uninit_mpglcontext(MPGLContext *ctx);
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 48cfb2a609..1099fdffec 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -84,7 +84,6 @@ extern struct vo_driver video_out_vdpau;
extern struct vo_driver video_out_xv;
extern struct vo_driver video_out_gl_nosw;
extern struct vo_driver video_out_gl;
-extern struct vo_driver video_out_gl_sdl;
extern struct vo_driver video_out_dga;
extern struct vo_driver video_out_sdl;
extern struct vo_driver video_out_3dfx;
@@ -181,9 +180,6 @@ const struct vo_driver *video_out_drivers[] =
#ifdef CONFIG_GL
&video_out_gl,
#endif
-#ifdef CONFIG_GL_SDL
- &video_out_gl_sdl,
-#endif
#ifdef CONFIG_DGA
&video_out_dga,
#endif
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index 99a953fcf7..6010c9766b 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -1183,8 +1183,12 @@ static void uninit(struct vo *vo)
p->gl = NULL;
}
-static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
- enum MPGLType gltype)
+static int backend_valid(void *arg)
+{
+ return mpgl_find_backend(*(const char **)arg) >= 0;
+}
+
+static int preinit_internal(struct vo *vo, const char *arg, int allow_sw)
{
struct gl_priv *p = talloc_zero(vo, struct gl_priv);
vo->priv = p;
@@ -1211,6 +1215,7 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
int user_colorspace = 0;
int levelconv = -1;
int aspect = -1;
+ char *backend_arg = NULL;
const opt_t subopts[] = {
{"manyfmts", OPT_ARG_BOOL, &p->many_fmts, NULL},
@@ -1235,6 +1240,7 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
{"mipmapgen", OPT_ARG_BOOL, &p->mipmap_gen, NULL},
{"osdcolor", OPT_ARG_INT, &p->osd_color, NULL},
{"stereo", OPT_ARG_INT, &p->stereo_mode, NULL},
+ {"backend", OPT_ARG_MSTRZ,&backend_arg, backend_valid},
// Removed options.
// They are only parsed to notify the user about the replacements.
{"aspect", OPT_ARG_BOOL, &aspect, NULL},
@@ -1310,6 +1316,12 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
" 1: side-by-side to red-cyan stereo\n"
" 2: side-by-side to green-magenta stereo\n"
" 3: side-by-side to quadbuffer stereo\n"
+ " backend=<sys>\n"
+ " auto: auto-select (default)\n"
+ " cocoa: Cocoa/OSX\n"
+ " win: Win32/WGL\n"
+ " x11: X11/GLX\n"
+ " sdl: SDL\n"
"\n");
return -1;
}
@@ -1329,7 +1341,11 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
" been removed, using yuv=2 instead.\n");
p->use_yuv = 2;
}
- p->glctx = init_mpglcontext(gltype, vo);
+
+ int backend = backend_arg ? mpgl_find_backend(backend_arg) : GLTYPE_AUTO;
+ free(backend_arg);
+
+ p->glctx = init_mpglcontext(backend, vo);
if (!p->glctx)
goto err_out;
p->gl = p->glctx->gl;
@@ -1353,7 +1369,7 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
// acceleration and so on. Destroy that window to make sure all state
// associated with it is lost.
uninit(vo);
- p->glctx = init_mpglcontext(gltype, vo);
+ p->glctx = init_mpglcontext(backend, vo);
if (!p->glctx)
goto err_out;
p->gl = p->glctx->gl;
@@ -1373,7 +1389,7 @@ err_out:
static int preinit(struct vo *vo, const char *arg)
{
- return preinit_internal(vo, arg, 1, GLTYPE_AUTO);
+ return preinit_internal(vo, arg, 1);
}
static int control(struct vo *vo, uint32_t request, void *data)
@@ -1498,7 +1514,7 @@ const struct vo_driver video_out_gl = {
static int preinit_nosw(struct vo *vo, const char *arg)
{
- return preinit_internal(vo, arg, 0, GLTYPE_AUTO);
+ return preinit_internal(vo, arg, 0);
}
const struct vo_driver video_out_gl_nosw =
@@ -1519,28 +1535,3 @@ const struct vo_driver video_out_gl_nosw =
.check_events = check_events,
.uninit = uninit,
};
-
-#ifdef CONFIG_GL_SDL
-static int preinit_sdl(struct vo *vo, const char *arg)
-{
- return preinit_internal(vo, arg, 1, GLTYPE_SDL);
-}
-
-const struct vo_driver video_out_gl_sdl = {
- .is_new = true,
- .info = &(const vo_info_t) {
- "OpenGL with SDL",
- "gl_sdl",
- "Reimar Doeffinger <Reimar.Doeffinger@gmx.de>",
- ""
- },
- .preinit = preinit_sdl,
- .config = config,
- .control = control,
- .draw_slice = draw_slice,
- .draw_osd = draw_osd,
- .flip_page = flip_page,
- .check_events = check_events,
- .uninit = uninit,
-};
-#endif