From d9e0a4711efcdde3c43bdcd2bfd64d84b4ca7fcb Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Mon, 13 Nov 2023 14:41:52 +0100 Subject: [PATCH] Add a feature for MacOS' IOKit/audio/IOAudioTypes.h When querying an AudioStream for its terminal type (kAudioStreamPropertyTerminalType) it will often return a value defined in IOAudioTypes.h (the ranges [INPUT_UNDEFINED, INPUT_MODEM_AUDIO] and [OUTPUT_UNDEFINED, OUTPUT_LOW_FREQUENCY_EFFECTS_SPEAKER]). This commit adds a feature io_kit_audio that will generate rust bindings for IOAudioTypes.h, so these enum values can be used in rust directly. --- Cargo.toml | 1 + build.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 896a7a6..be1c83f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ default = ["audio_toolbox", "audio_unit", "core_audio", "open_al", "core_midi"] audio_toolbox = [] audio_unit = [] core_audio = [] +io_kit_audio = [] open_al = [] core_midi = [] diff --git a/build.rs b/build.rs index 81cfbcc..7083f9c 100644 --- a/build.rs +++ b/build.rs @@ -86,6 +86,13 @@ fn build(sdk_path: Option<&str>, target: &str) { } } + #[cfg(feature = "io_kit_audio")] + { + assert!(target.contains("apple-darwin")); + println!("cargo:rustc-link-lib=framework=IOKit"); + headers.push("IOKit/audio/IOAudioTypes.h"); + } + #[cfg(feature = "open_al")] { println!("cargo:rustc-link-lib=framework=OpenAL");