From 2f165ee12ba2ebd64cb11224563faa08ecb83e17 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Sep 2013 18:33:43 +0200 Subject: gl_common: signal to GL backend whether we are probing This is supposed to reduce the amount of useless error messages shown during initialization of vo_opengl. If multiple backends are compiled, usually only one of them will work. For example, on Linux both X and Wayland backends can be compiled, but usually either Wayland or X is running. Then, if Wayland is not running, but X is, trying to initialize the Wayland backend should not spam the terminal with error messages. Signed-off-by: Andreas Sinz --- video/out/gl_common.c | 11 +++++++---- video/out/vo.h | 2 ++ video/out/wayland_common.c | 6 ++++-- video/out/x11_common.c | 4 +++- 4 files changed, 16 insertions(+), 7 deletions(-) (limited to 'video') diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 648d4462e8..48b1089147 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -893,18 +893,21 @@ int mpgl_validate_backend_opt(const struct m_option *opt, struct bstr name, return mpgl_find_backend(s) >= -1 ? 1 : M_OPT_INVALID; } -static MPGLContext *init_backend(struct vo *vo, MPGLSetBackendFn set_backend) +static MPGLContext *init_backend(struct vo *vo, MPGLSetBackendFn set_backend, + bool probing) { MPGLContext *ctx = talloc_ptrtype(NULL, ctx); *ctx = (MPGLContext) { .gl = talloc_zero(ctx, GL), .vo = vo, }; + vo->probing = probing; set_backend(ctx); if (!ctx->vo_init(vo)) { talloc_free(ctx); ctx = NULL; } + vo->probing = false; return ctx; } @@ -914,12 +917,12 @@ MPGLContext *mpgl_init(struct vo *vo, const char *backend_name) int index = mpgl_find_backend(backend_name); if (index == -1) { for (const struct backend *entry = backends; entry->name; entry++) { - ctx = init_backend(vo, entry->init); + ctx = init_backend(vo, entry->init, true); if (ctx) - return ctx; + break; } } else if (index >= 0) { - ctx = init_backend(vo, backends[index].init); + ctx = init_backend(vo, backends[index].init, false); } return ctx; } diff --git a/video/out/vo.h b/video/out/vo.h index 8bb1bd5617..50e83d2809 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -239,6 +239,8 @@ struct vo { int config_ok; // Last config call was successful? int config_count; // Total number of successful config calls + bool probing; + bool untimed; // non-interactive, don't do sleep calls in playloop bool frame_loaded; // Is there a next frame the VO could flip to? diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 96277551c5..533b8c056d 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -593,8 +593,10 @@ static bool create_display (struct vo_wayland_state *wl) wl->display.display = wl_display_connect(NULL); if (!wl->display.display) { - MP_ERR(wl->vo, "failed to connect to a wayland server: " - "check if a wayland compositor is running\n"); + MP_MSG(wl, wl->vo->probing ? MSGL_V : MSGL_ERR, + "failed to connect to a wayland server: " + "check if a wayland compositor is running\n"); + return false; } diff --git a/video/out/x11_common.c b/video/out/x11_common.c index b86d1ce661..8c6ddae3ea 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -462,7 +462,9 @@ int vo_x11_init(struct vo *vo) x11->display = XOpenDisplay(dispName); if (!x11->display) { - MP_ERR(x11, "couldn't open the X11 display (%s)!\n", dispName); + MP_MSG(x11, vo->probing ? MSGL_V : MSGL_ERR, + "vo: couldn't open the X11 display (%s)!\n", dispName); + talloc_free(x11); vo->x11 = NULL; return 0; -- cgit v1.2.3