Add NetBSD support
This commit is contained in:
parent
f19ceeb8e0
commit
0f8cd7a9c8
7 changed files with 25 additions and 24 deletions
|
|
@ -31,7 +31,7 @@ num-traits = { version = "0.2.6", optional = true }
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
once_cell = "1.12"
|
once_cell = "1.12"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))'.dependencies]
|
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))'.dependencies]
|
||||||
alsa = "0.6"
|
alsa = "0.6"
|
||||||
nix = "0.23"
|
nix = "0.23"
|
||||||
libc = "0.2.65"
|
libc = "0.2.65"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
jack: bool,
|
jack: bool,
|
||||||
|
|
@ -20,7 +20,7 @@ impl Opt {
|
||||||
fn from_args() -> Self {
|
fn from_args() -> Self {
|
||||||
let app = clap::Command::new("beep").arg(arg!([DEVICE] "The audio device to use"));
|
let app = clap::Command::new("beep").arg(arg!([DEVICE] "The audio device to use"));
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
let app = app.arg(arg!(-j --jack "Use the JACK host"));
|
let app = app.arg(arg!(-j --jack "Use the JACK host"));
|
||||||
|
|
@ -28,7 +28,7 @@ impl Opt {
|
||||||
let device = matches.value_of("DEVICE").unwrap_or("default").to_string();
|
let device = matches.value_of("DEVICE").unwrap_or("default").to_string();
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
return Opt {
|
return Opt {
|
||||||
|
|
@ -37,7 +37,7 @@ impl Opt {
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd")),
|
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")),
|
||||||
not(feature = "jack")
|
not(feature = "jack")
|
||||||
))]
|
))]
|
||||||
Opt { device }
|
Opt { device }
|
||||||
|
|
@ -49,7 +49,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
// Conditionally compile with jack if the feature is specified.
|
// Conditionally compile with jack if the feature is specified.
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
// Manually check for flags. Can be passed through cargo with -- e.g.
|
// Manually check for flags. Can be passed through cargo with -- e.g.
|
||||||
|
|
@ -66,7 +66,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd")),
|
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")),
|
||||||
not(feature = "jack")
|
not(feature = "jack")
|
||||||
))]
|
))]
|
||||||
let host = cpal::default_host();
|
let host = cpal::default_host();
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use ringbuf::RingBuffer;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
jack: bool,
|
jack: bool,
|
||||||
|
|
@ -38,7 +38,7 @@ impl Opt {
|
||||||
.arg(arg!([OUT] "The output audio device to use"));
|
.arg(arg!([OUT] "The output audio device to use"));
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
let app = app.arg(arg!(-j --jack "Use the JACK host"));
|
let app = app.arg(arg!(-j --jack "Use the JACK host"));
|
||||||
|
|
@ -52,7 +52,7 @@ impl Opt {
|
||||||
let output_device = matches.value_of("OUT").unwrap_or("default").to_string();
|
let output_device = matches.value_of("OUT").unwrap_or("default").to_string();
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
return Ok(Opt {
|
return Ok(Opt {
|
||||||
|
|
@ -63,7 +63,7 @@ impl Opt {
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd")),
|
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")),
|
||||||
not(feature = "jack")
|
not(feature = "jack")
|
||||||
))]
|
))]
|
||||||
Ok(Opt {
|
Ok(Opt {
|
||||||
|
|
@ -79,7 +79,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
// Conditionally compile with jack if the feature is specified.
|
// Conditionally compile with jack if the feature is specified.
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
// Manually check for flags. Can be passed through cargo with -- e.g.
|
// Manually check for flags. Can be passed through cargo with -- e.g.
|
||||||
|
|
@ -96,7 +96,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd")),
|
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")),
|
||||||
not(feature = "jack")
|
not(feature = "jack")
|
||||||
))]
|
))]
|
||||||
let host = cpal::default_host();
|
let host = cpal::default_host();
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use std::sync::{Arc, Mutex};
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
jack: bool,
|
jack: bool,
|
||||||
|
|
@ -28,7 +28,7 @@ impl Opt {
|
||||||
fn from_args() -> Self {
|
fn from_args() -> Self {
|
||||||
let app = clap::Command::new("record_wav").arg(arg!([DEVICE] "The audio device to use"));
|
let app = clap::Command::new("record_wav").arg(arg!([DEVICE] "The audio device to use"));
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
let app = app.arg(arg!(-j --jack "Use the JACK host"));
|
let app = app.arg(arg!(-j --jack "Use the JACK host"));
|
||||||
|
|
@ -36,7 +36,7 @@ impl Opt {
|
||||||
let device = matches.value_of("DEVICE").unwrap_or("default").to_string();
|
let device = matches.value_of("DEVICE").unwrap_or("default").to_string();
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
return Opt {
|
return Opt {
|
||||||
|
|
@ -45,7 +45,7 @@ impl Opt {
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd")),
|
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")),
|
||||||
not(feature = "jack")
|
not(feature = "jack")
|
||||||
))]
|
))]
|
||||||
Opt { device }
|
Opt { device }
|
||||||
|
|
@ -57,7 +57,7 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
|
|
||||||
// Conditionally compile with jack if the feature is specified.
|
// Conditionally compile with jack if the feature is specified.
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
// Manually check for flags. Can be passed through cargo with -- e.g.
|
// Manually check for flags. Can be passed through cargo with -- e.g.
|
||||||
|
|
@ -74,7 +74,7 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd")),
|
not(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd")),
|
||||||
not(feature = "jack")
|
not(feature = "jack")
|
||||||
))]
|
))]
|
||||||
let host = cpal::default_host();
|
let host = cpal::default_host();
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ pub type SupportedOutputConfigs = VecIntoIter<SupportedStreamConfigRange>;
|
||||||
|
|
||||||
mod enumerate;
|
mod enumerate;
|
||||||
|
|
||||||
/// The default linux, dragonfly and freebsd host type.
|
/// The default linux, dragonfly, freebsd and netbsd host type.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Host;
|
pub struct Host;
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ impl HostTrait for Host {
|
||||||
type Device = Device;
|
type Device = Device;
|
||||||
|
|
||||||
fn is_available() -> bool {
|
fn is_available() -> bool {
|
||||||
// Assume ALSA is always available on linux/dragonfly/freebsd.
|
// Assume ALSA is always available on linux/dragonfly/freebsd/netbsd.
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
|
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))]
|
||||||
pub(crate) mod alsa;
|
pub(crate) mod alsa;
|
||||||
#[cfg(all(windows, feature = "asio"))]
|
#[cfg(all(windows, feature = "asio"))]
|
||||||
pub(crate) mod asio;
|
pub(crate) mod asio;
|
||||||
|
|
@ -7,7 +7,7 @@ pub(crate) mod coreaudio;
|
||||||
#[cfg(target_os = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
pub(crate) mod emscripten;
|
pub(crate) mod emscripten;
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"),
|
||||||
feature = "jack"
|
feature = "jack"
|
||||||
))]
|
))]
|
||||||
pub(crate) mod jack;
|
pub(crate) mod jack;
|
||||||
|
|
|
||||||
|
|
@ -562,7 +562,7 @@ macro_rules! impl_platform_host {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add pulseaudio and jack here eventually.
|
// TODO: Add pulseaudio and jack here eventually.
|
||||||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
|
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))]
|
||||||
mod platform_impl {
|
mod platform_impl {
|
||||||
pub use crate::host::alsa::{
|
pub use crate::host::alsa::{
|
||||||
Device as AlsaDevice, Devices as AlsaDevices, Host as AlsaHost, Stream as AlsaStream,
|
Device as AlsaDevice, Devices as AlsaDevices, Host as AlsaHost, Stream as AlsaStream,
|
||||||
|
|
@ -687,6 +687,7 @@ mod platform_impl {
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
target_os = "dragonfly",
|
target_os = "dragonfly",
|
||||||
target_os = "freebsd",
|
target_os = "freebsd",
|
||||||
|
target_os = "netbsd",
|
||||||
target_os = "macos",
|
target_os = "macos",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
target_os = "emscripten",
|
target_os = "emscripten",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue