From 977d6e2321dac674fe53ee9ed964760fce317e4f Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Mon, 18 Jul 2022 17:22:30 +0300 Subject: [PATCH] audioconvert: fix input remapping As currently implemented, input format convert channel remap is no-op. This is because although the out_datas array is permuted, the original pointer array is not referred to later on, so the only effect is that the temporary data array is stored in permuted order. Fix the permutation by permuting the pointers only for the conversion step. --- spa/plugins/audioconvert/audioconvert.c | 34 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 99fda1814..7fe3a2d01 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -2509,19 +2509,29 @@ static int impl_node_process(void *object) out_datas = (void **)dst_remap; else out_datas = (void **)this->tmp_datas[(tmp++) & 1]; - } else { - out_datas = (void **)src_datas; - } - if (dir->need_remap) { - for (i = 0; i < dir->conv.n_channels; i++) { - remap_src_datas[i] = out_datas[dir->remap[i]]; - spa_log_trace_fp(this->log, "%p: input remap %d -> %d", this, dir->remap[i], i); + + if (dir->need_remap) { + for (i = 0; i < dir->conv.n_channels; i++) { + remap_src_datas[i] = out_datas[dir->remap[i]]; + spa_log_trace_fp(this->log, "%p: input remap %d -> %d", this, dir->remap[i], i); + } + } else { + for (i = 0; i < dir->conv.n_channels; i++) + remap_src_datas[i] = out_datas[i]; } - out_datas = (void **)remap_src_datas; - } - if (!in_passthrough) { + spa_log_trace_fp(this->log, "%p: input convert %d", this, n_samples); - convert_process(&dir->conv, out_datas, src_datas, n_samples); + convert_process(&dir->conv, remap_src_datas, src_datas, n_samples); + } else { + if (dir->need_remap) { + for (i = 0; i < dir->conv.n_channels; i++) { + remap_src_datas[dir->remap[i]] = (void *)src_datas[i]; + spa_log_trace_fp(this->log, "%p: input remap %d -> %d", this, dir->remap[i], i); + } + out_datas = (void **)remap_src_datas; + } else { + out_datas = (void **)src_datas; + } } if (!mix_passthrough) { @@ -2570,7 +2580,7 @@ static int impl_node_process(void *object) dir = &this->dir[SPA_DIRECTION_OUTPUT]; if (dir->need_remap) { for (i = 0; i < dir->conv.n_channels; i++) { - remap_dst_datas[i] = out_datas[dir->remap[i]]; + remap_dst_datas[dir->remap[i]] = out_datas[i]; spa_log_trace_fp(this->log, "%p: output remap %d -> %d", this, i, dir->remap[i]); } in_datas = (const void**)remap_dst_datas;