Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smart_amp_test: fix crash due to different source formats #9020

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions src/samples/audio/smart_amp_test_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,35 @@ static int smart_amp_reset(struct processing_module *mod)
return 0;
}

static smart_amp_proc get_smart_amp_process(struct sof_sink *sink)
static smart_amp_proc get_smart_amp_process(struct sof_source **sources, int num_of_sources,
struct sof_sink **sinks, int num_of_sinks)
{
switch (sink_get_frm_fmt(sink)) {
case SOF_IPC_FRAME_S16_LE:
return process_s16;
case SOF_IPC_FRAME_S24_4LE:
case SOF_IPC_FRAME_S32_LE:
return process_s32;
default:
LOG_ERR("smart_amp_process() error: not supported frame format");
return NULL;
/* Find if any of the sources/sinks needs 16bit process, else use 32bit */
for (int i = 0; i < num_of_sources; i++) {
switch (source_get_frm_fmt(sources[i])) {
case SOF_IPC_FRAME_S16_LE:
return process_s16;
lgirdwood marked this conversation as resolved.
Show resolved Hide resolved
case SOF_IPC_FRAME_S24_4LE:
case SOF_IPC_FRAME_S32_LE:
break;
default:
LOG_ERR("smart_amp_process() error: not supported frame format");
return NULL;
}
}
for (int i = 0; i < num_of_sinks; i++) {
switch (sink_get_frm_fmt(sinks[i])) {
case SOF_IPC_FRAME_S16_LE:
return process_s16;
case SOF_IPC_FRAME_S24_4LE:
case SOF_IPC_FRAME_S32_LE:
break;
default:
LOG_ERR("smart_amp_process() error: not supported frame format");
return NULL;
}
}
return process_s32;
lgirdwood marked this conversation as resolved.
Show resolved Hide resolved
}

static int smart_amp_prepare(struct processing_module *mod,
Expand All @@ -341,7 +358,7 @@ static int smart_amp_prepare(struct processing_module *mod,

LOG_DBG("smart_amp_prepare()");

sad->process = get_smart_amp_process(sinks[0]);
sad->process = get_smart_amp_process(sources, num_of_sources, sinks, num_of_sinks);
if (!sad->process) {
LOG_ERR("smart_amp_prepare(): get_smart_amp_process failed");
return -EINVAL;
Expand Down