Closed sofakng closed 1 year ago
Those errors are coming from inside the Core Audio headers. Not much I can do about those. I can see references to code like (^AudioObjectPropertyListenerBlock)
- the use of that ^
token is clearly invalid C. It could be an issue with your compilation environment. Perhaps try compiling as Objective-C.
Thanks for the reply...
However, does miniaudio expect clang on macOS? I understand the errors are coming from macOS headers, but miniaudio supports Core Audio, right? If so, was it tested/developed using clang and not gcc?
For example, I'm trying to compile examples/simple_playback.c using gcc-12 (on macOS) but it fails with many errors.
Yes, Core Audio is supported, and it works fine with Clang (and Xcode). I don't think I've personally tried compiling with GCC on macOS. I'm not doing anything unusual in miniaudio so the miniaudio-specific code should compile clean. If there's errors there I'm happy to fix those, but I'm not spending any time trying to work around invalid C in necessary system headers.
OK - Thanks for the information and I understand what you're saying.
Are there any alternative audio backends for macOS besides Core Audio?
Not built-in, no. But miniaudio supports custom backends. The custom_backend example implements an SDL backend.
I mean, it would be nice for GCC to "Just Work" on macOS, but it's just not a primary platform for me personally so I tend to not give it as much priority. How did you install GCC? I might be able to see if I can replicate it myself at some point.
Got it. It looks like your SDL example custom_backend works perfectly. Thanks so much!
I was using GCC v12 installed from Homebrew if you are curious and feel like looking into it. However, I'll go ahead and close this issue. Thanks again so much for the help and for the great project!
I'm running macOS Ventura (13.2.1) and Homebrew (v4.0.10) and I've installed GCC-12 (v12.2.0).
I've downloaded the latest git release of miniaudio (April 1st, 2023) and I'm trying to compile examples/simple_playback.c.
If I compile using clang (/usr/bin/clang, v14.0.0) then it compiles fine. However, if I use GCC-12 it has a lot of errors:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h:18, from ../miniaudio.h:31677, from simple_playback.c:14: /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:162:2: error: expected identifier or '(' before '^' token 162 | (^AudioObjectPropertyListenerBlock)( UInt32 inNumberAddresses, | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:400:41: error: unknown type name 'AudioObjectPropertyListenerBlock'; did you mean 'AudioObjectPropertyListenerProc'? 400 | AudioObjectPropertyListenerBlock inListener) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_7_0); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | AudioObjectPropertyListenerProc /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:421:41: error: unknown type name 'AudioObjectPropertyListenerBlock'; did you mean 'AudioObjectPropertyListenerProc'? 421 | AudioObjectPropertyListenerBlock inListener) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_7_0); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | AudioObjectPropertyListenerProc /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:804:2: error: expected identifier or '(' before '^' token 804 | (^AudioDeviceIOBlock)( const AudioTimeStamp* inNow, | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:1353:37: error: unknown type name 'AudioDeviceIOBlock'; did you mean 'AudioDeviceIOProc'? 1353 | AudioDeviceIOBlock inIOBlock) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_7_0); | ^~~~~~~~~~~~~~~~~~ | AudioDeviceIOProc In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioCodec.h:84, from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:17, from ../miniaudio.h:31682: /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioComponent.h:516:39: error: expected ')' before '^' token 516 | void (^inCompletionHandler)(AudioComponentInstance __nullable, OSStatus)) | ^ | ) /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioComponent.h:702:122: error: expected ')' before '^' token 702 | void (^inCompletionHandler)(AudioComponentValidationResult, CFDictionaryRef)) | ^ | ) In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnit.h:21, from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AUGraph.h:30, from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:21: /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnitProperties.h:1386:15: error: expected identifier or '(' before '^' token 1386 | typedef void (^AURenderContextObserver)(const AudioUnitRenderContext *context) | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnitProperties.h:1413:19: error: expected identifier or '(' before '^' token 1413 | typedef OSStatus (^ AUMIDIEventListBlock)(AUEventSampleTime eventSampleTime, | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnitProperties.h:1753:15: error: expected identifier or '(' before '^' token 1753 | typedef void (^AudioUnitRemoteControlEventListener)(AudioUnitRemoteControlEvent event); | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnitProperties.h:2625:15: error: expected identifier or '(' before '^' token 2625 | typedef void (^AUVoiceIOMutedSpeechActivityEventListener)(AUVoiceIOSpeechActivityEvent event); | ^ In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:30: /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioServices.h:212:51: error: expected ')' before '^' token 212 | void (^__nullable inCompletionBlock)(void)) | ^ | ) /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioServices.h:229:55: error: expected ')' before '^' token 229 | void (^__nullable inCompletionBlock)(void)) | ^ | ) In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/MusicPlayer.h:44, from /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:39: /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:322:2: error: expected identifier or '(' before '^' token 322 | (^MIDINotifyBlock)(const MIDINotification *message); | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:342:2: error: expected identifier or '(' before '^' token 342 | (^MIDIReceiveBlock)(const MIDIEventList *evtlist, void * __nullable srcConnRefCon); | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:385:2: error: expected identifier or '(' before '^' token 385 | (^MIDIReadBlock)(const MIDIPacketList *pktlist, void * __nullable srcConnRefCon) API_DEPRECATED("use MIDIReceiveBlock and MIDIEventLists", macos(10.11, API_TO_BE_DEPRECATED), ios(9.0, API_TO_BE_DEPRECATED)) __TVOS_PROHIBITED __WATCHOS_PROHIBITED; | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1303:41: error: unknown type name 'MIDINotifyBlock'; did you mean 'MIDINotifyProc'? 1303 | MIDINotifyBlock __nullable notifyBlock ) API_AVAILABLE(macos(10.11), ios(9.0)) API_UNAVAILABLE(tvos, watchos); | ^~~~~~~~~~~~~~~ | MIDINotifyProc /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1361:65: error: unknown type name 'MIDIReceiveBlock' 1361 | MIDIReceiveBlock receiveBlock ) API_AVAILABLE(macos(11.0), ios(14.0)) API_UNAVAILABLE(tvos, watchos); | ^~~~~~~~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1426:65: error: unknown type name 'MIDIReadBlock'; did you mean 'MIDIReadProc'? 1426 | MIDIReadBlock readBlock ) | ^~~~~~~~~~~~~ | MIDIReadProc /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1780:73: error: unknown type name 'MIDIReceiveBlock' 1780 | MIDIReceiveBlock readBlock ) API_AVAILABLE(macos(11.0), ios(14.0)) API_UNAVAILABLE(tvos, watchos); | ^~~~~~~~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks/CoreMIDI.framework/Headers/MIDIServices.h:1861:65: error: unknown type name 'MIDIReadBlock'; did you mean 'MIDIReadProc'? 1861 | MIDIReadBlock readBlock ) | ^~~~~~~~~~~~~ | MIDIReadProc
output.txt
Unfortunately I need to use GCC to compile another project so I can't switch to clang...