1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 00:42:57 +00:00

vo_vdpau: fix loop initializing output surfaces as invalid

The loop initializing handles in the output surface table to
VDP_INVALID_HANDLE ran over indices from 0 to vc->num_output_surfaces.
However it is first called before that variable is initialized. As a
result later code could try to destroy the handles which still had the
"non-invalid" value 0. Most likely this caused no visible effects; at
least on my machine no valid surface gets handle 0, and libvdpau just
returns an error for the resulting invalid calls. Change the code to
loop over the whole table. Also add code to print visible warnings if
libvdpau rejects a surface destroy call (some other places already had
checks but not all).
This commit is contained in:
Uoti Urpala 2010-05-26 08:54:09 +03:00
parent aa07b6d578
commit 2e8ef70d4f

View File

@ -409,8 +409,11 @@ static void resize(struct vo *vo)
}
// Creation of output_surfaces
for (i = 0; i <= vc->num_output_surfaces; i++) {
if (vc->output_surfaces[i] != VDP_INVALID_HANDLE)
vdp->output_surface_destroy(vc->output_surfaces[i]);
if (vc->output_surfaces[i] != VDP_INVALID_HANDLE) {
vdp_st = vdp->output_surface_destroy(vc->output_surfaces[i]);
CHECK_ST_WARNING("Error when calling "
"vdp_output_surface_destroy");
}
vdp_st = vdp->output_surface_create(vc->vdp_device,
VDP_RGBA_FORMAT_B8G8R8A8,
vc->output_surface_width,
@ -811,7 +814,7 @@ static void mark_vdpau_objects_uninitialized(struct vo *vo)
vc->video_mixer = VDP_INVALID_HANDLE;
vc->flip_queue = VDP_INVALID_HANDLE;
vc->flip_target = VDP_INVALID_HANDLE;
for (int i = 0; i <= vc->num_output_surfaces; i++)
for (int i = 0; i <= MAX_OUTPUT_SURFACES; i++)
vc->output_surfaces[i] = VDP_INVALID_HANDLE;
vc->vdp_device = VDP_INVALID_HANDLE;
vc->eosd_surface = (struct eosd_bitmap_surface){
@ -1211,8 +1214,10 @@ static void generate_eosd(struct vo *vo, mp_eosd_images_t *imgs)
reallocate = true;
}
if (reallocate) {
if (sfc->surface != VDP_INVALID_HANDLE)
vdp->bitmap_surface_destroy(sfc->surface);
if (sfc->surface != VDP_INVALID_HANDLE) {
vdp_st = vdp->bitmap_surface_destroy(sfc->surface);
CHECK_ST_WARNING("Error when calling vdp_bitmap_surface_destroy");
}
mp_msg(MSGT_VO, MSGL_V, "[vdpau] Allocating a %dx%d surface for "
"EOSD bitmaps.\n", sfc->w, sfc->h);
vdp_st = vdp->bitmap_surface_create(vc->vdp_device, VDP_RGBA_FORMAT_A8,