mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
snd: Remove cras-snd parameter
As virtio snd and vhost snd support multiple backends, a new snd parameter is introduced to replace cras-snd parameter. Now cras-snd parameter is no longer needed and can be removed. BUG=b:241489181 TEST=tast run vm.AudioAplay.* TEST=emerge crosvm and boot crostini|arcvm|borealis Change-Id: Ieff12764753c9df4a06cca089a6d24bd956dc57d Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3813255 Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org> Tested-by: Norman Bintang <normanbt@chromium.org> Commit-Queue: Norman Bintang <normanbt@chromium.org>
This commit is contained in:
parent
b80068d3ab
commit
9d25cf1617
5 changed files with 2 additions and 101 deletions
|
@ -29,9 +29,6 @@ cfg_if::cfg_if! {
|
|||
pub use vsock::{run_vsock_device, Options as VsockOptions};
|
||||
pub use wl::{run_wl_device, parse_wayland_sock, Options as WlOptions};
|
||||
pub use console::{create_vu_console_device, run_console_device, Options as ConsoleOptions};
|
||||
// TODO(b/241489181): Remove once cras-snd calls are changed to snd.
|
||||
#[cfg(feature = "audio_cras")]
|
||||
pub use snd::{run_cras_snd_device, CrasOptions as CrasSndOptions};
|
||||
#[cfg(feature = "audio")]
|
||||
pub use snd::{run_snd_device, Options as SndOptions};
|
||||
pub use fs::{run_fs_device, Options as FsOptions};
|
||||
|
|
|
@ -41,10 +41,6 @@ use crate::virtio::snd::common_backend::StreamInfo;
|
|||
use crate::virtio::snd::common_backend::MAX_QUEUE_NUM;
|
||||
use crate::virtio::snd::common_backend::MAX_VRING_LEN;
|
||||
use crate::virtio::snd::parameters::Parameters;
|
||||
#[cfg(feature = "audio_cras")]
|
||||
use crate::virtio::snd::parameters::StreamSourceBackend as Backend;
|
||||
#[cfg(feature = "audio_cras")]
|
||||
use crate::virtio::snd::sys::StreamSourceBackend as SysBackend;
|
||||
use crate::virtio::vhost::user::device::handler::sys::Doorbell;
|
||||
use crate::virtio::vhost::user::device::handler::VhostUserBackend;
|
||||
use crate::virtio::vhost::user::device::listener::sys::VhostUserListener;
|
||||
|
@ -265,32 +261,6 @@ impl VhostUserBackend for SndBackend {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO(b/241489181): Remove once cras-snd calls are changed to snd.
|
||||
#[cfg(feature = "audio_cras")]
|
||||
#[derive(FromArgs)]
|
||||
#[argh(subcommand, name = "cras-snd")]
|
||||
/// CRAS snd device
|
||||
pub struct CrasOptions {
|
||||
#[argh(option, arg_name = "PATH")]
|
||||
/// path to a socket
|
||||
socket: Option<String>,
|
||||
#[argh(option, arg_name = "CONFIG")]
|
||||
/// VFIO-PCI device name (e.g. '0000:00:07.0')
|
||||
vfio: Option<String>,
|
||||
#[argh(option, arg_name = "CONFIG")]
|
||||
/// comma separated key=value pairs for setting up cras snd devices.
|
||||
/// Possible key values:
|
||||
/// capture - Enable audio capture. Default to false.
|
||||
/// client_type - Set specific client type for cras backend.
|
||||
/// num_output_devices - Set number of output PCM devices.
|
||||
/// num_input_devices - Set number of input PCM devices.
|
||||
/// num_output_streams - Set number of output PCM streams per device.
|
||||
/// num_input_streams - Set number of input PCM streams per device.
|
||||
/// Example: [capture=true,client=crosvm,socket=unified,
|
||||
/// num_output_devices=1,num_input_devices=1,num_output_streams=1,num_input_streams=1]
|
||||
config: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
#[argh(subcommand, name = "snd")]
|
||||
/// Snd device
|
||||
|
@ -317,21 +287,6 @@ pub struct Options {
|
|||
config: Option<String>,
|
||||
}
|
||||
|
||||
// TODO(b/241489181): Remove once cras-snd calls are changed to snd.
|
||||
#[cfg(feature = "audio_cras")]
|
||||
pub fn run_cras_snd_device(opts: CrasOptions) -> anyhow::Result<()> {
|
||||
let params = opts
|
||||
.config
|
||||
.unwrap_or("".to_string())
|
||||
.parse::<Parameters>()?;
|
||||
let params = Parameters {
|
||||
backend: Backend::Sys(SysBackend::CRAS),
|
||||
..params
|
||||
};
|
||||
|
||||
run(params, opts.socket, opts.vfio)
|
||||
}
|
||||
|
||||
/// Starts a vhost-user snd device.
|
||||
/// Returns an error if the given `args` is invalid or the device fails to run.
|
||||
pub fn run_snd_device(opts: Options) -> anyhow::Result<()> {
|
||||
|
@ -340,14 +295,6 @@ pub fn run_snd_device(opts: Options) -> anyhow::Result<()> {
|
|||
.unwrap_or("".to_string())
|
||||
.parse::<Parameters>()?;
|
||||
|
||||
run(params, opts.socket, opts.vfio)
|
||||
}
|
||||
|
||||
fn run(
|
||||
params: Parameters,
|
||||
socket_path: Option<String>,
|
||||
vfio: Option<String>,
|
||||
) -> anyhow::Result<()> {
|
||||
let snd_device = Box::new(SndBackend::new(params)?);
|
||||
|
||||
// Child, we can continue by spawning the executor and set up the device
|
||||
|
@ -356,8 +303,8 @@ fn run(
|
|||
let _ = SND_EXECUTOR.set(ex.clone());
|
||||
|
||||
let listener = VhostUserListener::new_from_socket_or_vfio(
|
||||
&socket_path,
|
||||
&vfio,
|
||||
&opts.socket,
|
||||
&opts.vfio,
|
||||
snd_device.max_queue_num(),
|
||||
None,
|
||||
)?;
|
||||
|
|
|
@ -516,30 +516,6 @@ pub struct RunCommand {
|
|||
)]
|
||||
/// group the given CPUs into a cluster (default: no clusters)
|
||||
pub cpu_clusters: Vec<Vec<usize>>,
|
||||
#[cfg(feature = "audio_cras")]
|
||||
#[argh(
|
||||
option,
|
||||
arg_name = "[capture=true,client=crosvm,socket=unified,\
|
||||
num_output_devices=1,num_input_devices=1,num_output_streams=1,num_input_streams=1]",
|
||||
long = "cras-snd"
|
||||
)]
|
||||
/// comma separated key=value pairs for setting up virtio snd
|
||||
/// devices.
|
||||
/// Possible key values:
|
||||
/// capture=(false,true) - Disable/enable audio capture.
|
||||
/// Default is false.
|
||||
/// client_type=(crosvm,arcvm,borealis) - Set specific
|
||||
/// client type for cras backend. Default is crosvm.
|
||||
/// socket_type=(legacy,unified) Set specific socket type
|
||||
/// for cras backend. Default is unified.
|
||||
/// num_output_devices=INT - Set number of output PCM
|
||||
/// devices.
|
||||
/// num_input_devices=INT - Set number of input PCM devices.
|
||||
/// num_output_streams=INT - Set number of output PCM
|
||||
/// streams per device.
|
||||
/// num_input_streams=INT - Set number of input PCM streams
|
||||
/// per device.
|
||||
pub cras_snds: Vec<SndParameters>,
|
||||
#[cfg(feature = "crash-report")]
|
||||
#[argh(option, long = "crash-pipe-name", arg_name = "\\\\.\\pipe\\PIPE_NAME")]
|
||||
/// the crash handler ipc pipe name.
|
||||
|
@ -1659,17 +1635,6 @@ impl TryFrom<RunCommand> for super::config::Config {
|
|||
{
|
||||
cfg.virtio_snds = cmd.virtio_snds;
|
||||
}
|
||||
#[cfg(feature = "audio_cras")]
|
||||
{
|
||||
// cmd.cras_snds is the old parameter for virtio snd with cras backend.
|
||||
cfg.virtio_snds
|
||||
.extend(cmd.cras_snds.into_iter().map(|s| SndParameters {
|
||||
backend: devices::virtio::parameters::StreamSourceBackend::Sys(
|
||||
devices::virtio::snd::sys::StreamSourceBackend::CRAS,
|
||||
),
|
||||
..s
|
||||
}));
|
||||
}
|
||||
|
||||
#[cfg(feature = "gpu")]
|
||||
{
|
||||
|
|
|
@ -15,9 +15,6 @@ use crate::crosvm::config::JailConfig;
|
|||
/// Unix Devices
|
||||
pub enum DevicesSubcommand {
|
||||
Console(device::ConsoleOptions),
|
||||
// TODO(b/241489181): Remove once cras-snd calls are changed to snd.
|
||||
#[cfg(feature = "audio_cras")]
|
||||
CrasSnd(device::CrasSndOptions),
|
||||
#[cfg(feature = "audio")]
|
||||
Snd(device::SndOptions),
|
||||
Fs(device::FsOptions),
|
||||
|
|
|
@ -13,8 +13,6 @@ use base::syslog;
|
|||
use base::syslog::LogConfig;
|
||||
use base::warn;
|
||||
use devices::virtio::vhost::user::device::run_console_device;
|
||||
#[cfg(feature = "audio_cras")]
|
||||
use devices::virtio::vhost::user::device::run_cras_snd_device;
|
||||
use devices::virtio::vhost::user::device::run_fs_device;
|
||||
#[cfg(feature = "gpu")]
|
||||
use devices::virtio::vhost::user::device::run_gpu_device;
|
||||
|
@ -32,9 +30,6 @@ use crate::Config;
|
|||
pub(crate) fn start_device(command: DevicesSubcommand) -> anyhow::Result<()> {
|
||||
match command {
|
||||
DevicesSubcommand::Console(cfg) => run_console_device(cfg),
|
||||
// TODO(b/241489181): Remove once cras-snd calls are changed to snd.
|
||||
#[cfg(feature = "audio_cras")]
|
||||
DevicesSubcommand::CrasSnd(cfg) => run_cras_snd_device(cfg),
|
||||
#[cfg(feature = "audio")]
|
||||
DevicesSubcommand::Snd(cfg) => run_snd_device(cfg),
|
||||
DevicesSubcommand::Fs(cfg) => run_fs_device(cfg),
|
||||
|
|
Loading…
Reference in a new issue