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.
This commit is contained in:
Wim Taymans 2025-07-15 15:06:24 +02:00
parent 0be61add02
commit 328e101f37

View file

@ -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;