Skip to content

Commit a5b41ae

Browse files
author
Jyri Sarha
committed
audio: src: validate stream parameters at prepare time
Check that the source stream rate and channel count at prepare match what was used to initialize the filter stages and delay lines. Since these allocations now happen at init and persist across prepare/reset cycles, a mismatch would cause incorrect processing or buffer overruns. Also compare rates against the actual source stream rather than only the IPC config, catching cases where the upstream pipeline delivers a different rate than originally configured. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent c18e622 commit a5b41ae

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/audio/src/src_ipc4.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,21 @@ int src_do_prepare(struct processing_module *mod,
285285
{
286286
struct comp_data *cd = module_get_private_data(mod);
287287
struct comp_dev *dev = mod->dev;
288+
unsigned int source_channels = source_get_channels(source);
289+
unsigned int source_rate = source_get_rate(source);
288290
int ret;
289291

290-
if (cd->source_rate != cd->ipc_config.base.audio_fmt.sampling_frequency ||
292+
if (cd->source_rate != source_rate ||
291293
cd->sink_rate != cd->ipc_config.sink_rate) {
292-
comp_err(mod->dev, "rate mismatch: source %u/%u sink %u/%u",
293-
cd->source_rate,
294-
cd->ipc_config.base.audio_fmt.sampling_frequency,
295-
cd->sink_rate, cd->ipc_config.sink_rate);
294+
comp_err(dev, "rate mismatch: init %u/%u, stream %u/%u",
295+
cd->source_rate, cd->sink_rate,
296+
source_rate, cd->ipc_config.sink_rate);
297+
return -EINVAL;
298+
}
299+
300+
if (cd->channels_count != (int)source_channels) {
301+
comp_err(dev, "channels mismatch: init %d, stream %u",
302+
cd->channels_count, source_channels);
296303
return -EINVAL;
297304
}
298305

0 commit comments

Comments
 (0)