Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Don't query audio devices on linux #2303

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading