<div dir="ltr">Ok so what I'm finding:<div>- module-null-sink with module-remap-source can get to near-zero latency<br>- This however comes at the expense of CPU</div><div>- The various buffer attributes are a bit confusing.</div><div><br></div><div>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:</div><div><a href="https://source.chromium.org/chromium/chromium/src/+/main:media/audio/pulse/pulse_util.cc">https://source.chromium.org/chromium/chromium/src/+/main:media/audio/pulse/pulse_util.cc</a></div><div><a href="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/libwebrtc/modules/audio_device/linux/audio_device_pulse_linux.cc</a><br></div><div><a href="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-sys/libcubeb/src/cubeb_pulse.c</a><br></div><div><a href="https://searchfox.org/mozilla-central/source/third_party/rust/cubeb-pulse/src/backend/stream.rs#502">https://searchfox.org/mozilla-central/source/third_party/rust/cubeb-pulse/src/backend/stream.rs#502</a><br></div><div><br></div><div>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.<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 18, 2022 at 11:46 PM Georg Chini <<a href="mailto:georg@chini.tk">georg@chini.tk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div>Hi Chase,</div>
<div><br>
</div>
<div>let me know the results of your tests.
I would especially be interested in the<br>
difference between using module-null-sink with module-remap-source</div>
<div>and module-null-source with the uplink
sink of module-remap-source.</div>
<div><br>
</div>
<div>Regards</div>
<div> Georg<br>
</div>
<div><br>
</div>
<div>On 19.04.22 01:32, Chase Lambert wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Thanks for the replies!
<div><br>
</div>
<div>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.<br>
<br>
Georg - I can see how that MR could reduce latency,
interesting.<br>
<br>
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:</div>
<div>- My application would get a callback from PulseAudio,
telling it to write something<br>
- My application writes something<br>
- Immediately thereafter, Chrome gets a callback to read data</div>
<div>- Chrome reads the data<br>
- There isn't a risk of an underrun here by Chrome, because it
will only get callbacks when data is ready (hazy guess!)</div>
<div><br>
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.</div>
<div><br>
</div>
<div>In any case, I'll soon find the answer myself. Thanks!</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sun, Apr 17, 2022 at 9:13
AM guest271314 <<a href="mailto:guest271314@gmail.com" target="_blank">guest271314@gmail.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">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.
<div><br>
</div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sat, Apr 16, 2022 at
9:49 PM Chase Lambert <<a href="mailto:chaselambda@gmail.com" target="_blank">chaselambda@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">Hi,
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Then I can write to that sink, and get data to show
up in this virtual microphone.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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].</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Chase</div>
<div><br>
</div>
<div>[0] <a href="https://source.chromium.org/chromium/chromium/src/+/main:media/audio/pulse/audio_manager_pulse.cc" target="_blank">https://source.chromium.org/chromium/chromium/src/+/main:media/audio/pulse/audio_manager_pulse.cc</a></div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
<p><br>
</p>
</div>
</blockquote></div>