From 9f6dfaabf99b29b1b9caaf9e2a97128964a01b05 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 8 Feb 2016 13:39:33 +0100 Subject: [PATCH] vo_opengl: vdpau: call glVDPAUFiniNV only if initialized This is "more correct". See #2798. --- video/out/opengl/hwdec_vdpau.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/video/out/opengl/hwdec_vdpau.c b/video/out/opengl/hwdec_vdpau.c index 2396d8ad5d..b1d49622fc 100644 --- a/video/out/opengl/hwdec_vdpau.c +++ b/video/out/opengl/hwdec_vdpau.c @@ -37,6 +37,7 @@ struct priv { uint64_t preemption_counter; struct mp_image_params image_params; GLuint gl_texture; + bool vdpgl_initialized; GLvdpauSurfaceNV vdpgl_surface; VdpOutputSurface vdp_surface; struct mp_vdpau_mixer *mixer; @@ -78,13 +79,12 @@ static void destroy_objects(struct gl_hwdec *hw) glCheckError(gl, hw->log, "Before uninitializing OpenGL interop"); - gl->VDPAUFiniNV(); + if (p->vdpgl_initialized) + gl->VDPAUFiniNV(); - // If the GL/vdpau state is not initialized, above calls raises an error. - while (1) { - if (gl->GetError() == GL_NO_ERROR) - break; - } + p->vdpgl_initialized = false; + + glCheckError(gl, hw->log, "After uninitializing OpenGL interop"); } static void destroy(struct gl_hwdec *hw) @@ -142,6 +142,8 @@ static int reinit(struct gl_hwdec *hw, struct mp_image_params *params) gl->VDPAUInitNV(BRAINDEATH(p->ctx->vdp_device), p->ctx->get_proc_address); + p->vdpgl_initialized = true; + vdp_st = vdp->output_surface_create(p->ctx->vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, params->w, params->h, &p->vdp_surface);