Skip to content

Commit

Permalink
Implement device enumeration for WASAPI driver backend
Browse files Browse the repository at this point in the history
  • Loading branch information
geom3trik committed Jul 27, 2024
1 parent 4f1dc32 commit 24f0f24
Show file tree
Hide file tree
Showing 7 changed files with 480 additions and 4 deletions.
129 changes: 129 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ cfg_aliases = "0.2.1"
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd"))'.dependencies]
alsa = "0.9.0"

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.58.0", features = [
"Win32_Media_Audio",
"Win32_Foundation",
"Win32_Devices_Properties",
"Win32_Media_KernelStreaming",
"Win32_System_Com_StructuredStorage",
"Win32_System_Threading",
"Win32_Security",
"Win32_System_SystemServices",
"Win32_System_Variant",
"Win32_Media_Multimedia",
"Win32_UI_Shell_PropertiesSystem"
]}

[[example]]
name = "enumerate_alsa"
path = "examples/enumerate_alsa.rs"

[[example]]
name = "enumerate_wasapi"
path = "examples/enumerate_wasapi.rs"

3 changes: 2 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ fn main() {
// Setup cfg aliases
cfg_aliases! {
os_alsa: { any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd",
target_os = "netbsd") }
target_os = "netbsd") },
os_wasapi: { target_os = "windows" }
}
}
4 changes: 1 addition & 3 deletions examples/enumerate_alsa.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::error::Error;

mod util;

#[cfg(os_alsa)]
fn main() -> Result<(), Box<dyn Error>> {
fn main() -> Result<(), Box<dyn std::error::Error>> {
use crate::util::enumerate::enumerate_devices;
use interflow::backends::alsa::AlsaDriver;
enumerate_devices(AlsaDriver::default())
Expand Down
14 changes: 14 additions & 0 deletions examples/enumerate_wasapi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mod util;

#[cfg(os_wasapi)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
use crate::util::enumerate::enumerate_devices;
use interflow::backends::wasapi::WasapiDriver;
enumerate_devices(WasapiDriver)
}

#[cfg(not(os_wasapi))]
fn main() {
println!("WASAPI driver is not available on this platform");
}

3 changes: 3 additions & 0 deletions src/backends/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#[cfg(os_alsa)]
pub mod alsa;

#[cfg(os_wasapi)]
pub mod wasapi;
Loading

0 comments on commit 24f0f24

Please sign in to comment.