Search code examples
linuxubuntu-16.04alsapulseaudio

Fake input device in Docker container on Ubuntu VM


I need a fake microphone device in a Docker container on an Ubuntu VM. Any idea how I can get one there?

I'm a bit of a Linux n00b, so I've been looking at pulseaudio, ALSA and modprobe. But I really can't tie together all the pieces, conceptually. I'm looking to you, SO, for some much needed help on this one.


Solution

  • For our Firefox automated testing in CI we use PulseAudio's module-sine-source as a fake audio input. It just generates a sine wave. I'm not certain if the same code will work for Chrome but you can try it: https://dxr.mozilla.org/mozilla-central/rev/2a3a253806d129c0bb6f2b76bf75630457a24492/testing/mochitest/runtests.py#736

    We essentially just run pactl load-module module-sine-source if the module is not already loaded, and then we set a Firefox preference to force it to use that device as the default input device (but it's the only input device so it should work either way).