aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-09-20 18:59:37 +0200
committerdec05eba <dec05eba@protonmail.com>2024-09-20 18:59:37 +0200
commitf3284302a70e18208fef73ebd68b28dcc74ec2c6 (patch)
tree9d436eddbc0671960004d3466f6accc70b29a06c
parent559a881dfdbcac547627d3155736cf653b76870c (diff)
Dont crash on error in nvenc query
-rw-r--r--src/encoder/video/cuda.c6
1 files changed, 3 insertions, 3 deletions
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(&params, &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);