From dd4f006b5f57ad6f7f8bde3335ba709f7d8d2b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 3 Aug 2025 10:14:53 +0800 Subject: [PATCH] GPU: support `"hideType": null` --- src/modules/gpu/gpu.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index b608dc300..58392af1e 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -240,18 +240,23 @@ void ffParseGPUJsonObject(FFGPUOptions* options, yyjson_val* module) if (unsafe_yyjson_equals_str(key, "hideType")) { - int value; - const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { - { "none", FF_GPU_TYPE_NONE }, - { "unknown", FF_GPU_TYPE_UNKNOWN }, - { "integrated", FF_GPU_TYPE_INTEGRATED }, - { "discrete", FF_GPU_TYPE_DISCRETE }, - {}, - }); - if (error) - ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); + if (yyjson_is_null(val)) + options->hideType = FF_GPU_TYPE_NONE; else - options->hideType = (FFGPUType) value; + { + int value; + const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { + { "none", FF_GPU_TYPE_NONE }, + { "unknown", FF_GPU_TYPE_UNKNOWN }, + { "integrated", FF_GPU_TYPE_INTEGRATED }, + { "discrete", FF_GPU_TYPE_DISCRETE }, + {}, + }); + if (error) + ffPrintError(FF_GPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Invalid %s value: %s", unsafe_yyjson_get_str(key), error); + else + options->hideType = (FFGPUType) value; + } continue; }