Skip to content

Commit

Permalink
sndio: test CI with linux-sndio feature
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronM04 committed Jan 27, 2021
1 parent ce57c56 commit 2e00be6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/cpal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ jobs:
run: sudo apt-get install libasound2-dev
- name: Install libjack
run: sudo apt-get install libjack-jackd2-dev libjack-jackd2-0
- name: Install sndio
run: |
sudo apt-get install build-essential &&
git clone https://caoua.org/git/sndio &&
cd sndio &&
./configure &&
make &&
sudo mkdir /var/run/sndiod &&
sudo useradd -r -g audio -s /sbin/nologin -d /var/run/sndiod sndiod &&
sudo make install &&
sudo ldconfig
- name: Install stable
uses: actions-rs/toolchain@v1
with:
Expand All @@ -98,6 +109,11 @@ jobs:
with:
command: test
args: --all --all-features --verbose
- name: Run with jack feature
uses: actions-rs/cargo@v1
with:
command: test
args: --all --features jack --verbose

linux-check-and-test-armv7:
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords = ["audio", "sound"]

[features]
asio = ["asio-sys", "num-traits"] # Only available on Windows. See README for setup instructions.
linux-sndio = ["sndio-sys", "libc"] # sndio on Linux (normally this is only used on OpenBSD)

[dependencies]
thiserror = "1.0.2"
Expand All @@ -34,6 +35,10 @@ libc = "0.2.65"
parking_lot = "0.11"
jack = { version = "0.6.5", optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
sndio-sys = { version = "0.0.*", optional = true }
libc = { version = "0.2.65", optional = true }

[target.'cfg(target_os = "openbsd")'.dependencies]
sndio-sys = "0.0.*"
libc = "0.2.65"
Expand Down
5 changes: 4 additions & 1 deletion src/host/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ pub(crate) mod jack;
pub(crate) mod null;
#[cfg(target_os = "android")]
pub(crate) mod oboe;
#[cfg(target_os = "openbsd")]
#[cfg(any(
target_os = "openbsd",
all(target_os = "linux", feature = "linux-sndio")
))]
pub(crate) mod sndio;
#[cfg(windows)]
pub(crate) mod wasapi;
Expand Down
26 changes: 23 additions & 3 deletions src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,30 +448,50 @@ macro_rules! impl_platform_host {
// TODO: Add pulseaudio and jack here eventually.
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
mod platform_impl {
#[cfg(not(feature = "linux-sndio"))]
pub use crate::host::alsa::{
Device as AlsaDevice, Devices as AlsaDevices, Host as AlsaHost, Stream as AlsaStream,
SupportedInputConfigs as AlsaSupportedInputConfigs,
SupportedOutputConfigs as AlsaSupportedOutputConfigs,
};
#[cfg(feature = "jack")]
#[cfg(all(feature = "jack", not(feature = "linux-sndio")))]
pub use crate::host::jack::{
Device as JackDevice, Devices as JackDevices, Host as JackHost, Stream as JackStream,
SupportedInputConfigs as JackSupportedInputConfigs,
SupportedOutputConfigs as JackSupportedOutputConfigs,
};

#[cfg(feature = "jack")]
#[cfg(all(feature = "jack", not(feature = "linux-sndio")))]
impl_platform_host!(Jack jack "JACK", Alsa alsa "ALSA");

#[cfg(not(feature = "jack"))]
#[cfg(all(not(feature = "jack"), not(feature = "linux-sndio")))]
impl_platform_host!(Alsa alsa "ALSA");

/// The default host for the current compilation target platform.
#[cfg(not(feature = "linux-sndio"))]
pub fn default_host() -> Host {
AlsaHost::new()
.expect("the default host should always be available")
.into()
}

#[cfg(feature = "linux-sndio")]
pub use crate::host::sndio::{
Device as SndioDevice, Devices as SndioDevices, Host as SndioHost, Stream as SndioStream,
SupportedInputConfigs as SndioSupportedInputConfigs,
SupportedOutputConfigs as SndioSupportedOutputConfigs,
};

#[cfg(feature = "linux-sndio")]
impl_platform_host!(Sndio sndio "sndio");

/// The default host for the current compilation target platform.
#[cfg(feature = "linux-sndio")]
pub fn default_host() -> Host {
SndioHost::new()
.expect("the default host should always be available")
.into()
}
}

#[cfg(target_os = "openbsd")]
Expand Down

0 comments on commit 2e00be6

Please sign in to comment.