Skip to content

Replace coreaudio-sys with objc2-audio-toolbox - #26

Merged
mrDIMAS merged 1 commit into
mrDIMAS:mainfrom
emilk:objc2-coreaudio
Sep 26, 2026
Merged

mrDIMAS merged 1 commit into
mrDIMAS:mainfrom
emilk:objc2-coreaudio

Conversation

@emilk

@emilk emilk commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

coreaudio-sys generates its bindings with bindgen at build time. That makes every macOS/iOS build of tinyaudio depend on libclang and the full SDK headers, and it breaks when cross-compiling.
For example, with cargo-zigbuild on Linux, AudioToolbox.h fails to parse ('AudioToolbox/CASpatialAudioExperience.h' file not found) because TARGET_OS_OSX ends up unset.

This switches the CoreAudio backend to objc2-audio-toolbox and objc2-core-audio-types, which ship pregenerated bindings for the same AudioQueue API.
The backend logic is unchanged; only the types and signatures differ (NonNull out-pointers, bool instead of Boolean, extern "C-unwind" callback).
The dependency tree no longer contains bindgen, and builds are faster.

Tested on macOS (Apple Silicon): the sine example plays, and the data callback fires about 47 times per second at 48 kHz with 1024-frame buffers, as expected.
Not tested on iOS.


Disclosure: this PR was written by Claude, an AI coding assistant, working for @emilk.

coreaudio-sys runs bindgen on the macOS SDK headers at build time, which
needs libclang and breaks when cross-compiling, e.g. with cargo-zigbuild.
objc2-audio-toolbox ships pregenerated bindings for the same AudioQueue API.
@mrDIMAS

mrDIMAS commented Sep 26, 2026

Copy link
Copy Markdown
Owner

I'm not a huge fan of AI-generated code, but this one looks ok and fixes real problem.

@mrDIMAS
mrDIMAS merged commit 540a6a1 into mrDIMAS:main Sep 26, 2026
9 checks passed
@sourcebox

Copy link
Copy Markdown

I'm not a huge fan of AI-generated code, but this one looks ok and fixes real problem.

It looks quite similar to what a human would have done by hand. So likely no complaints from a technical pov.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants