Commit bf697698 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vdpau: use custom picture destroy callback

parent 1a5c86d8
...@@ -52,8 +52,6 @@ vlc_module_begin() ...@@ -52,8 +52,6 @@ vlc_module_begin()
add_shortcut("vdpau", "xid") add_shortcut("vdpau", "xid")
vlc_module_end() vlc_module_end()
#define MAX_PICTURES (32)
struct vout_display_sys_t struct vout_display_sys_t
{ {
xcb_connection_t *conn; /**< XCB connection */ xcb_connection_t *conn; /**< XCB connection */
...@@ -69,47 +67,73 @@ struct vout_display_sys_t ...@@ -69,47 +67,73 @@ struct vout_display_sys_t
VdpRGBAFormat rgb_fmt; /**< Output surface format */ VdpRGBAFormat rgb_fmt; /**< Output surface format */
picture_pool_t *pool; /**< pictures pool */ picture_pool_t *pool; /**< pictures pool */
picture_sys_t *pics[MAX_PICTURES];
}; };
static picture_pool_t *PoolAlloc(vout_display_t *vd, unsigned requested_count) static void pictureSys_DestroyVDPAU(picture_sys_t *psys)
{ {
vout_display_sys_t *sys = vd->sys; vdp_output_surface_destroy(psys->vdp, psys->surface);
const video_format_t *fmt = &vd->fmt; vdp_release_x11(psys->vdp);
picture_t *pics[MAX_PICTURES]; free(psys);
picture_resource_t res = { .p_sys = NULL }; }
if (requested_count > MAX_PICTURES) static void PictureDestroyVDPAU(picture_t *pic)
requested_count = MAX_PICTURES; {
pictureSys_DestroyVDPAU(pic->p_sys);
free(pic);
}
unsigned count = 0; static VdpStatus picture_NewVDPAU(vdp_t *vdp, VdpRGBAFormat rgb_fmt,
while (count < requested_count) const video_format_t *restrict fmt,
{ picture_t **restrict picp)
{
picture_sys_t *psys = malloc(sizeof (*psys)); picture_sys_t *psys = malloc(sizeof (*psys));
if (unlikely(psys == NULL)) if (unlikely(psys == NULL))
break; return VDP_STATUS_RESOURCES;
psys->vdp = vdp_hold_x11(vdp, &psys->device);
VdpStatus err = vdp_output_surface_create(sys->vdp, sys->device, VdpStatus err = vdp_output_surface_create(psys->vdp, psys->device,
sys->rgb_fmt, fmt->i_visible_width, fmt->i_visible_height, rgb_fmt, fmt->i_visible_width, fmt->i_visible_height,
&psys->surface); &psys->surface);
if (err != VDP_STATUS_OK) if (err != VDP_STATUS_OK)
{ {
vdp_release_x11(psys->vdp);
free(psys); free(psys);
msg_Err(vd, "%s creation failure: %s", "output surface", return err;
vdp_get_error_string(sys->vdp, err));
break;
} }
psys->device = sys->device;
psys->vdp = sys->vdp;
res.p_sys = psys; picture_resource_t res = {
pics[count] = picture_NewFromResource(&vd->fmt, &res); .p_sys = psys,
if (pics[count] == NULL) .pf_destroy = PictureDestroyVDPAU,
};
picture_t *pic = picture_NewFromResource(fmt, &res);
if (unlikely(pic == NULL))
{ {
free(psys); pictureSys_DestroyVDPAU(psys);
return VDP_STATUS_RESOURCES;
}
*picp = pic;
return VDP_STATUS_OK;
}
static picture_pool_t *PoolAlloc(vout_display_t *vd, unsigned requested_count)
{
vout_display_sys_t *sys = vd->sys;
picture_t *pics[requested_count];
unsigned count = 0;
while (count < requested_count)
{
VdpStatus err = picture_NewVDPAU(sys->vdp, sys->rgb_fmt, &vd->fmt,
pics + count);
if (err != VDP_STATUS_OK)
{
msg_Err(vd, "%s creation failure: %s", "output surface",
vdp_get_error_string(sys->vdp, err));
break; break;
} }
sys->pics[count++] = res.p_sys; count++;
} }
sys->current = NULL; sys->current = NULL;
return count ? picture_pool_New(count, pics) : NULL; return count ? picture_pool_New(count, pics) : NULL;
...@@ -119,17 +143,6 @@ static void PoolFree(vout_display_t *vd, picture_pool_t *pool) ...@@ -119,17 +143,6 @@ static void PoolFree(vout_display_t *vd, picture_pool_t *pool)
{ {
vout_display_sys_t *sys = vd->sys; vout_display_sys_t *sys = vd->sys;
for (unsigned count = 0; count < MAX_PICTURES; count++)
{
picture_sys_t *psys = sys->pics[count];
if (psys == NULL)
continue;
VdpStatus err = vdp_output_surface_destroy(sys->vdp, psys->surface);
if (err != VDP_STATUS_OK)
msg_Err(vd, "%s destruction failure: %s", "output surface",
vdp_get_error_string(sys->vdp, err));
}
if (sys->current != NULL) if (sys->current != NULL)
picture_Release(sys->current); picture_Release(sys->current);
picture_pool_Delete(pool); picture_pool_Delete(pool);
...@@ -626,8 +639,6 @@ static int Open(vlc_object_t *obj) ...@@ -626,8 +639,6 @@ static int Open(vlc_object_t *obj)
sys->cursor = XCB_cursor_Create(sys->conn, screen); sys->cursor = XCB_cursor_Create(sys->conn, screen);
sys->pool = NULL; sys->pool = NULL;
for (unsigned count = 0; count < MAX_PICTURES; count++)
sys->pics[count] = NULL;
/* */ /* */
vd->sys = sys; vd->sys = sys;
......
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