alsa: clamp audio.channels to MAX_CHANNELS

So that we don't end up trying to use too many channels later on.
This commit is contained in:
Wim Taymans 2025-05-08 18:14:02 +02:00
parent b2695f86cf
commit ff0d6d5677

View file

@ -162,6 +162,11 @@ static int alsa_set_param(struct state *state, const char *k, const char *s)
int fmt_change = 0;
if (spa_streq(k, SPA_KEY_AUDIO_CHANNELS)) {
state->default_channels = atoi(s);
if (state->default_channels > SPA_AUDIO_MAX_CHANNELS) {
spa_log_warn(state->log, "%p: %s: %s > %d, clamping",
state, k, s, SPA_AUDIO_MAX_CHANNELS);
state->default_channels = SPA_AUDIO_MAX_CHANNELS;
}
fmt_change++;
} else if (spa_streq(k, SPA_KEY_AUDIO_RATE)) {
state->default_rate = atoi(s);