detector: verify if format is supported

This patch adds verification if sample width is
supported by detector.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This commit is contained in:
Marcin Rajwa 2019-07-25 16:35:40 +02:00 committed by Janusz Jankowski
parent 6115724ce8
commit b2c6dc7425
1 changed files with 22 additions and 1 deletions

View File

@ -26,6 +26,7 @@
#include <user/detect_test.h>
#include <user/trace.h>
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
@ -76,6 +77,26 @@ struct comp_data {
struct comp_buffer *source, uint32_t frames);
};
static inline bool detector_is_sample_width_supported(enum sof_ipc_frame sf)
{
bool ret;
switch (sf) {
case SOF_IPC_FRAME_S16_LE:
/* FALLTHRU */
case SOF_IPC_FRAME_S24_4LE:
/* FALLTHRU */
case SOF_IPC_FRAME_S32_LE:
ret = true;
break;
default:
ret = false;
break;
}
return ret;
}
static void notify_host(struct comp_dev *dev)
{
struct sof_ipc_comp_event event;
@ -317,7 +338,7 @@ static int test_keyword_params(struct comp_dev *dev)
return -EINVAL;
}
if (dev->params.frame_fmt != SOF_IPC_FRAME_S16_LE) {
if (!detector_is_sample_width_supported(dev->params.frame_fmt)) {
trace_keyword_error("test_keyword_params() "
"error: only 16-bit format supported");
return -EINVAL;