mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-28 08:01:04 +00:00
sound: support --backend option
This commit is contained in:
parent
82660840ca
commit
65f7c78dbd
@ -53,11 +53,11 @@ pub struct SoundConfig {
|
||||
impl SoundConfig {
|
||||
/// Create a new instance of the SoundConfig struct, containing the
|
||||
/// parameters to be fed into the sound-backend server.
|
||||
pub fn new(socket: String, multi_thread: bool) -> Self {
|
||||
pub fn new(socket: String, multi_thread: bool, audio_backend_name: String) -> Self {
|
||||
Self {
|
||||
socket,
|
||||
multi_thread,
|
||||
audio_backend_name: "null".to_string(),
|
||||
audio_backend_name,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@ struct SoundArgs {
|
||||
/// vhost-user Unix domain socket path.
|
||||
#[clap(long)]
|
||||
socket: String,
|
||||
/// audio backend to be used (supported: null)
|
||||
#[clap(long)]
|
||||
backend: String,
|
||||
}
|
||||
|
||||
impl TryFrom<SoundArgs> for SoundConfig {
|
||||
@ -19,8 +22,9 @@ impl TryFrom<SoundArgs> for SoundConfig {
|
||||
|
||||
fn try_from(cmd_args: SoundArgs) -> Result<Self> {
|
||||
let socket = cmd_args.socket.trim().to_string();
|
||||
let backend = cmd_args.backend.trim().to_string();
|
||||
|
||||
Ok(SoundConfig::new(socket, false))
|
||||
Ok(SoundConfig::new(socket, false, backend))
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +47,7 @@ mod tests {
|
||||
fn from_args(socket: &str) -> Self {
|
||||
SoundArgs {
|
||||
socket: socket.to_string(),
|
||||
backend: "null".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user