Skip to content

Commit 9bd3ca9

Browse files
committed
audio: mux: fix input buffer consumption for mixed channel counts
Fix per-source consumed byte accounting in mux_process(). When MUX inputs use different channel counts, using the first input buffer frame size for all consumed accounting advances other source buffers incorrectly. This causes duplicated samples, incorrect output frequency, and capture duration issues. Compute consumed bytes per input buffer using each source stream's own frame size. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent c64e373 commit 9bd3ca9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/audio/mux/mux.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ static int mux_process(struct processing_module *mod,
312312
const struct audio_stream *sources_stream[MUX_MAX_STREAMS] = { NULL };
313313
int frames = 0;
314314
int sink_bytes;
315-
int source_bytes;
316315
int i, j;
317316

318317
comp_dbg(dev, "entry");
@@ -341,18 +340,18 @@ static int mux_process(struct processing_module *mod,
341340
if (num_input_buffers == 0)
342341
return 0;
343342

344-
source_bytes = frames * audio_stream_frame_bytes(mod->input_buffers[0].data);
345343
sink_bytes = frames * audio_stream_frame_bytes(mod->output_buffers[0].data);
346344
mux_prepare_active_look_up(cd, output_buffers[0].data, &sources_stream[0]);
347345

348346
/* produce output */
349347
cd->mux(dev, output_buffers[0].data, &sources_stream[0], frames, &cd->active_lookup);
350348

351-
/* Update consumed and produced */
349+
/* Update consumed per source using each source's own frame size */
352350
j = 0;
353351
comp_dev_for_each_producer(dev, source) {
354352
if (comp_buffer_get_source_state(source) == dev->state)
355-
mod->input_buffers[j].consumed = source_bytes;
353+
mod->input_buffers[j].consumed =
354+
frames * audio_stream_frame_bytes(mod->input_buffers[j].data);
356355
j++;
357356
}
358357
mod->output_buffers[0].size = sink_bytes;

0 commit comments

Comments
 (0)