Commit ceebb977 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

vdpau: context structure for video surfaces

parent 99d6ce3b
/*****************************************************************************
* picture.c: VDPAU instance management for VLC
*****************************************************************************
* Copyright (C) 2013 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <vlc_common.h>
#include <vlc_picture.h>
#include "vlc_vdpau.h"
#pragma GCC visibility push(default)
static void SurfaceDestroy(void *opaque)
{
vlc_vdp_video_t *ctx = opaque;
VdpStatus err;
err = vdp_video_surface_destroy(ctx->vdp, ctx->surface);
if (err != VDP_STATUS_OK)
fprintf(stderr, "video surface destruction failure: %s\n",
vdp_get_error_string(ctx->vdp, err));
vdp_release_x11(ctx->vdp);
free(ctx);
}
VdpStatus vlc_vdp_video_attach(vdp_t *vdp, VdpVideoSurface surface,
picture_t *pic)
{
vlc_vdp_video_t *ctx = malloc(sizeof (*ctx));
if (unlikely(ctx == NULL))
{
vdp_video_surface_destroy(vdp, surface);
return VDP_STATUS_RESOURCES;
}
ctx->destroy = SurfaceDestroy;
ctx->surface = surface;
ctx->vdp = vdp_hold_x11(vdp, &ctx->device);
assert(pic->context == NULL);
pic->context = ctx;
return VDP_STATUS_OK;
}
......@@ -244,4 +244,19 @@ struct picture_sys_t
VdpDevice device;
const vdp_t *vdp;
};
typedef struct vlc_vdp_video
{
void (*destroy)(void *); /* must be first @ref picture_Release() */
VdpVideoSurface surface;
VdpDevice device;
vdp_t *vdp;
} vlc_vdp_video_t;
/**
* Attaches a VDPAU video surface as context of a VLC picture.
* @note In case of error, the surface is destroyed immediately. Otherwise,
* it will be destroyed at the same time as the picture it was attached to.
*/
VdpStatus vlc_vdp_video_attach(vdp_t *, VdpVideoSurface, picture_t *);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment