mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
spa: Fix audioconvert overflow when scaling
Add SPA_SCALE32_UP that scales a uint32 without overflow. Use this for scaling the threshold in ALSA. Fix the scaling in audioconvert of the buffer size, the scaling was wrong and it was also causing an overflow resulting in choppy sound in some cases. See #2680
This commit is contained in:
parent
32a7c85c84
commit
1d9640af5a
3 changed files with 11 additions and 3 deletions
|
|
@ -1999,7 +1999,7 @@ static inline void check_position_config(struct state *state)
|
|||
(state->rate_denom != state->position->clock.rate.denom))) {
|
||||
state->duration = state->position->clock.duration;
|
||||
state->rate_denom = state->position->clock.rate.denom;
|
||||
state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom;
|
||||
state->threshold = SPA_SCALE32_UP(state->duration, state->rate, state->rate_denom);
|
||||
state->max_error = SPA_MAX(256.0f, state->threshold / 2.0f);
|
||||
state->resample = ((uint32_t)state->rate != state->rate_denom) || state->matching;
|
||||
state->alsa_sync = true;
|
||||
|
|
@ -2569,7 +2569,7 @@ int spa_alsa_start(struct state *state)
|
|||
setup_matching(state);
|
||||
|
||||
spa_dll_init(&state->dll);
|
||||
state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom;
|
||||
state->threshold = SPA_SCALE32_UP(state->duration, state->rate, state->rate_denom);
|
||||
state->last_threshold = state->threshold;
|
||||
state->max_error = SPA_MAX(256.0f, state->threshold / 2.0f);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue