1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-09 08:27:18 +00:00

vo_opengl: hwdec_vdpau: remove minor code duplication

Move unmap() to the top of the function, and replace some duplicated
code with a call to it.
This commit is contained in:
wm4 2016-06-08 22:16:32 +02:00
parent ff37d7efec
commit 4123c9642d

View File

@ -44,6 +44,16 @@ struct priv {
bool mapped;
};
static void unmap(struct gl_hwdec *hw)
{
struct priv *p = hw->priv;
GL *gl = hw->gl;
if (p->mapped)
gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface);
p->mapped = false;
}
static void mark_vdpau_objects_uninitialized(struct gl_hwdec *hw)
{
struct priv *p = hw->priv;
@ -59,9 +69,7 @@ static void destroy_objects(struct gl_hwdec *hw)
struct vdp_functions *vdp = &p->ctx->vdp;
VdpStatus vdp_st;
if (p->mapped)
gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface);
p->mapped = false;
unmap(hw);
if (p->vdpgl_surface)
gl->VDPAUUnregisterSurfaceNV(p->vdpgl_surface);
@ -206,16 +214,6 @@ static int map_frame(struct gl_hwdec *hw, struct mp_image *hw_image,
return 0;
}
static void unmap(struct gl_hwdec *hw)
{
struct priv *p = hw->priv;
GL *gl = hw->gl;
if (p->mapped)
gl->VDPAUUnmapSurfacesNV(1, &p->vdpgl_surface);
p->mapped = false;
}
const struct gl_hwdec_driver gl_hwdec_vdpau = {
.name = "vdpau-glx",
.api = HWDEC_VDPAU,