mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-09 13:29:59 -05:00
loopback: Fix sink latency calculation if source is alsa source with fixed latency
When an alsa source with fixed latency is used, the actual latency of the source will only be one fragment size. This is not taken into account when the required sink latency is calculated. This patch fixes the issue. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/451>
This commit is contained in:
parent
f18f55bb5e
commit
0efae0488c
1 changed files with 8 additions and 0 deletions
|
|
@ -1016,6 +1016,14 @@ static void set_sink_input_latency(struct userdata *u, pa_sink *sink) {
|
||||||
if (u->min_source_latency > requested_latency) {
|
if (u->min_source_latency > requested_latency) {
|
||||||
latency = PA_MAX(u->latency, u->minimum_latency);
|
latency = PA_MAX(u->latency, u->minimum_latency);
|
||||||
requested_latency = (latency - u->min_source_latency) / 2;
|
requested_latency = (latency - u->min_source_latency) / 2;
|
||||||
|
/* In the case of a fixed alsa source, u->minimum_latency is calculated from
|
||||||
|
* the default fragment size while u->min_source_latency is the reported minimum
|
||||||
|
* of the source latency (nr_of_fragments * fragment_size). This can lead to a
|
||||||
|
* situation where u->minimum_latency < u->min_source_latency. We only fall
|
||||||
|
* back to use the fragment size instead of min_source_latency if the calculation
|
||||||
|
* above does not deliver a usable result. */
|
||||||
|
if (u->fixed_alsa_source && u->min_source_latency >= latency)
|
||||||
|
requested_latency = (latency - u->core->default_fragment_size_msec * PA_USEC_PER_MSEC) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
latency = PA_CLAMP(requested_latency , u->min_sink_latency, u->max_sink_latency);
|
latency = PA_CLAMP(requested_latency , u->min_sink_latency, u->max_sink_latency);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue