vo_dmabuf_wayland: close file handles when surface export fails

file handles may still be opened despite failure
This commit is contained in:
Aaron Boxer 2023-01-26 14:18:17 -05:00 committed by sfan5
parent e3618002e3
commit 881f820fdf
1 changed files with 9 additions and 2 deletions

View File

@ -74,6 +74,12 @@ static uintptr_t vaapi_key_provider(struct mp_image *src)
return va_surface_id(src);
}
static void close_file_descriptors(VADRMPRIMESurfaceDescriptor desc)
{
for (int i = 0; i < desc.num_objects; i++)
close(desc.objects[i].fd);
}
/* va-api dmabuf importer */
static bool vaapi_dmabuf_importer(struct mp_image *src, struct wlbuf_pool_entry* entry,
struct zwp_linux_buffer_params_v1 *params)
@ -89,6 +95,8 @@ static bool vaapi_dmabuf_importer(struct mp_image *src, struct wlbuf_pool_entry*
/* invalid surface warning => composed layers not supported */
if (status == VA_STATUS_ERROR_INVALID_SURFACE)
MP_VERBOSE(entry->vo, "vaExportSurfaceHandle: composed layers not supported.\n");
close_file_descriptors(desc);
return false;
}
bool success = false;
@ -108,8 +116,7 @@ static bool vaapi_dmabuf_importer(struct mp_image *src, struct wlbuf_pool_entry*
success = true;
done:
for (int i = 0; i < desc.num_objects; i++)
close(desc.objects[i].fd);
close_file_descriptors(desc);
return success;
}