The alsa sink does larger rewind than needed when the configured sink latency changes
@tanuk
Submitted by Tanu Kaskinen Assigned to pul..@..op.org
Description
If a sink supports dynamic latency and the latency is adjusted downwards, there needs to be a rewind to ensure that the sink buffer doesn't contain more data than what is allowed by the new latency. This is because rewind requests can't be larger than the configured latency, and if there's more data than that in the buffer, a later rewind request may end up being too small.
The alsa sink requests the rewind in sink_update_requested_latency_cb():
if (u->hwbuf_unused > before) {
pa_log_debug("Requesting rewind due to latency change.");
pa_sink_request_rewind(s, (size_t) -1);
}
Doing a full rewind (-1 as the rewind amount) is not necessary, as far as I can see. It would be sufficient to rewind only by the difference between the old and new latency.