obs-studio
obs-studio copied to clipboard
Linux: virtual audio support via ALSA Loopback card
NOTE: This PR includes the changes in #8008, which is expected to get merged first.
Description
Adds virtual audio support via the ALSA loopback module, snd_aloop. As implemented, audio is optional and the virtualcam depends on v4l2loopback still. snd_aloop is not auto-loaded and an audio-only mode is not available.
Motivation and Context
Allows sharing audio output with other programs as a virtual microphone.
How Has This Been Tested?
- Load the loopback modules:
modprobe v4l2loopbackmodprobe snd-aloop - Start OBS and click [Start Virtual Cam]. Both audio and video are activated:
info: v4l2-output: Using device 'Dummy video device (0x0000)' at '/dev/video0'
info: ALSA output: hw:Loopback,1,0
info: Virtual camera starting: audio=1 video=1
- Add a media source, and observe video output as before (in this case, via '/dev/video0' **).
- Record audio:
arecord -D hw:Loopback,1,0 --duration=30 -fS16_LE -c2 -r48000 /tmp/test.pcm - Replay audio:
aplay -fS16_LE -c2 -r48000 /tmp/test.pcm - This varies by distro, but to load the device into PluseAudio:
pacmd load-module module-alsa-source source_properties=device.description=OBS device=hw:Loopback,1,0
** ideally the audio and video device names will be added to the OBS status bar, a to-do.
Types of changes
- New feature (non-breaking change which adds functionality)
Checklist:
- [x] My code has been run through clang-format.
- [x] I have read the contributing document.
- [x] My code is not on the master branch.
- [x] The code has been tested.
- [x] All commit messages are properly formatted and commits squashed where appropriate.
- [ ] I have included updates to all appropriate documentation.