From 784da5468e70a59c5b84c487e2eab67c289f69cb Mon Sep 17 00:00:00 2001 From: Serhiy Katsyuba Date: Tue, 16 Apr 2024 17:03:02 +0200 Subject: [PATCH] detect_test: Do not overwrite supplied threshold Default threshold should be applied only if it was not already set via IPC4_DETECT_TEST_SET_CONFIG call. Signed-off-by: Serhiy Katsyuba --- src/samples/audio/detect_test.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/samples/audio/detect_test.c b/src/samples/audio/detect_test.c index 88a32301c..0ea23e95f 100644 --- a/src/samples/audio/detect_test.c +++ b/src/samples/audio/detect_test.c @@ -836,19 +836,25 @@ static int test_keyword_params(struct comp_dev *dev, cd->keyphrase_samples = KEYPHRASE_DEFAULT_PREAMBLE_LENGTH; } - err = test_keyword_get_threshold(dev, params->sample_valid_bytes * 8); - if (err < 0) { - comp_err(dev, "test_keyword_params(): unsupported sample width %u", - params->sample_valid_bytes * 8); - return err; + /* + * Threshold might be already set via IPC4_DETECT_TEST_SET_CONFIG, + * otherwise apply default value. + */ + if (!cd->config.activation_threshold) { + err = test_keyword_get_threshold(dev, params->sample_valid_bytes * 8); + if (err < 0) { + comp_err(dev, "test_keyword_params(): unsupported sample width %u", + params->sample_valid_bytes * 8); + return err; + } + + cd->config.activation_threshold = err; } #if CONFIG_AMS cd->kpd_uuid_id = AMS_INVALID_MSG_TYPE; #endif /* CONFIG_AMS */ - cd->config.activation_threshold = err; - return 0; }