From f052cfefc8d6d27fa068c34190615db1819b8fef Mon Sep 17 00:00:00 2001 From: paulhsia Date: Tue, 22 Jan 2019 15:22:25 +0800 Subject: linux: Add ac97 device with CRAS backend Add an ac97 device that plays audio through CRAS audio server. BUG=chromium:781398 BUG=chromium:907520 TEST=Test building by $ cargo build TEST=Deploy crosvm to DUT and test audio functionality CQ-DEPEND=CL:1429311 CQ-DEPEND=CL:1429542 Change-Id: Ia273d8f1e82c20d1f1882f088886458339399aae Reviewed-on: https://chromium-review.googlesource.com/1426282 Commit-Ready: Chih-Yang Hsia Tested-by: kokoro Tested-by: Chih-Yang Hsia Reviewed-by: Chih-Yang Hsia --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 555c98d..5847087 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ extern crate kernel_loader; extern crate kvm; extern crate kvm_sys; extern crate libc; +extern crate libcras; extern crate net_util; extern crate qcow; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] @@ -93,6 +94,7 @@ pub struct Config { multiprocess: bool, seccomp_policy_dir: PathBuf, gpu: bool, + cras_audio: bool, null_audio: bool, } @@ -120,6 +122,7 @@ impl Default for Config { shared_dirs: Vec::new(), multiprocess: !cfg!(feature = "default-no-sandbox"), seccomp_policy_dir: PathBuf::from(SECCOMP_POLICY_DIR), + cras_audio: false, null_audio: false, } } @@ -212,6 +215,9 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument:: })?, ) } + "cras-audio" => { + cfg.cras_audio = true; + } "null-audio" => { cfg.null_audio = true; } @@ -497,6 +503,7 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> { "IP address to assign to host tap interface."), Argument::value("netmask", "NETMASK", "Netmask for VM subnet."), Argument::value("mac", "MAC", "MAC address for VM."), + Argument::flag("cras-audio", "Add an audio device to the VM that plays samples through CRAS server"), Argument::flag("null-audio", "Add an audio device to the VM that plays samples to /dev/null"), Argument::value("wayland-sock", "PATH", "Path to the Wayland socket to use."), #[cfg(feature = "wl-dmabuf")] -- cgit 1.4.1