From f3284302a70e18208fef73ebd68b28dcc74ec2c6 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 20 Sep 2024 18:59:37 +0200 Subject: Dont crash on error in nvenc query --- src/encoder/video/cuda.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/encoder') diff --git a/src/encoder/video/cuda.c b/src/encoder/video/cuda.c index 543a1ca..858f912 100644 --- a/src/encoder/video/cuda.c +++ b/src/encoder/video/cuda.c @@ -287,6 +287,7 @@ static gsr_supported_video_codecs gsr_video_encoder_cuda_get_supported_codecs(gs (void)encoder; void *nvenc_lib = NULL; + void *nvenc_encoder = NULL; gsr_cuda cuda; memset(&cuda, 0, sizeof(cuda)); gsr_supported_video_codecs supported_video_codecs = {0}; @@ -321,8 +322,6 @@ static gsr_supported_video_codecs gsr_video_encoder_cuda_get_supported_codecs(gs params.deviceType = NV_ENC_DEVICE_TYPE_CUDA; params.device = cuda.cu_ctx; params.apiVersion = NVENCAPI_VERSION; - - void *nvenc_encoder = NULL; if(function_list.nvEncOpenEncodeSessionEx(¶ms, &nvenc_encoder) != NV_ENC_SUCCESS) { // Old nvidia gpus dont support the new nvenc api (which is required for av1). // In such cases fallback to old api version if possible and try again. @@ -344,7 +343,8 @@ static gsr_supported_video_codecs gsr_video_encoder_cuda_get_supported_codecs(gs done: if(cleanup) { - function_list.nvEncDestroyEncoder(nvenc_encoder); + if(nvenc_encoder) + function_list.nvEncDestroyEncoder(nvenc_encoder); if(nvenc_lib) dlclose(nvenc_lib); gsr_cuda_unload(&cuda); -- cgit v1.2.3