[pulseaudio-discuss] module-remap-source, module-virtual-source, and latencies
Chase Lambert
chaselambda at gmail.com
Tue Apr 19 23:14:52 UTC 2022
Ok so what I'm finding:
- module-null-sink with module-remap-source can get to near-zero latency
- This however comes at the expense of CPU
- The various buffer attributes are a bit confusing.
The Chromium and firefox team seem to be choosing arbitrary buffer
attributes, in a variety of forms. You can search for "minreq" in all of
these files:
https://source.chromium.org/chromium/chromium/src/+/main:media/audio/pulse/pulse_util.cc
https://searchfox.org/mozilla-central/source/third_party/libwebrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
https://searchfox.org/mozilla-central/source/third_party/rust/cubeb-sys/libcubeb/src/cubeb_pulse.c
https://searchfox.org/mozilla-central/source/third_party/rust/cubeb-pulse/src/backend/stream.rs#502
I'm still trying to wrap my head around what they actually mean. It may be
necessary for me to change those buffer attributes in Chromium. I'm still
pondering what to do next.
On Mon, Apr 18, 2022 at 11:46 PM Georg Chini <georg at chini.tk> wrote:
> Hi Chase,
>
> let me know the results of your tests. I would especially be interested in
> the
> difference between using module-null-sink with module-remap-source
> and module-null-source with the uplink sink of module-remap-source.
>
> Regards
> Georg
>
> On 19.04.22 01:32, Chase Lambert wrote:
>
> Thanks for the replies!
>
> guest271314 - Huh, that's odd that you would see any audio differences. My
> stab in the dark guess would be some sort of PulseAudio resampling?
> Otherwise I would think the PCM data would be the same. I'll double check
> that the audio quality is as expected.
>
> Georg - I can see how that MR could reduce latency, interesting.
>
> I'm kind of just thinking out loud here, but the latency can get very low
> (say to 10ms), right? As long as I have small numbers in pa_buffer_attr, I
> would think that:
> - My application would get a callback from PulseAudio, telling it to write
> something
> - My application writes something
> - Immediately thereafter, Chrome gets a callback to read data
> - Chrome reads the data
> - There isn't a risk of an underrun here by Chrome, because it will only
> get callbacks when data is ready (hazy guess!)
>
> I ask this because my alternative is modifying Chromium and sending data
> directly to it over a custom IPC channel. But in theory that IPC channel
> should not be faster than PulseAudio. PulseAudio is just acting as a queue,
> and ultimately just a form of IPC between my application and Chrome.
>
> In any case, I'll soon find the answer myself. Thanks!
>
> On Sun, Apr 17, 2022 at 9:13 AM guest271314 <guest271314 at gmail.com> wrote:
>
>> I am not sure about different latencies re module-remap-source and
>> module-virtual-source. From my testing the quality of audio output when
>> using a remapped source with getUserMedia() is inferior compared to getting
>> the raw PCM using pactl or parec with fetch() on the browser side then
>> using AudioWorklet or MediaStreamTrackGenerator in Chrome/Chromium to
>> output the audio.
>>
>>
>>
>> On Sat, Apr 16, 2022 at 9:49 PM Chase Lambert <chaselambda at gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I'm trying to make a low latency Virtual microphone. What that means is
>>> I make a null sink, and then a module-virtual-source or module-remap-source
>>> that has a master pointing to the sink's monitor.
>>>
>>> Then I can write to that sink, and get data to show up in this virtual
>>> microphone.
>>>
>>> I've found that module-remap-source has a lower latency
>>> than module-virtual-source, (~400ms lower it seems), but I don't have any
>>> idea why. And more generally -- what is the difference between these two
>>> modules? I looked at their source and also the git history, but that didn't
>>> clear much up for me.
>>>
>>> Also, is this the best way to make a low latency microphone? I have an
>>> application that I want to send data to Chrome, with as low latency as
>>> possible. Chrome operates directly with pulseaudio[0].
>>>
>>> Thanks,
>>> Chase
>>>
>>> [0]
>>> https://source.chromium.org/chromium/chromium/src/+/main:media/audio/pulse/audio_manager_pulse.cc
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20220419/8be23e19/attachment.htm>
More information about the pulseaudio-discuss
mailing list