frontend-common: prefer jack on linux

This commit is contained in:
Alex Janka 2024-05-30 15:51:02 +10:00
parent 101a0fc062
commit c6d25af1ba
3 changed files with 5 additions and 1 deletions

1
Cargo.lock generated
View file

@ -1122,6 +1122,7 @@ dependencies = [
"core-foundation-sys 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
"coreaudio-rs",
"dasp_sample",
"jack",
"jni",
"js-sys",
"libc",

View file

@ -15,7 +15,7 @@ wgpu = ["gb-emu-lib/wgpu-renderer"]
[dependencies]
gb-emu-lib = { workspace = true }
gilrs = "0.10"
cpal = "0.15"
cpal = { version = "0.15", features = ["jack"] }
futures = "0.3"
nokhwa = { version = "0.10", features = [
"input-avfoundation",

View file

@ -10,6 +10,9 @@ use crate::access_config;
const DOWNSAMPLE_TYPE: DownsampleType = DownsampleType::ZeroOrderHold;
pub fn create_output(muted: bool) -> (AudioOutput, Stream) {
#[cfg(target_os = "linux")]
let host = cpal::host_from_id(cpal::HostId::Jack).unwrap_or_else(|_| cpal::default_host());
#[cfg(not(target_os = "linux"))]
let host = cpal::default_host();
let device = host