Skip to content

Commit

Permalink
chore: Don't query audio devices on linux (#2303)
Browse files Browse the repository at this point in the history
  • Loading branch information
The-personified-devil authored and zmerp committed Aug 15, 2024
1 parent 31885f8 commit 359fc00
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
4 changes: 3 additions & 1 deletion alvr/server_io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
37 changes: 24 additions & 13 deletions alvr/server_io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -290,18 +289,30 @@ impl ServerDataManager {
}

pub fn get_audio_devices_list(&self) -> Result<AudioDevicesList> {
let host = cpal::default_host();

let output = host
.output_devices()?
.filter_map(|d| d.name().ok())
.collect::<Vec<_>>();
let input = host
.input_devices()?
.filter_map(|d| d.name().ok())
.collect::<Vec<_>>();

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::<Vec<_>>();
let input = host
.input_devices()?
.filter_map(|d| d.name().ok())
.collect::<Vec<_>>();

Ok(AudioDevicesList { output, input })
}
#[cfg(target_os = "linux")]
{
Ok(AudioDevicesList {
input: vec![],
output: vec![],
})
}
}
}

Expand Down

0 comments on commit 359fc00

Please sign in to comment.