Skip to content

Commit

Permalink
Add the CoreAudio framework
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jan 12, 2025
1 parent 4b06c5d commit 25bb2c7
Show file tree
Hide file tree
Showing 16 changed files with 194 additions and 41 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/header-translator/src/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ impl Ty {
let declaration = ty.get_declaration().expect("record declaration");
let id = ItemIdentifier::new_optional(&declaration, context);

// Override for self-referential types
// Override for self-referential / recursive types
let fields = if matches!(
id.name.as_deref(),
Some(
Expand Down
1 change: 1 addition & 0 deletions crates/objc2/src/topics/about_generated/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `AVFoundation` / `objc2-av-foundation`.
- `AVRouting` / `objc2-av-routing`.
- `CoreAudioTypes` / `objc2-core-audio-types`.
- `CoreAudio` / `objc2-core-audio`.
- `ColorSync` / `objc2-color-sync`.
- `CoreGraphics` / `objc2-core-graphics`.
- `CoreFoundation` / `objc2-core-foundation`.
Expand Down
1 change: 1 addition & 0 deletions crates/objc2/src/topics/about_generated/list_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
| `ColorSync` | [![`objc2-color-sync`](https://badgen.net/crates/v/objc2-color-sync)](https://crates.io/crates/objc2-color-sync) | [![docs.rs](https://docs.rs/objc2-color-sync/badge.svg)](https://docs.rs/objc2-color-sync/) |
| `Contacts` | [![`objc2-contacts`](https://badgen.net/crates/v/objc2-contacts)](https://crates.io/crates/objc2-contacts) | [![docs.rs](https://docs.rs/objc2-contacts/badge.svg)](https://docs.rs/objc2-contacts/) |
| `ContactsUI` | [![`objc2-contacts-ui`](https://badgen.net/crates/v/objc2-contacts-ui)](https://crates.io/crates/objc2-contacts-ui) | [![docs.rs](https://docs.rs/objc2-contacts-ui/badge.svg)](https://docs.rs/objc2-contacts-ui/) |
| `CoreAudio` | [![`objc2-core-audio`](https://badgen.net/crates/v/objc2-core-audio)](https://crates.io/crates/objc2-core-audio) | [![docs.rs](https://docs.rs/objc2-core-audio/badge.svg)](https://docs.rs/objc2-core-audio/) |
| `CoreAudioTypes` | [![`objc2-core-audio-types`](https://badgen.net/crates/v/objc2-core-audio-types)](https://crates.io/crates/objc2-core-audio-types) | [![docs.rs](https://docs.rs/objc2-core-audio-types/badge.svg)](https://docs.rs/objc2-core-audio-types/) |
| `CoreBluetooth` | [![`objc2-core-bluetooth`](https://badgen.net/crates/v/objc2-core-bluetooth)](https://crates.io/crates/objc2-core-bluetooth) | [![docs.rs](https://docs.rs/objc2-core-bluetooth/badge.svg)](https://docs.rs/objc2-core-bluetooth/) |
| `CoreData` | [![`objc2-core-data`](https://badgen.net/crates/v/objc2-core-data)](https://crates.io/crates/objc2-core-data) | [![docs.rs](https://docs.rs/objc2-core-data/badge.svg)](https://docs.rs/objc2-core-data/) |
Expand Down
3 changes: 3 additions & 0 deletions crates/test-frameworks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ test-frameworks = [
"objc2-contacts/all",
"dep:objc2-contacts-ui",
"objc2-contacts-ui/all",
"dep:objc2-core-audio",
"objc2-core-audio/all",
"dep:objc2-core-audio-types",
"objc2-core-audio-types/all",
"dep:objc2-core-bluetooth",
Expand Down Expand Up @@ -227,6 +229,7 @@ objc2-accessibility = { path = "../../framework-crates/objc2-accessibility", opt
objc2-authentication-services = { path = "../../framework-crates/objc2-authentication-services", optional = true }
objc2-cloud-kit = { path = "../../framework-crates/objc2-cloud-kit", optional = true }
objc2-color-sync = { path = "../../framework-crates/objc2-color-sync", optional = true }
objc2-core-audio = { path = "../../framework-crates/objc2-core-audio", optional = true }
objc2-core-audio-types = { path = "../../framework-crates/objc2-core-audio-types", optional = true }
objc2-core-bluetooth = { path = "../../framework-crates/objc2-core-bluetooth", optional = true }
objc2-core-data = { path = "../../framework-crates/objc2-core-data", optional = true }
Expand Down
9 changes: 6 additions & 3 deletions framework-crates/objc2-audio-toolbox/Cargo.toml

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

14 changes: 0 additions & 14 deletions framework-crates/objc2-audio-toolbox/translation-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,6 @@ class.AUAudioUnitBus.methods."setFormat:error:".skipped = true
class.AUAudioUnit.methods."shouldChangeToFormat:forBus:".skipped = true
class.AUAudioUnitBus.methods."initWithFormat:error:".skipped = true

# Needs CoreAudio
fn.AudioHardwareServiceHasProperty.skipped = true
fn.AudioHardwareServiceIsPropertySettable.skipped = true
fn.AudioHardwareServiceGetPropertyDataSize.skipped = true
fn.AudioHardwareServiceGetPropertyData.skipped = true
fn.AudioHardwareServiceSetPropertyData.skipped = true
fn.AudioHardwareServiceAddPropertyListener.skipped = true
fn.AudioHardwareServiceRemovePropertyListener.skipped = true
enum.anonymous.constants.kAudioHardwareServiceProperty_ServiceRestarted.skipped = true
enum.anonymous.constants.kAudioHardwareServiceDeviceProperty_VirtualMainVolume.skipped = true
enum.anonymous.constants.kAudioHardwareServiceDeviceProperty_VirtualMasterVolume.skipped = true
enum.anonymous.constants.kAudioHardwareServiceDeviceProperty_VirtualMainBalance.skipped = true
enum.anonymous.constants.kAudioHardwareServiceDeviceProperty_VirtualMasterBalance.skipped = true

# Needs ComponentDescription from CoreServices
fn.AUGraphNewNode.skipped = true
fn.AUGraphGetNodeInfo.skipped = true
Expand Down
73 changes: 73 additions & 0 deletions framework-crates/objc2-core-audio/Cargo.toml

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

14 changes: 14 additions & 0 deletions framework-crates/objc2-core-audio/README.md

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

1 change: 1 addition & 0 deletions framework-crates/objc2-core-audio/src/generated

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

26 changes: 26 additions & 0 deletions framework-crates/objc2-core-audio/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//! # Bindings to the `CoreAudio` framework
//!
//! See [Apple's docs][apple-doc] and [the general docs on framework crates][framework-crates] for more information.
//!
//! [apple-doc]: https://developer.apple.com/documentation/coreaudio/
//! [framework-crates]: https://docs.rs/objc2/latest/objc2/topics/about_generated/index.html
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// Update in Cargo.toml as well.
#![doc(html_root_url = "https://docs.rs/objc2-core-audio/0.2.2")]

#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std;

mod generated;
#[allow(unused_imports, unreachable_pub)]
pub use self::generated::*;

// MacTypes.h
#[allow(dead_code)]
pub(crate) type Boolean = u8;
#[allow(dead_code)]
pub(crate) type OSStatus = i32;
28 changes: 28 additions & 0 deletions framework-crates/objc2-core-audio/translation-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
framework = "CoreAudio"
crate = "objc2-core-audio"
required-crates = ["objc2-core-foundation"]
custom-lib-rs = true
macos = "10.0"
maccatalyst = "13.1"
ios = "2.0"
tvos = "9.0"
watchos = "3.0"
visionos = "1.0"

# Self-referential / recursive structs
struct.AudioServerPlugInHostInterface.skipped = true
typedef.AudioServerPlugInHostInterface.skipped = true
typedef.AudioServerPlugInHostRef.skipped = true
struct.AudioServerPlugInDriverInterface.skipped = true
typedef.AudioServerPlugInDriverInterface.skipped = true
typedef.AudioServerPlugInDriverRef.skipped = true

# Needs dispatch_queue_t from libdispatch
fn.AudioObjectAddPropertyListenerBlock.skipped = true
fn.AudioObjectRemovePropertyListenerBlock.skipped = true
fn.AudioDeviceCreateIOProcIDWithBlock.skipped = true

# This is currently emitted incorrectly, the union field is
# not included, which is an ABI mismatch.
struct.AudioServerPlugInIOCycleInfo.skipped = true
typedef.AudioServerPlugInIOCycleInfo.skipped = true
15 changes: 11 additions & 4 deletions framework-crates/objc2-core-media/Cargo.toml

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

5 changes: 0 additions & 5 deletions framework-crates/objc2-core-media/translation-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ fn.CMTimebaseRemoveTimerDispatchSource.skipped = true
fn.CMTimebaseSetTimerDispatchSourceNextFireTime.skipped = true
fn.CMTimebaseSetTimerDispatchSourceToFireImmediately.skipped = true

# Needs AudioDeviceID from CoreAudio
fn.CMAudioDeviceClockCreateFromAudioDeviceID.skipped = true
fn.CMAudioDeviceClockSetAudioDeviceID.skipped = true
fn.CMAudioDeviceClockGetAudioDevice.skipped = true

# Unknown how to handle the calling convention for arrays
fn.CMTextFormatDescriptionGetDefaultStyle.skipped = true

Expand Down

0 comments on commit 25bb2c7

Please sign in to comment.