From 47de1e15a47b058e0bc434a35b002535af4b2aa6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 10 Feb 2026 13:34:44 +0100 Subject: [PATCH] channelmix: handle more than 64 channels When setting up the mix matrix, don't just iterate over the first 64 (CHANNEL_BITS) positions because then we will never be able to configure more than 64 channels in the matrix. Instead iterate until we have filled all src and dst entries in the matrix. For the first 64 positions we might need to check the channel mask to get the right positions in our source matrix. Fixes the channel mixer for >64 channels where the positions above 64 where 0 in the matrix and muted. Fixes #5118 --- spa/plugins/audioconvert/channelmix-ops.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/spa/plugins/audioconvert/channelmix-ops.c b/spa/plugins/audioconvert/channelmix-ops.c index d832edf8c..12edb4b5a 100644 --- a/spa/plugins/audioconvert/channelmix-ops.c +++ b/spa/plugins/audioconvert/channelmix-ops.c @@ -720,7 +720,7 @@ done: if (src_paired == 0) src_paired = ~0LU; - for (jc = 0, ic = 0, i = 0; i < CHANNEL_BITS; i++) { + for (jc = 0, ic = 0, i = 0; ic < dst_chan; i++) { float sum = 0.0f; char str1[1024], str2[1024]; struct spa_strbuf sb1, sb2; @@ -728,12 +728,10 @@ done: spa_strbuf_init(&sb1, str1, sizeof(str1)); spa_strbuf_init(&sb2, str2, sizeof(str2)); - if ((dst_paired & (1UL << i)) == 0) + if (i < CHANNEL_BITS && (dst_paired & (1UL << i)) == 0) continue; - for (jc = 0, j = 0; j < CHANNEL_BITS; j++) { - if ((src_paired & (1UL << j)) == 0) - continue; - if (ic >= dst_chan || jc >= src_chan) + for (jc = 0, j = 0; jc < src_chan; j++) { + if (j < CHANNEL_BITS && (src_paired & (1UL << j)) == 0) continue; if (ic == 0) @@ -752,7 +750,7 @@ done: if (sb2.pos > 0) spa_log_info(mix->log, " %s", str2); if (sb1.pos > 0) { - spa_log_info(mix->log, "%-4.4s %s %f", + spa_log_info(mix->log, "%03d %-4.4s %s %f", ic, dst_mask == 0 ? "UNK" : spa_debug_type_find_short_name(spa_type_audio_channel, i + _SH), str1, sum);