mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

OSX ma_context_init__coreaudio fails to open dylibs #750

Closed dezi closed 1 year ago

dezi commented 1 year ago

After upgrading my macbook to OSX 13.5.2 (22G91), miniaudio all of a sudden fails to

dlopen("CoreFoundation.framework/CoreFoundation", RTLD_NOW)

with the dlerror string:

dlerror=dlopen(CoreFoundation.framework/CoreFoundation, 0x0002): tried: 'CoreFoundation.framework/CoreFoundation' (no such file), '/System/Volumes/Preboot/Cryptexes/OSCoreFoundation.framework/CoreFoundation' (no such file), '/usr/lib/CoreFoundation.framework/CoreFoundation' (no such file, not in dyld cache), 'CoreFoundation.framework/CoreFoundation' (no such file)

Given an absolute path, it is able to open the dylib:

dlopen("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", RTLD_NOW)

I made a temporary workaround in my copy of miniaudo.h with all absolute paths to the different libraries for OSX, so my miniaudio is back online.

I posted this bug at

https://developer.apple.com/forums/thread/739136

but as far i can see, Apple is reluctant in picking up this issue.

What could we do inside miniaudio to fix this issue? Is it possible to do some kind of fallback here?

Regards dezi

inlife commented 1 year ago

Having a similar same issue on macOS 14.0 (Sonoma)

miniaudio silently fails to load any backend and switches to Null backend

Also confirming that adding "/System/Library/Frameworks/" prefix to all macOS ma_dlopen .framework paths solves the issue

mackron commented 1 year ago

Yes there's a work around for this. Use MA_NO_RUNTIME_LINKING. See section 2.2 in the documentation for details: https://miniaud.io/docs/manual/#Building

This has been reported a lot lately. I think it's time to update miniaudio to force compile-time linking for macOS/iOS. Will leave this item open to remind me to get that done.

inlife commented 1 year ago

Awesome, thanks @mackron 🎉 Will be looking forward to that!

mackron commented 1 year ago

I've gone ahead and added the "/System/Library/Frameworks/" prefix to the relevant dlopen() calls. I haven't tested this on my side yet. It's in the dev branch if you were wanting to try that.

As for enforcing compile-time linking - I'll probably delay that to the 0.12 release so I don't unnecessarily break anyone's builds in the 0.11 release cycle.

khiner commented 1 year ago

I ran into this as well, and it's fixed for me on dev. Thanks for the fix! This would be nice to have in the split header files as well.

mackron commented 1 year ago

I'll be doing a release in the coming days at which time I'll update the split version.

mackron commented 1 year ago

I've released version 0.11.19 which includes this fix. I'm going to go ahead and close this one to clean up the issue tracker, but I've got an item on my todo list to consider forcing compile-time linking for Apple platforms.

Thanks for the report and confirming the fix.