diff --git a/alvr/server_io/Cargo.toml b/alvr/server_io/Cargo.toml index ed058ee4f9..90af596cc2 100644 --- a/alvr/server_io/Cargo.toml +++ b/alvr/server_io/Cargo.toml @@ -13,8 +13,10 @@ alvr_filesystem.workspace = true alvr_packets.workspace = true alvr_session.workspace = true -cpal = { version = "0.15", features = ["jack"] } encoding_rs_io = "0.1" dirs = "5" runas = "^1.2" # version 1.1 is broken serde_json = "1" + +[target.'cfg(not(target_os = "linux"))'.dependencies] +cpal = "0.15" diff --git a/alvr/server_io/src/lib.rs b/alvr/server_io/src/lib.rs index 7e5cd91997..95a911e9bf 100644 --- a/alvr/server_io/src/lib.rs +++ b/alvr/server_io/src/lib.rs @@ -13,7 +13,6 @@ use alvr_common::{ use alvr_events::EventType; use alvr_packets::{AudioDevicesList, ClientListAction, PathSegment, PathValuePair}; use alvr_session::{ClientConnectionConfig, SessionConfig, Settings}; -use cpal::traits::{DeviceTrait, HostTrait}; use serde_json as json; use std::{ collections::{hash_map::Entry, HashMap}, @@ -290,18 +289,30 @@ impl ServerDataManager { } pub fn get_audio_devices_list(&self) -> Result { - let host = cpal::default_host(); - - let output = host - .output_devices()? - .filter_map(|d| d.name().ok()) - .collect::>(); - let input = host - .input_devices()? - .filter_map(|d| d.name().ok()) - .collect::>(); - - Ok(AudioDevicesList { output, input }) + #[cfg(not(target_os = "linux"))] + { + use cpal::traits::{DeviceTrait, HostTrait}; + + let host = cpal::default_host(); + + let output = host + .output_devices()? + .filter_map(|d| d.name().ok()) + .collect::>(); + let input = host + .input_devices()? + .filter_map(|d| d.name().ok()) + .collect::>(); + + Ok(AudioDevicesList { output, input }) + } + #[cfg(target_os = "linux")] + { + Ok(AudioDevicesList { + input: vec![], + output: vec![], + }) + } } }