From b2695f86cfe5e30644f0ce565e22c1e6da303655 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 8 May 2025 16:01:18 +0200 Subject: [PATCH] alsa-pcm: handle and warn about a driver bug wrt channels If the driver returns a larger min than max channel count, log a warning and swap the two numbers. See #4687 --- spa/plugins/alsa/alsa-pcm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 36834eaed..e71d28093 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -1563,6 +1563,12 @@ static int add_channels(struct state *state, bool all, uint32_t index, uint32_t spa_log_debug(state->log, "channels (%d %d) default:%d all:%d", min, max, state->default_channels, all); + if (min > max) { + spa_log_warn(state->log, "driver bug! min > max channels: (%d > %d)", + min, max); + SPA_SWAP(min, max); + } + if (state->default_channels != 0 && !all) { if (min < state->default_channels) min = state->default_channels;