vhost-device/vhost-device-sound
Davíð Steinn Geirsson dac004f86b feat(sound): add per-direction runtime enable/disable with Unix control socket
Always create both output and input virtio-sound streams regardless of
CLI args. Per-direction AtomicBool flags checked in process_io() enforce
enable/disable — disabled output discards samples, disabled input returns
silence. A Unix control socket accepts QUERY/SET commands to toggle flags
at runtime. PipeWire set_active() is called alongside as a cosmetic signal.

- Add StreamEnabled type with shared atomic per-direction flags
- Replace --streams with --initial-streams, add --control-socket CLI arg
- Always create both output and input streams unconditionally
- Enforce enabled flags in process_io() (security boundary)
- Add set_active() to AudioBackend trait with PipeWire implementation
- Add control_socket module with QUERY/SET line protocol
- Wire everything together in start_backend_server and main
2026-03-27 22:30:36 +00:00
..
src feat(sound): add per-direction runtime enable/disable with Unix control socket 2026-03-27 22:30:36 +00:00
Cargo.toml Use our vhost fork for all crates and add GPU flake package 2026-03-22 19:10:55 +00:00
CHANGELOG.md vhost-device-sound: add --socket-fd argument 2025-11-20 17:24:04 +02:00
LICENSE-APACHE sound: fix symbolic links to license files 2024-01-10 11:23:08 +05:30
LICENSE-BSD-3-Clause sound: fix symbolic links to license files 2024-01-10 11:23:08 +05:30
README.md sound: document --streams CLI option in README 2026-03-17 19:33:57 +00:00

vhost-device-sound

Synopsis

   vhost-device-sound --socket <SOCKET> --backend <BACKEND>

Description

   A virtio-sound device using the vhost-user protocol.

Options

     --socket <SOCKET>
            vhost-user Unix domain socket path

     --socket-fd <FD>
            listening vhost-user Unix domain socket file descriptor
            (e.g. from a service manager)

     --backend <BACKEND>
            audio backend to be used [possible values: null, pipewire, alsa, gstreamer]

     --streams <STREAMS>
            comma-separated list of stream directions to enable [possible values: output, input]
            (default: output,input)

     -h, --help
            Print help

     -V, --version
            Print version

Examples

Launch the backend on the host machine:

host# vhost-device-sound --socket /tmp/snd.sock --backend null

With QEMU, you can add a virtio device that uses the backend's socket with the following flags:

-chardev socket,id=vsnd,path=/tmp/snd.sock \
-device vhost-user-snd-pci,chardev=vsnd,id=snd

License

This project is licensed under either of