alsa: improve xrun clock field calculation

We're missing the delay in samples plus all of the extra samples of
silence we use to restart the device. This is in the samplerate of
the device.

Convert this to the time domain of the graph before adding it to xrun.
This commit is contained in:
Wim Taymans 2023-08-31 14:28:56 +02:00
parent 2c2b0f482f
commit 21392d898e

View file

@ -1945,16 +1945,15 @@ static int alsa_recover(struct state *state, int err)
delay = SPA_TIMEVAL_TO_USEC(&diff); delay = SPA_TIMEVAL_TO_USEC(&diff);
missing = delay * state->rate / SPA_USEC_PER_SEC; missing = delay * state->rate / SPA_USEC_PER_SEC;
if (missing == 0) missing += state->start_delay + state->threshold + state->headroom;
missing = state->threshold;
spa_log_trace(state->log, "%p: xrun of %"PRIu64" usec %"PRIu64, spa_log_trace(state->log, "%p: xrun of %"PRIu64" usec %"PRIu64,
state, delay, missing); state, delay, missing);
if (state->clock) if (state->clock) {
state->clock->xrun += missing; state->clock->xrun += SPA_SCALE32_UP(missing,
state->sample_count += missing; state->clock->rate.denom, state->rate);
}
spa_node_call_xrun(&state->callbacks, spa_node_call_xrun(&state->callbacks,
SPA_TIMEVAL_TO_USEC(&trigger), delay, NULL); SPA_TIMEVAL_TO_USEC(&trigger), delay, NULL);
break; break;