1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avutil/hwcontext_vulkan: Fix leaks when semaphore creation fails

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
Zhao Zhili 2024-02-22 22:42:42 +08:00
parent 3bb00c0a42
commit 6f9730cb28

View File

@ -1807,16 +1807,22 @@ static void vulkan_frame_free(AVHWFramesContext *hwfc, AVVkFrame *f)
VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
FFVulkanFunctions *vk = &p->vkctx.vkfn;
int nb_images = ff_vk_count_images(f);
int nb_sems = 0;
VkSemaphoreWaitInfo sem_wait = {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
.flags = 0x0,
.pSemaphores = f->sem,
.pValues = f->sem_value,
.semaphoreCount = nb_images,
};
while (nb_sems < FF_ARRAY_ELEMS(f->sem) && f->sem[nb_sems])
nb_sems++;
vk->WaitSemaphores(hwctx->act_dev, &sem_wait, UINT64_MAX);
if (nb_sems) {
VkSemaphoreWaitInfo sem_wait = {
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
.flags = 0x0,
.pSemaphores = f->sem,
.pValues = f->sem_value,
.semaphoreCount = nb_sems,
};
vk->WaitSemaphores(hwctx->act_dev, &sem_wait, UINT64_MAX);
}
vulkan_free_internal(f);
@ -2098,7 +2104,8 @@ static int create_frame(AVHWFramesContext *hwfc, AVVkFrame **frame,
if (ret != VK_SUCCESS) {
av_log(hwctx, AV_LOG_ERROR, "Failed to create semaphore: %s\n",
ff_vk_ret2str(ret));
return AVERROR_EXTERNAL;
err = AVERROR_EXTERNAL;
goto fail;
}
f->queue_family[i] = p->nb_img_qfs > 1 ? VK_QUEUE_FAMILY_IGNORED : p->img_qfs[0];