https://github.com/sysprog21/vsnd
Virtual Linux soundcard driver
https://github.com/sysprog21/vsnd
Last synced: 29 days ago
JSON representation
Virtual Linux soundcard driver
- Host: GitHub
- URL: https://github.com/sysprog21/vsnd
- Owner: sysprog21
- License: mit
- Created: 2024-02-01T12:57:54.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-06T09:55:13.000Z (about 1 year ago)
- Last Synced: 2025-05-08T23:54:02.035Z (29 days ago)
- Language: C
- Homepage:
- Size: 21.5 KB
- Stars: 27
- Watchers: 3
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Virtual Soundcard Driver for Linux Kernel
`vsnd` implements a Linux device driver that introduces a virtual soundcard.
Typically, a sound card is a hardware component that enables computers to play
audio files. This virtual soundcard, however, is designed to transmit audio
PCM data received from various programs directly into a FIFO file.## Prerequisites
The following packages must be installed before building `vsnd`.
To compile the kernel driver successfully, package versions of currently used
kernel, kernel-devel and kernel-headers need to be matched.```shell
$ sudo apt install linux-headers-$(uname -r)
```Additional packages are required for verification purpose.
```shell
$ sudo apt install alsa-utils ffmpeg
```## Build and Run
After running make, you should be able to generate the file `vsnd.ko`.
Before loading this kernel module, you have to satisfy its dependency:
```shell
$ sudo modprobe snd_pcm
```A FIFO file is required during kernel module initialization and is used for
transmitting audio PCM data.```shell
$ mkfifo /tmp/audio.pcm
```The module can be loaded to Linux kernel by runnning the command:
```shell
$ sudo insmod vsnd.ko out_fifo_name=/tmp/audio.pcm
```Then, use [aplay](https://manpages.org/aplay) to check the soundcard device
provided by `vsnd`.```shell
$ aplay -l
```Reference output:
```
card 0: vsnd [vsnd], device 0: vsnd PCM [vsnd PCM]
Subdevices: 1/1
Subdevice #0: subdevice #0
```See [scripts/verify.sh](scripts/verify.sh) for automated test.
### Run on PulseAudio-enabled environment
If your system uses PulseAudio to control the sound ouput
device (i.e., sink), you may undergo
with the following error when you select the sink
as `vsnd` from PulseAudio then you try to remove `vsnd`:```shell
$ sudo rmmod vsnd
rmmod: ERROR: Module vsnd is in use
```The reason is that PulseAudio occupies `vsnd`. Though you can
tell PulseAudio to disable `vsnd` so that you can remove `vsnd`,
we suggest you to disable temporarily when using `vsnd` by the following
command:```shell
$ systemctl --user stop pulseaudio.socket
$ systemctl --user stop pulseaudio.service
```After using `vsnd`, you can execute the following command to bring
back PulseAudio:```shell
$ systemctl --user start pulseaudio.service
$ systemctl --user start pulseaudio.socket
```### Run on PipeWire-enabled environment
In systems use the PipeWire (e.g., Ubuntu 24.04 LTS), you might also encounter
the problem that you are not able to remove the vsnd module.To solve this problem, you need to stop the PipeWire with:
```shell
$ systemctl --user stop pipewire.socket
$ systemctl --user stop pipewire
```And after removing the module, restart it with:
```shell
$ systemctl --user start pipewire
```## License
`vsnd`is released under the MIT license. Use of this source code is governed by
a MIT-style license that can be found in the LICENSE file.## Reference
* [The ALSA Driver API](https://www.kernel.org/doc/html/latest/sound/kernel-api/alsa-driver-api.html)