NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Pulseaudio & browsers - anyone got something ELSE working?



On Mon, Aug 14, 2017 at 10:27:34PM +0100, Sad Clouds wrote:
> Just out of interest, what is the significance of in-kernel audio mixer
> and what is it supposed to do?

Without an audio mixer you can only have one output at once to some
hardware. if you let multiple things write audio then they will trample
each other.
if one thread says "the audio is 55" and the other says "audio is 22"
then (at best) you may get 22, or 55, or 25, or 52. neither of which
sound right.

before it only allowed one input, and if something else was inputting,
new things cannot start inputting.
even if you only wanted one output, sometimes something will refuse to
let go of it, and you wouldn't be able to play audio.

an audio mixer puts the 55 and 22 in different places and combines them
to a single meaningful result, say 77.

what netbsd has now is the same daemon in the kernel, if you do:
  top -t |grep audio
you will see the audiomix kernel thread. If you see what is
kthread_create'ing something called "audiomix", you will see the
functionality is just this function:
https://nxr.netbsd.org/xref/src/sys/dev/audio.c#audio_play_thread

it does a few things around, but then does the 'thing' with mix_func,
which is: https://nxr.netbsd.org/xref/src/sys/dev/audio.c#DEF_MIX_FUNC

it literally multiplies the virtual channel the volume and adds in
ways that sound right.

what pulseaudio does is run a userland daemon, so anything that uses
pulseaudio as a library speaks to the daemon (using dbus to pass data, I
think) and this daemon does the mixing, and then tells the kernel the
combined results. this means the kernel can remain dumb but audio will
still be mixed.


Home | Main Index | Thread Index | Old Index