alsa: don't change the resampler delay value

Don't change the resampler delay value, we need it to make sure
we keep samples around for the next round. With small period sizes,
we set the delay to 0 and mess up the resampler and cause dropouts
and clicking.

Fixes #287
This commit is contained in:
Wim Taymans 2020-09-15 13:16:31 +02:00
parent f29bf9cb40
commit 8332d3e3ed

View file

@ -664,7 +664,6 @@ static int alsa_recover(struct state *state, int err)
state->alsa_started = false;
spa_alsa_write(state, state->threshold * 2);
}
return 0;
}
@ -688,6 +687,7 @@ static int get_status(struct state *state, snd_pcm_uframes_t *delay, snd_pcm_ufr
*target = state->last_threshold;
#define MARGIN 48
if (state->resample && state->rate_match) {
state->delay = state->rate_match->delay * 2;
state->read_size = state->rate_match->size;
@ -695,9 +695,10 @@ static int get_status(struct state *state, snd_pcm_uframes_t *delay, snd_pcm_ufr
* by moving a little closer to the device read/write pointers.
* Don't try to get closer than 48 samples but instead increase the
* reported latency on the port (TODO). */
if (*target <= state->delay + 48)
state->delay = SPA_MAX(0, (int)(*target - 48 - state->delay));
*target -= state->delay;
if (*target <= state->delay + MARGIN)
*target -= SPA_MAX(0, (int)(*target - MARGIN - state->delay));
else
*target -= state->delay;
} else {
state->delay = state->read_size = 0;
}
@ -1290,6 +1291,7 @@ int spa_alsa_start(struct state *state)
reset_buffers(state);
state->alsa_sync = true;
state->alsa_recovering = false;
if (state->stream == SND_PCM_STREAM_PLAYBACK) {
state->alsa_started = false;