Skip to content

Commit ae8d7b8

Browse files
committed
sndio: test CI with linux-sndio feature
1 parent ce57c56 commit ae8d7b8

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

.github/workflows/cpal.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ jobs:
8282
run: sudo apt-get install libasound2-dev
8383
- name: Install libjack
8484
run: sudo apt-get install libjack-jackd2-dev libjack-jackd2-0
85+
- name: Install sndio
86+
run: |
87+
sudo apt-get install build-essential &&
88+
git clone https://caoua.org/git/sndio &&
89+
cd sndio &&
90+
./configure &&
91+
make &&
92+
sudo mkdir /var/run/sndiod &&
93+
sudo useradd -r -g audio -s /sbin/nologin -d /var/run/sndiod sndiod &&
94+
sudo make install &&
95+
sudo ldconfig
8596
- name: Install stable
8697
uses: actions-rs/toolchain@v1
8798
with:
@@ -98,6 +109,11 @@ jobs:
98109
with:
99110
command: test
100111
args: --all --all-features --verbose
112+
- name: Run with jack feature
113+
uses: actions-rs/cargo@v1
114+
with:
115+
command: test
116+
args: --all --features jack --verbose
101117

102118
linux-check-and-test-armv7:
103119
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ keywords = ["audio", "sound"]
1010

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

1415
[dependencies]
1516
thiserror = "1.0.2"
@@ -34,7 +35,7 @@ libc = "0.2.65"
3435
parking_lot = "0.11"
3536
jack = { version = "0.6.5", optional = true }
3637

37-
[target.'cfg(target_os = "openbsd")'.dependencies]
38+
[target.'cfg(or(target_os = "openbsd", and(target_os = "linux", feature = "linux-sndio")))'.dependencies]
3839
sndio-sys = "0.0.*"
3940
libc = "0.2.65"
4041

src/host/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(crate) mod jack;
1414
pub(crate) mod null;
1515
#[cfg(target_os = "android")]
1616
pub(crate) mod oboe;
17-
#[cfg(target_os = "openbsd")]
17+
#[cfg(or(target_os = "openbsd", and(target_os = "linux", feature = "linux-sndio")))]
1818
pub(crate) mod sndio;
1919
#[cfg(windows)]
2020
pub(crate) mod wasapi;

src/platform/mod.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,30 +448,50 @@ macro_rules! impl_platform_host {
448448
// TODO: Add pulseaudio and jack here eventually.
449449
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
450450
mod platform_impl {
451+
#[cfg(not(feature = "linux-sndio"))]
451452
pub use crate::host::alsa::{
452453
Device as AlsaDevice, Devices as AlsaDevices, Host as AlsaHost, Stream as AlsaStream,
453454
SupportedInputConfigs as AlsaSupportedInputConfigs,
454455
SupportedOutputConfigs as AlsaSupportedOutputConfigs,
455456
};
456-
#[cfg(feature = "jack")]
457+
#[cfg(and(feature = "jack", not(feature = "linux-sndio")))]
457458
pub use crate::host::jack::{
458459
Device as JackDevice, Devices as JackDevices, Host as JackHost, Stream as JackStream,
459460
SupportedInputConfigs as JackSupportedInputConfigs,
460461
SupportedOutputConfigs as JackSupportedOutputConfigs,
461462
};
462463

463-
#[cfg(feature = "jack")]
464+
#[cfg(and(feature = "jack", not(feature = "linux-sndio")))]
464465
impl_platform_host!(Jack jack "JACK", Alsa alsa "ALSA");
465466

466-
#[cfg(not(feature = "jack"))]
467+
#[cfg(and(not(feature = "jack"), not(feature = "linux-sndio")))]
467468
impl_platform_host!(Alsa alsa "ALSA");
468469

469470
/// The default host for the current compilation target platform.
471+
#[cfg(not(feature = "linux-sndio"))]
470472
pub fn default_host() -> Host {
471473
AlsaHost::new()
472474
.expect("the default host should always be available")
473475
.into()
474476
}
477+
478+
#[cfg(feature = "linux-sndio")]
479+
pub use crate::host::sndio::{
480+
Device as SndioDevice, Devices as SndioDevices, Host as SndioHost, Stream as SndioStream,
481+
SupportedInputConfigs as SndioSupportedInputConfigs,
482+
SupportedOutputConfigs as SndioSupportedOutputConfigs,
483+
};
484+
485+
#[cfg(feature = "linux-sndio")]
486+
impl_platform_host!(Sndio sndio "sndio");
487+
488+
/// The default host for the current compilation target platform.
489+
#[cfg(feature = "linux-sndio")]
490+
pub fn default_host() -> Host {
491+
SndioHost::new()
492+
.expect("the default host should always be available")
493+
.into()
494+
}
475495
}
476496

477497
#[cfg(target_os = "openbsd")]

0 commit comments

Comments
 (0)