On 19.02.2018 16:56, Raman Shishniou wrote:
Hello,
Currently a loopback module does a double resampling if the source
and sink sample rates are different.
I used a simple config to test it:
load-module module-null-source source_name=src rate=48000
load-module module-null-sink sink_name=dst rate=96000
load-module module-loopback source=src sink=dst
After start I see in logs:
D: [pulseaudio] module-loopback.c: Loopback overall latency is 56.14 ms + 67.48
ms + 53.20 ms = 176.76 ms
D: [pulseaudio] module-loopback.c: Loopback latency at base rate is 176.46 ms
D: [pulseaudio] module-loopback.c: [dst] Updated sampling rate to 95758 Hz.
D: [pulseaudio] module-loopback.c: Loopback overall latency is 23.17 ms +
134.20 ms + 44.60 ms = 201.94 ms
D: [pulseaudio] module-loopback.c: Loopback latency at base rate is 201.60 ms
D: [pulseaudio] module-loopback.c: [dst] Updated sampling rate to 95925 Hz.
D: [pulseaudio] module-loopback.c: Loopback overall latency is 44.15 ms +
133.80 ms + 31.56 ms = 209.48 ms
D: [pulseaudio] module-loopback.c: Loopback latency at base rate is 209.37 ms
D: [pulseaudio] module-loopback.c: [dst] Updated sampling rate to 95994 Hz.
Sink-inputs and source-outputs:
$ ~/bin/pactl list short source-outputs
0 0 - module-loopback.c s16le 2ch 96000Hz
$ ~/bin/pactl list short sink-inputs
0 0 - module-loopback.c s16le 2ch 95994Hz
I.e. first resample occurs in source-output (48000Hz -> 96000Hz) and
the second in sink-input (95994Hz -> 96000Hz).
I think it should change source-output's sample rate during latency
recalculations.
In this case there should be only one real resampler. This should increase
audio quality and reduce cpu usage.
You can specify a sample-rate for module-loopback. So if you do
the same as above, but with rate=48000, the first re-sampling
will not happen. If you don't specify a rate, module-loopback uses
the rate of the sink. But you are right, because we do re-sampling
on the sink-input side anyway, it would probably make more sense
to use the source rate as default. This can easily be fixed in the
module init function. Will you send a patch?
_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss