static void uninit(struct vo *vo) { struct gl_priv *p = vo->priv; if (p->glctx) { if (p->renderer) gl_video_uninit(p->renderer); mpgl_uninit(p->glctx); } }
static void uninit(struct vo *vo) { struct gl_priv *p = vo->priv; gl_video_uninit(p->renderer); gl_hwdec_uninit(p->hwdec); hwdec_devices_set_loader(vo->hwdec_devs, NULL, NULL); hwdec_devices_destroy(vo->hwdec_devs); mpgl_uninit(p->glctx); }
static MPGLContext *init_backend(struct vo *vo, const struct mpgl_driver *driver, bool probing, int vo_flags) { MPGLContext *ctx = talloc_ptrtype(NULL, ctx); *ctx = (MPGLContext) { .gl = talloc_zero(ctx, GL), .vo = vo, .driver = driver, }; if (probing) vo_flags |= VOFLAG_PROBING; bool old_probing = vo->probing; vo->probing = probing; // hack; kill it once backends are separate MP_VERBOSE(vo, "Initializing OpenGL backend '%s'\n", ctx->driver->name); ctx->priv = talloc_zero_size(ctx, ctx->driver->priv_size); if (ctx->driver->init(ctx, vo_flags) < 0) { vo->probing = old_probing; talloc_free(ctx); return NULL; } vo->probing = old_probing; if (!ctx->gl->version && !ctx->gl->es) goto cleanup; if (probing && ctx->gl->es && (vo_flags & VOFLAG_NO_GLES)) { MP_VERBOSE(ctx->vo, "Skipping GLES backend.\n"); goto cleanup; } if (ctx->gl->mpgl_caps & MPGL_CAP_SW) { MP_WARN(ctx->vo, "Suspected software renderer or indirect context.\n"); if (vo->probing && !(vo_flags & VOFLAG_SW)) goto cleanup; } ctx->gl->debug_context = !!(vo_flags & VOFLAG_GL_DEBUG); set_current_context(ctx); return ctx; cleanup: mpgl_uninit(ctx); return NULL; } // Create a VO window and create a GL context on it. // vo_flags: passed to the backend's create window function MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, int vo_flags) { MPGLContext *ctx = NULL; int index = mpgl_find_backend(backend_name); if (index == -1) { for (int n = 0; n < MP_ARRAY_SIZE(backends); n++) { ctx = init_backend(vo, backends[n], true, vo_flags); if (ctx) break; } // VO forced, but no backend is ok => force the first that works at all if (!ctx && !vo->probing) { for (int n = 0; n < MP_ARRAY_SIZE(backends); n++) { ctx = init_backend(vo, backends[n], false, vo_flags); if (ctx) break; } } } else if (index >= 0) { ctx = init_backend(vo, backends[index], false, vo_flags); } return ctx; }