From 328e101f37ac478d4832844d977e026cc9c25540 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 15 Jul 2025 15:06:24 +0200 Subject: [PATCH] alsa: don't try to activate resampling with unknown rates If the driver or our rate is not known yet, don't assume we will need to resample. --- spa/plugins/alsa/alsa-pcm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 2c750f8eb..e10326b65 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2369,13 +2369,13 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_ spa_log_info(state->log, "%s: format:%s access:%s-%s rate:%d channels:%d " "buffer frames %lu, period frames %lu, periods %u, frame_size %zd " - "headroom %u start-delay:%u batch:%u tsched:%u", + "headroom %u start-delay:%u batch:%u tsched:%u resample:%u", state->name, snd_pcm_format_name(state->format), state->use_mmap ? "mmap" : "rw", planar ? "planar" : "interleaved", state->rate, state->channels, state->buffer_frames, state->period_frames, periods, state->frame_size, state->headroom, state->start_delay, - state->is_batch, !state->disable_tsched); + state->is_batch, !state->disable_tsched, state->resample); /* write the parameters to device */ CHECK(snd_pcm_hw_params(hndl, params), "set_hw_params"); @@ -2914,8 +2914,8 @@ static int setup_matching(struct state *state) if (spa_streq(state->position->clock.name, state->clock_name)) state->matching = false; - state->resample = !state->pitch_elem && - (((uint32_t)state->rate != state->driver_rate.denom) || state->matching); + check_position_config(state, false); + recalc_headroom(state); spa_log_info(state->log, "driver clock:'%s'@%d our clock:'%s'@%d matching:%d resample:%d", @@ -2974,7 +2974,8 @@ static inline int check_position_config(struct state *state, bool starting) state->max_resync = SPA_MIN(state->threshold + state->headroom, state->max_error); state->err_wdw = (double)state->driver_rate.denom/state->driver_duration; state->resample = !state->pitch_elem && - (((uint32_t)state->rate != state->driver_rate.denom) || state->matching); + ((state->rate != 0 && state->driver_rate.denom != 0 && + (uint32_t)state->rate != state->driver_rate.denom) || state->matching); state->alsa_sync = true; } return 0;