Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
628 changes: 404 additions & 224 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions vhost-device-sound/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

### Added

- [[#876]](https://github.com/rust-vmm/vhost-device/pull/876) Add GStreamer audio backend support
- [[#806]](https://github.com/rust-vmm/vhost-device/pull/806) Add controls field in VirtioSoundConfig
- [[#746]](https://github.com/rust-vmm/vhost-device/pull/746) Add new sampling rates 12000Hz and 24000Hz

Expand All @@ -14,6 +15,10 @@
- [[#808]](https://github.com/rust-vmm/vhost-device/pull/808) pipewire: Fix rand module imports
- [[#884]](https://github.com/rust-vmm/vhost-device/pull/884) vhost-device-sound/pipewire: fix wrong format

### Limitations

- GStreamer backend: 20-bit PCM formats (VIRTIO_SND_PCM_FMT_S20/U20) are not directly supported by GStreamer and are automatically converted to 24/32-bit formats

### Deprecated

## v0.2.0
Expand Down
6 changes: 5 additions & 1 deletion vhost-device-sound/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ edition = "2021"

[features]
xen = ["vm-memory/xen", "vhost/xen", "vhost-user-backend/xen"]
default = ["alsa-backend", "pw-backend"]
default = ["alsa-backend", "pw-backend", "gst-backend"]
alsa-backend = ["dep:alsa"]
pw-backend = ["pw"]
gst-backend = ["dep:gst", "dep:gst-app", "dep:gst-audio"]

[dependencies]
clap = { version = "4.5", features = ["derive"] }
Expand All @@ -32,6 +33,9 @@ vmm-sys-util = "0.14"
[target.'cfg(target_env = "gnu")'.dependencies]
alsa = { version = "0.10", optional = true }
pw = { package = "pipewire", version = "0.9.2", optional = true }
gst = { package = "gstreamer", version = "0.24.2", optional = true, features = ["v1_24"] }
gst-app = { package = "gstreamer-app", version = "0.24.2", optional = true, features = ["v1_24"] }
gst-audio = {package = "gstreamer-audio", version = "0.24.2", optional = true, features = ["v1_24"] }

[dev-dependencies]
rstest = "0.26.1"
Expand Down
2 changes: 1 addition & 1 deletion vhost-device-sound/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ generated with help2man target/debug/vhost-device-sound |mandoc
vhost-user Unix domain socket path

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

-h, --help
Print help
Expand Down
3 changes: 3 additions & 0 deletions vhost-device-sound/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ pub enum BackendType {
Pipewire,
#[cfg(all(feature = "alsa-backend", target_env = "gnu"))]
Alsa,
#[cfg(all(feature = "gst-backend", target_env = "gnu"))]
#[value(name = "gstreamer")]
GStreamer,
}
11 changes: 11 additions & 0 deletions vhost-device-sound/src/audio_backends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ mod null;
#[cfg(all(feature = "pw-backend", target_env = "gnu"))]
mod pipewire;

#[cfg(all(feature = "gst-backend", target_env = "gnu"))]
mod gstreamer;

use std::sync::{Arc, RwLock};

#[cfg(all(feature = "alsa-backend", target_env = "gnu"))]
use self::alsa::AlsaBackend;
#[cfg(all(feature = "gst-backend", target_env = "gnu"))]
use self::gstreamer::GStreamerBackend;
use self::null::NullBackend;
#[cfg(all(feature = "pw-backend", target_env = "gnu"))]
use self::pipewire::PwBackend;
Expand Down Expand Up @@ -61,6 +66,12 @@ pub fn alloc_audio_backend(
}
#[cfg(all(feature = "alsa-backend", target_env = "gnu"))]
BackendType::Alsa => Ok(Box::new(AlsaBackend::new(streams))),
#[cfg(all(feature = "gst-backend", target_env = "gnu"))]
BackendType::GStreamer => {
Ok(Box::new(GStreamerBackend::new(streams).map_err(|err| {
crate::Error::UnexpectedAudioBackendError(err.into())
})?))
}
}
}

Expand Down
Loading