alsa: don't compensate for rate match for very low latencies

For very small buffer sizes, don't try to attempt to compensate
for the rate matching because we would come dangerously close to
the read/write pointers and cause dropouts. Instead this latency
should be reported on the ports later.
This commit is contained in:
Wim Taymans 2019-08-30 16:31:51 +02:00
parent aaa6821052
commit 001c0a5217

View file

@ -612,6 +612,12 @@ static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t del
if (state->rate_match) { if (state->rate_match) {
state->delay = state->rate_match->delay; state->delay = state->rate_match->delay;
state->read_size = state->rate_match->size; state->read_size = state->rate_match->size;
/* We try to compensate for the latency introduced by rate matching
* by moving a little closer to the device read/write pointers.
* Don't try to get closer than 32 samples but instead increase the
* reported latency on the port (TODO). */
if ((int)state->last_threshold <= state->delay + 32)
state->delay = SPA_MAX(0, (int)state->last_threshold + 32 - state->delay);
} }
if (state->stream == SND_PCM_STREAM_PLAYBACK) if (state->stream == SND_PCM_STREAM_PLAYBACK)
@ -644,8 +650,8 @@ static int update_time(struct state *state, uint64_t nsec, snd_pcm_sframes_t del
else if (state->bw == BW_MED) else if (state->bw == BW_MED)
set_loop(state, BW_MIN); set_loop(state, BW_MIN);
spa_log_debug(state->log, "slave:%d rate:%f bw:%f thr:%d err:%f (%f %f %f)", spa_log_debug(state->log, "slave:%d rate:%f bw:%f del:%d thr:%d err:%f (%f %f %f)",
slave, corr, state->bw, state->threshold, slave, corr, state->bw, state->delay, state->threshold,
err, state->z1, state->z2, state->z3); err, state->z1, state->z2, state->z3);
} }