sound: support --backend option

This commit is contained in:
Stefano Garzarella 2023-05-19 18:16:21 +02:00
parent 82660840ca
commit 65f7c78dbd
2 changed files with 8 additions and 3 deletions

View File

@ -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,
}
}

View File

@ -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(),
}
}
}