[pulseaudio-discuss] Virtualbox sound management

Colin Guthrie gmane at colin.guthr.ie
Tue Oct 19 04:29:22 PDT 2010


'Twas brillig, and Fabrice Beauvir at 19/10/10 10:41 did gyre and gimble:
> On a Ubuntu 9.04 server running pulse audio without any sound card I run
> 2 Windows XP virtual box .
> 
>  Sound is Ok and on both of them , I am playing on the current virtual
> sound card (mapped on each vbox  instance) and stream directly using
> virtual card as input on each .
> 
> but....
> 
>  On both stream sound is mixed , I heard the 2 sounds mixed out  on each
> one !!!

Ahh right, yes this is simple to explain, but rather more complex to fix.

Ultimately PulseAudio uses a "module-null-sink" when no real hardware is
found. This means that a dummy sound card is essentially provided. This
is created automatically by module-always-sink so that applications
generally find "somethign" to output to (as without this, alsa
applications going via alsa->pulse bridge often got, erm, "confused" is
a nice term :D)

Anyway, the point is that this module only provide a virtual null
*output*, and there is no virtual null *input*.

Well, I say there is no null input but there *is* a "monitor" input for
the virtual output (a monitor basically acts as a pretend input that
allows you to record what is being currently played - think of how bands
perform at live gigs - they use monitors there to make sure they don't
sound crap!)


Anyway, when VirtualBox is recording it has to record form some source
in PA. As a side effect of the virtual output, the *only* input it can
record from is the montitor of this virtual input. As both VMs output to
the same virtual null sink in PA, their sound is mixed. Therefore when
either of them record, they get the product of the mixed audio from the
monitor.

So that explains things. How to fix?

Well there is no module-null-source (there arguably should be on written
but no one has done this yet).

So a trick here would be to load a second null sink and set *it's*
monitor source as the default source, but never actually play anything
on it.  This way you can happily "record" the silence inside the VMs and
that should be OK.

Hope that makes sense!


You'd have to do something like:

pacmd load-module module-null-sink sink_name=fake
pacmd set-default-source fake.monitor

(you can also put this in your default.pa so it's done automatically)

You'll likely need to restart your VMs to make sure they then use the
right devices.

Hope that helps.

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]




More information about the pulseaudio-discuss mailing list