From 00949481ba6e1be875b3efd40ed750c99d3691ca Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Tue, 6 Sep 2022 12:10:11 -0400 Subject: [PATCH 1/5] [AudioToolbox] Add support for xcode 14 beta6. --- src/AudioToolbox/Enums.cs | 14 ++ src/AudioUnit/AUEnums.cs | 10 ++ src/AudioUnit/AudioComponent.cs | 125 +++++++++++++++++- .../MacCatalyst-AudioToolbox.todo | 21 --- .../common-AudioToolbox.ignore | 21 +++ .../iOS-AudioToolbox.todo | 23 ---- .../macOS-AudioToolbox.ignore | 18 --- .../macOS-AudioToolbox.todo | 5 - .../tvOS-AudioToolbox.todo | 18 --- tests/xtro-sharpie/common-AudioToolbox.ignore | 20 +++ tests/xtro-sharpie/iOS-AudioToolbox.todo | 23 ---- tests/xtro-sharpie/macOS-AudioToolbox.ignore | 17 --- tests/xtro-sharpie/macOS-AudioToolbox.todo | 5 - tests/xtro-sharpie/tvOS-AudioToolbox.todo | 18 --- 14 files changed, 189 insertions(+), 149 deletions(-) delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-AudioToolbox.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/iOS-AudioToolbox.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/macOS-AudioToolbox.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/tvOS-AudioToolbox.todo delete mode 100644 tests/xtro-sharpie/iOS-AudioToolbox.todo delete mode 100644 tests/xtro-sharpie/macOS-AudioToolbox.todo delete mode 100644 tests/xtro-sharpie/tvOS-AudioToolbox.todo diff --git a/src/AudioToolbox/Enums.cs b/src/AudioToolbox/Enums.cs index d4ea1da27de4..4851d433820c 100644 --- a/src/AudioToolbox/Enums.cs +++ b/src/AudioToolbox/Enums.cs @@ -49,4 +49,18 @@ public enum AUSpatialMixerSourceMode : uint AmbienceBed = 3, } + [NoWatch] + [TV (16, 0)] + [Mac (13, 0)] + [iOS (16, 0)] + public enum AUSpatialMixerPersonalizedHrtfMode : uint + { + [NoiOS, NoTV] + Off = 0, + [NoiOS, NoTV] + On = 1, + [NoiOS, NoTV] + Auto = 2, + } + } diff --git a/src/AudioUnit/AUEnums.cs b/src/AudioUnit/AUEnums.cs index f0cd675e4ae6..60d2d3808736 100644 --- a/src/AudioUnit/AUEnums.cs +++ b/src/AudioUnit/AUEnums.cs @@ -892,6 +892,16 @@ public enum AUVoiceIOSpeechActivityEvent : uint Ended = 1, } + [iOS (16,0), TV (16,0), Mac (13,0), MacCatalyst (16,0)] + public enum AudioUnitEventType : uint + { + ParameterValueChange = 0, + BeginParameterChangeGesture = 1, + EndParameterChangeGesture = 2, + PropertyChange = 3, + } + + public enum AudioUnitSubType : uint { AUConverter = 0x636F6E76, // 'conv' diff --git a/src/AudioUnit/AudioComponent.cs b/src/AudioUnit/AudioComponent.cs index 13e772338da1..6c564cb873b0 100644 --- a/src/AudioUnit/AudioComponent.cs +++ b/src/AudioUnit/AudioComponent.cs @@ -523,6 +523,128 @@ public double LastActiveTime { #endif #if IOS || MONOMAC + +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] +#endif + [DllImport (Constants.AudioUnitLibrary)] + static extern int AudioComponentCopyConfigurationInfo (IntPtr /* AudioComponent */ inComponent, out /* CFDictionaryRef** */ IntPtr outConfigurationInfo); + +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] +#endif + public NSDictionary? ConfigurationInfo { + get { + var success = AudioComponentCopyConfigurationInfo (GetCheckedHandle (), out var dictPtr); + if (success == 0) { + return Runtime.GetNSObject (dictPtr, owns: true); + } + return null; + } + } + +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] + [MacCatalyst (16,0)] +#endif + [DllImport (Constants.AudioUnitLibrary)] + static extern int AudioComponentValidate (IntPtr /* AudioComponent* */ inComponent, IntPtr /* CFDictionaryRef* */ inValidationParameters, + out AudioComponentValidationResult outValidationResult); + +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] + [MacCatalyst (16,0)] +#endif + public AudioComponentValidationResult Validate (NSDictionary validationParameters) { + var success = AudioComponentValidate (GetCheckedHandle (), validationParameters.GetNonNullHandle (nameof (validationParameters)), out var result); + if (success == 0) + return result; + return AudioComponentValidationResult.Unknown; + } + + delegate void TrampolineCallback (IntPtr blockPtr, AudioComponentValidationResult result, IntPtr dictionary); + + static unsafe readonly TrampolineCallback static_action = TrampolineAction; + + [MonoPInvokeCallback (typeof (TrampolineCallback))] + static void TrampolineAction (IntPtr blockPtr, AudioComponentValidationResult result, IntPtr dictionary) + { + var del = BlockLiteral.GetTarget> (blockPtr); + if (del is not null) + del (result, Runtime.GetNSObject(dictionary)); + } + +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] +#endif + [DllImport (Constants.AudioUnitLibrary)] + static extern int AudioComponentValidateWithResults (IntPtr /* AudioComponent* */ inComponent, IntPtr /* CFDictionaryRef* */ inValidationParameters, ref BlockLiteral inCompletionHandler); + +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] +#endif + public void ValidateAsync (NSDictionary validationParameters, + Action onCompletion) { + if (onCompletion is null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (onCompletion)); + + var block_handler= new BlockLiteral (); + block_handler.SetupBlockUnsafe (static_action, onCompletion); + try { + AudioComponentValidateWithResults (GetCheckedHandle (), validationParameters.GetNonNullHandle (nameof (validationParameters)), ref block_handler); + } finally { + block_handler.CleanupBlock (); + } + } + #if NET [SupportedOSPlatform ("macos10.13")] [SupportedOSPlatform ("ios11.0")] @@ -608,7 +730,8 @@ public AudioComponentInfo[]? ComponentList { } } } -#endif + +#endif // IOS || MONOMAC #endif // !COREBUILD } diff --git a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-AudioToolbox.todo b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-AudioToolbox.todo deleted file mode 100644 index 920d7d9936a1..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-AudioToolbox.todo +++ /dev/null @@ -1,21 +0,0 @@ -!missing-enum! AudioUnitEventType not bound -!missing-pinvoke! AudioComponentCopyConfigurationInfo is not bound -!missing-pinvoke! AudioComponentValidate is not bound -!missing-pinvoke! AUEventListenerAddEventType is not bound -!missing-pinvoke! AUEventListenerCreate is not bound -!missing-pinvoke! AUEventListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUEventListenerNotify is not bound -!missing-pinvoke! AUEventListenerRemoveEventType is not bound -!missing-pinvoke! AUListenerAddParameter is not bound -!missing-pinvoke! AUListenerCreate is not bound -!missing-pinvoke! AUListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUListenerDispose is not bound -!missing-pinvoke! AUListenerRemoveParameter is not bound -!missing-pinvoke! AUParameterFormatValue is not bound -!missing-pinvoke! AUParameterListenerNotify is not bound -!missing-pinvoke! AUParameterSet is not bound -!missing-pinvoke! AUParameterValueFromLinear is not bound -!missing-pinvoke! AUParameterValueToLinear is not bound -!missing-protocol! AUMessageChannel not bound -!missing-selector! AUAudioUnit::messageChannelFor: not bound -!missing-selector! AUAudioUnitV2Bridge::audioUnit not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/common-AudioToolbox.ignore b/tests/xtro-sharpie/api-annotations-dotnet/common-AudioToolbox.ignore index a32d157be969..19b6c70870d0 100644 --- a/tests/xtro-sharpie/api-annotations-dotnet/common-AudioToolbox.ignore +++ b/tests/xtro-sharpie/api-annotations-dotnet/common-AudioToolbox.ignore @@ -52,6 +52,8 @@ !missing-selector! AUAudioUnit::scheduleMIDIEventBlock not bound !missing-selector! AUAudioUnit::setMusicalContextBlock: not bound !missing-selector! AUAudioUnit::tokenByAddingRenderObserver: not bound +!missing-selector! AUAudioUnit::messageChannelFor: not bound +!missing-selector! AUAudioUnitV2Bridge::audioUnit not bound !missing-type! AUAudioUnitV2Bridge not bound !missing-pinvoke! AudioCodecAppendInputBufferList is not bound !missing-pinvoke! AudioCodecAppendInputData is not bound @@ -77,3 +79,22 @@ !missing-selector! AUAudioUnit::AudioUnitMIDIProtocol not bound !missing-selector! AUAudioUnit::hostMIDIProtocol not bound !missing-selector! AUAudioUnit::setHostMIDIProtocol: not bound + +# ignored in the past on macOS now ignored in every platform. +!missing-pinvoke! AUListenerAddParameter is not bound +!missing-pinvoke! AUListenerRemoveParameter is not bound +!missing-pinvoke! AUListenerCreate is not bound +!missing-pinvoke! AUListenerCreateWithDispatchQueue is not bound +!missing-pinvoke! AUListenerDispose is not bound +!missing-pinvoke! AUEventListenerAddEventType is not bound +!missing-pinvoke! AUEventListenerCreate is not bound +!missing-pinvoke! AUEventListenerCreateWithDispatchQueue is not bound +!missing-pinvoke! AUEventListenerNotify is not bound +!missing-pinvoke! AUEventListenerRemoveEventType is not bound +!missing-pinvoke! AUParameterFormatValue is not bound +!missing-pinvoke! AUParameterListenerNotify is not bound +!missing-pinvoke! AUParameterSet is not bound +!missing-pinvoke! AUParameterValueFromLinear is not bound +!missing-pinvoke! AUParameterValueToLinear is not bound + +!missing-protocol! AUMessageChannel not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-AudioToolbox.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-AudioToolbox.todo deleted file mode 100644 index de547e44b300..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-AudioToolbox.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-enum! AudioUnitEventType not bound -!missing-pinvoke! AudioComponentCopyConfigurationInfo is not bound -!missing-pinvoke! AudioComponentValidate is not bound -!missing-pinvoke! AudioComponentValidateWithResults is not bound -!missing-pinvoke! AUEventListenerAddEventType is not bound -!missing-pinvoke! AUEventListenerCreate is not bound -!missing-pinvoke! AUEventListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUEventListenerNotify is not bound -!missing-pinvoke! AUEventListenerRemoveEventType is not bound -!missing-pinvoke! AUListenerAddParameter is not bound -!missing-pinvoke! AUListenerCreate is not bound -!missing-pinvoke! AUListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUListenerDispose is not bound -!missing-pinvoke! AUListenerRemoveParameter is not bound -!missing-pinvoke! AUParameterFormatValue is not bound -!missing-pinvoke! AUParameterListenerNotify is not bound -!missing-pinvoke! AUParameterSet is not bound -!missing-pinvoke! AUParameterValueFromLinear is not bound -!missing-pinvoke! AUParameterValueToLinear is not bound -!missing-protocol! AUMessageChannel not bound -!missing-selector! AUAudioUnit::messageChannelFor: not bound -!missing-selector! AUAudioUnitV2Bridge::audioUnit not bound -!missing-enum! AUSpatialMixerPersonalizedHRTFMode not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-AudioToolbox.ignore b/tests/xtro-sharpie/api-annotations-dotnet/macOS-AudioToolbox.ignore index 475feb408baa..2f91f974f15d 100644 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-AudioToolbox.ignore +++ b/tests/xtro-sharpie/api-annotations-dotnet/macOS-AudioToolbox.ignore @@ -1,12 +1,9 @@ -!missing-enum! AudioUnitEventType not bound !missing-enum! AUParameterMIDIMappingFlags not bound !missing-enum! CAClockMessage not bound !missing-enum! CAClockPropertyID not bound !missing-enum! CAClockSyncMode not bound !missing-enum! CAClockTimebase not bound !missing-enum! CAClockTimeFormat not bound -!missing-pinvoke! AudioComponentCopyConfigurationInfo is not bound -!missing-pinvoke! AudioComponentValidate is not bound !missing-pinvoke! AudioFileComponentCloseFile is not bound !missing-pinvoke! AudioFileComponentCountUserData is not bound !missing-pinvoke! AudioFileComponentCreateURL is not bound @@ -30,21 +27,6 @@ !missing-pinvoke! AudioFileComponentSetUserData is not bound !missing-pinvoke! AudioFileComponentWriteBytes is not bound !missing-pinvoke! AudioFileComponentWritePackets is not bound -!missing-pinvoke! AUEventListenerAddEventType is not bound -!missing-pinvoke! AUEventListenerCreate is not bound -!missing-pinvoke! AUEventListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUEventListenerNotify is not bound -!missing-pinvoke! AUEventListenerRemoveEventType is not bound -!missing-pinvoke! AUListenerAddParameter is not bound -!missing-pinvoke! AUListenerCreate is not bound -!missing-pinvoke! AUListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUListenerDispose is not bound -!missing-pinvoke! AUListenerRemoveParameter is not bound -!missing-pinvoke! AUParameterFormatValue is not bound -!missing-pinvoke! AUParameterListenerNotify is not bound -!missing-pinvoke! AUParameterSet is not bound -!missing-pinvoke! AUParameterValueFromLinear is not bound -!missing-pinvoke! AUParameterValueToLinear is not bound !missing-pinvoke! CAClockAddListener is not bound !missing-pinvoke! CAClockArm is not bound !missing-pinvoke! CAClockBarBeatTimeToBeats is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-AudioToolbox.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-AudioToolbox.todo deleted file mode 100644 index 7b78f93d9761..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-AudioToolbox.todo +++ /dev/null @@ -1,5 +0,0 @@ -!missing-protocol! AUMessageChannel not bound -!missing-selector! AUAudioUnit::messageChannelFor: not bound -!missing-selector! AUAudioUnitV2Bridge::audioUnit not bound -!missing-pinvoke! AudioComponentValidateWithResults is not bound -!missing-enum! AUSpatialMixerPersonalizedHRTFMode not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-AudioToolbox.todo b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-AudioToolbox.todo deleted file mode 100644 index 5e73f8c56782..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-AudioToolbox.todo +++ /dev/null @@ -1,18 +0,0 @@ -!missing-enum! AudioUnitEventType not bound -!missing-pinvoke! AUEventListenerAddEventType is not bound -!missing-pinvoke! AUEventListenerCreate is not bound -!missing-pinvoke! AUEventListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUEventListenerNotify is not bound -!missing-pinvoke! AUEventListenerRemoveEventType is not bound -!missing-pinvoke! AUListenerAddParameter is not bound -!missing-pinvoke! AUListenerCreate is not bound -!missing-pinvoke! AUListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUListenerDispose is not bound -!missing-pinvoke! AUListenerRemoveParameter is not bound -!missing-pinvoke! AUParameterFormatValue is not bound -!missing-pinvoke! AUParameterListenerNotify is not bound -!missing-pinvoke! AUParameterSet is not bound -!missing-pinvoke! AUParameterValueFromLinear is not bound -!missing-pinvoke! AUParameterValueToLinear is not bound -!missing-selector! AUAudioUnitV2Bridge::audioUnit not bound -!missing-enum! AUSpatialMixerPersonalizedHRTFMode not bound diff --git a/tests/xtro-sharpie/common-AudioToolbox.ignore b/tests/xtro-sharpie/common-AudioToolbox.ignore index a32d157be969..822ae6deccfa 100644 --- a/tests/xtro-sharpie/common-AudioToolbox.ignore +++ b/tests/xtro-sharpie/common-AudioToolbox.ignore @@ -52,6 +52,8 @@ !missing-selector! AUAudioUnit::scheduleMIDIEventBlock not bound !missing-selector! AUAudioUnit::setMusicalContextBlock: not bound !missing-selector! AUAudioUnit::tokenByAddingRenderObserver: not bound +!missing-selector! AUAudioUnit::messageChannelFor: not bound +!missing-selector! AUAudioUnitV2Bridge::audioUnit not bound !missing-type! AUAudioUnitV2Bridge not bound !missing-pinvoke! AudioCodecAppendInputBufferList is not bound !missing-pinvoke! AudioCodecAppendInputData is not bound @@ -77,3 +79,21 @@ !missing-selector! AUAudioUnit::AudioUnitMIDIProtocol not bound !missing-selector! AUAudioUnit::hostMIDIProtocol not bound !missing-selector! AUAudioUnit::setHostMIDIProtocol: not bound + +# ignored in the past on macOS now ignored in every platform. +!missing-pinvoke! AUListenerAddParameter is not bound +!missing-pinvoke! AUListenerCreate is not bound +!missing-pinvoke! AUListenerCreateWithDispatchQueue is not bound +!missing-pinvoke! AUListenerDispose is not bound +!missing-pinvoke! AUEventListenerAddEventType is not bound +!missing-pinvoke! AUEventListenerCreate is not bound +!missing-pinvoke! AUEventListenerCreateWithDispatchQueue is not bound +!missing-pinvoke! AUEventListenerNotify is not bound +!missing-pinvoke! AUEventListenerRemoveEventType is not bound +!missing-pinvoke! AUParameterFormatValue is not bound +!missing-pinvoke! AUParameterListenerNotify is not bound +!missing-pinvoke! AUParameterSet is not bound +!missing-pinvoke! AUParameterValueFromLinear is not bound +!missing-pinvoke! AUParameterValueToLinear is not bound + +!missing-protocol! AUMessageChannel not bound diff --git a/tests/xtro-sharpie/iOS-AudioToolbox.todo b/tests/xtro-sharpie/iOS-AudioToolbox.todo deleted file mode 100644 index de547e44b300..000000000000 --- a/tests/xtro-sharpie/iOS-AudioToolbox.todo +++ /dev/null @@ -1,23 +0,0 @@ -!missing-enum! AudioUnitEventType not bound -!missing-pinvoke! AudioComponentCopyConfigurationInfo is not bound -!missing-pinvoke! AudioComponentValidate is not bound -!missing-pinvoke! AudioComponentValidateWithResults is not bound -!missing-pinvoke! AUEventListenerAddEventType is not bound -!missing-pinvoke! AUEventListenerCreate is not bound -!missing-pinvoke! AUEventListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUEventListenerNotify is not bound -!missing-pinvoke! AUEventListenerRemoveEventType is not bound -!missing-pinvoke! AUListenerAddParameter is not bound -!missing-pinvoke! AUListenerCreate is not bound -!missing-pinvoke! AUListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUListenerDispose is not bound -!missing-pinvoke! AUListenerRemoveParameter is not bound -!missing-pinvoke! AUParameterFormatValue is not bound -!missing-pinvoke! AUParameterListenerNotify is not bound -!missing-pinvoke! AUParameterSet is not bound -!missing-pinvoke! AUParameterValueFromLinear is not bound -!missing-pinvoke! AUParameterValueToLinear is not bound -!missing-protocol! AUMessageChannel not bound -!missing-selector! AUAudioUnit::messageChannelFor: not bound -!missing-selector! AUAudioUnitV2Bridge::audioUnit not bound -!missing-enum! AUSpatialMixerPersonalizedHRTFMode not bound diff --git a/tests/xtro-sharpie/macOS-AudioToolbox.ignore b/tests/xtro-sharpie/macOS-AudioToolbox.ignore index 475feb408baa..cfd489962bb3 100644 --- a/tests/xtro-sharpie/macOS-AudioToolbox.ignore +++ b/tests/xtro-sharpie/macOS-AudioToolbox.ignore @@ -1,12 +1,9 @@ -!missing-enum! AudioUnitEventType not bound !missing-enum! AUParameterMIDIMappingFlags not bound !missing-enum! CAClockMessage not bound !missing-enum! CAClockPropertyID not bound !missing-enum! CAClockSyncMode not bound !missing-enum! CAClockTimebase not bound !missing-enum! CAClockTimeFormat not bound -!missing-pinvoke! AudioComponentCopyConfigurationInfo is not bound -!missing-pinvoke! AudioComponentValidate is not bound !missing-pinvoke! AudioFileComponentCloseFile is not bound !missing-pinvoke! AudioFileComponentCountUserData is not bound !missing-pinvoke! AudioFileComponentCreateURL is not bound @@ -30,21 +27,7 @@ !missing-pinvoke! AudioFileComponentSetUserData is not bound !missing-pinvoke! AudioFileComponentWriteBytes is not bound !missing-pinvoke! AudioFileComponentWritePackets is not bound -!missing-pinvoke! AUEventListenerAddEventType is not bound -!missing-pinvoke! AUEventListenerCreate is not bound -!missing-pinvoke! AUEventListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUEventListenerNotify is not bound -!missing-pinvoke! AUEventListenerRemoveEventType is not bound -!missing-pinvoke! AUListenerAddParameter is not bound -!missing-pinvoke! AUListenerCreate is not bound -!missing-pinvoke! AUListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUListenerDispose is not bound !missing-pinvoke! AUListenerRemoveParameter is not bound -!missing-pinvoke! AUParameterFormatValue is not bound -!missing-pinvoke! AUParameterListenerNotify is not bound -!missing-pinvoke! AUParameterSet is not bound -!missing-pinvoke! AUParameterValueFromLinear is not bound -!missing-pinvoke! AUParameterValueToLinear is not bound !missing-pinvoke! CAClockAddListener is not bound !missing-pinvoke! CAClockArm is not bound !missing-pinvoke! CAClockBarBeatTimeToBeats is not bound diff --git a/tests/xtro-sharpie/macOS-AudioToolbox.todo b/tests/xtro-sharpie/macOS-AudioToolbox.todo deleted file mode 100644 index 7b78f93d9761..000000000000 --- a/tests/xtro-sharpie/macOS-AudioToolbox.todo +++ /dev/null @@ -1,5 +0,0 @@ -!missing-protocol! AUMessageChannel not bound -!missing-selector! AUAudioUnit::messageChannelFor: not bound -!missing-selector! AUAudioUnitV2Bridge::audioUnit not bound -!missing-pinvoke! AudioComponentValidateWithResults is not bound -!missing-enum! AUSpatialMixerPersonalizedHRTFMode not bound diff --git a/tests/xtro-sharpie/tvOS-AudioToolbox.todo b/tests/xtro-sharpie/tvOS-AudioToolbox.todo deleted file mode 100644 index 5e73f8c56782..000000000000 --- a/tests/xtro-sharpie/tvOS-AudioToolbox.todo +++ /dev/null @@ -1,18 +0,0 @@ -!missing-enum! AudioUnitEventType not bound -!missing-pinvoke! AUEventListenerAddEventType is not bound -!missing-pinvoke! AUEventListenerCreate is not bound -!missing-pinvoke! AUEventListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUEventListenerNotify is not bound -!missing-pinvoke! AUEventListenerRemoveEventType is not bound -!missing-pinvoke! AUListenerAddParameter is not bound -!missing-pinvoke! AUListenerCreate is not bound -!missing-pinvoke! AUListenerCreateWithDispatchQueue is not bound -!missing-pinvoke! AUListenerDispose is not bound -!missing-pinvoke! AUListenerRemoveParameter is not bound -!missing-pinvoke! AUParameterFormatValue is not bound -!missing-pinvoke! AUParameterListenerNotify is not bound -!missing-pinvoke! AUParameterSet is not bound -!missing-pinvoke! AUParameterValueFromLinear is not bound -!missing-pinvoke! AUParameterValueToLinear is not bound -!missing-selector! AUAudioUnitV2Bridge::audioUnit not bound -!missing-enum! AUSpatialMixerPersonalizedHRTFMode not bound From f35420de065fa62a31cd4099b904aac0a7ad9e7f Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 7 Sep 2022 11:54:46 -0400 Subject: [PATCH 2/5] Address reviews. --- src/AudioUnit/AudioComponent.cs | 38 ++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/AudioUnit/AudioComponent.cs b/src/AudioUnit/AudioComponent.cs index 6c564cb873b0..0f2821164008 100644 --- a/src/AudioUnit/AudioComponent.cs +++ b/src/AudioUnit/AudioComponent.cs @@ -587,13 +587,27 @@ static extern int AudioComponentValidate (IntPtr /* AudioComponent* */ inCompone [iOS (16,0)] [MacCatalyst (16,0)] #endif - public AudioComponentValidationResult Validate (NSDictionary validationParameters) { - var success = AudioComponentValidate (GetCheckedHandle (), validationParameters.GetNonNullHandle (nameof (validationParameters)), out var result); - if (success == 0) + public AudioComponentValidationResult Validate (NSDictionary validationParameters, out int resultCode) { + resultCode = AudioComponentValidate (GetCheckedHandle (), validationParameters.GetHandle (), out var result); + if (resultCode == 0) return result; return AudioComponentValidationResult.Unknown; } +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] + [MacCatalyst (16,0)] +#endif + public AudioComponentValidationResult Validate (NSDictionary validationParameters) => Validate (validationParameters, out var _); + delegate void TrampolineCallback (IntPtr blockPtr, AudioComponentValidationResult result, IntPtr dictionary); static unsafe readonly TrampolineCallback static_action = TrampolineAction; @@ -632,19 +646,33 @@ static void TrampolineAction (IntPtr blockPtr, AudioComponentValidationResult re [iOS (16,0)] #endif public void ValidateAsync (NSDictionary validationParameters, - Action onCompletion) { + Action onCompletion, out int resultCode) { if (onCompletion is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (onCompletion)); var block_handler= new BlockLiteral (); block_handler.SetupBlockUnsafe (static_action, onCompletion); try { - AudioComponentValidateWithResults (GetCheckedHandle (), validationParameters.GetNonNullHandle (nameof (validationParameters)), ref block_handler); + resultCode = AudioComponentValidateWithResults (GetCheckedHandle (), validationParameters.GetHandle (), ref block_handler); } finally { block_handler.CleanupBlock (); } } +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] +#endif + public void ValidateAsync (NSDictionary validationParameters, + Action onCompletion) => ValidateAsync (validationParameters, onCompletion, out var _); + #if NET [SupportedOSPlatform ("macos10.13")] [SupportedOSPlatform ("ios11.0")] From c9ff13fbb7e6747e1f4df74ccf9207ccf324baab Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Thu, 8 Sep 2022 13:04:37 -0400 Subject: [PATCH 3/5] Add tests for manual code. --- src/AudioUnit/AudioComponent.cs | 46 +++++++++--- .../AudioToolbox/AudioComponentTest.cs | 74 +++++++++++++++++++ 2 files changed, 109 insertions(+), 11 deletions(-) diff --git a/src/AudioUnit/AudioComponent.cs b/src/AudioUnit/AudioComponent.cs index 0f2821164008..698a63aa41d9 100644 --- a/src/AudioUnit/AudioComponent.cs +++ b/src/AudioUnit/AudioComponent.cs @@ -549,16 +549,27 @@ public double LastActiveTime { [Mac (13,0)] [iOS (16,0)] #endif - public NSDictionary? ConfigurationInfo { - get { - var success = AudioComponentCopyConfigurationInfo (GetCheckedHandle (), out var dictPtr); - if (success == 0) { - return Runtime.GetNSObject (dictPtr, owns: true); - } - return null; + public NSDictionary? GetConfigurationInfo (out int resultCode) { + resultCode = AudioComponentCopyConfigurationInfo (GetCheckedHandle (), out var dictPtr); + if (resultCode == 0) { + return Runtime.GetNSObject (dictPtr, owns: true); } + return null; } +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] +#endif + public NSDictionary? GetConfigurationInfo () => GetConfigurationInfo (out var _); + #if NET [SupportedOSPlatform ("macos13.0")] [SupportedOSPlatform ("ios16.0")] @@ -587,7 +598,7 @@ static extern int AudioComponentValidate (IntPtr /* AudioComponent* */ inCompone [iOS (16,0)] [MacCatalyst (16,0)] #endif - public AudioComponentValidationResult Validate (NSDictionary validationParameters, out int resultCode) { + public AudioComponentValidationResult Validate (NSDictionary? validationParameters, out int resultCode) { resultCode = AudioComponentValidate (GetCheckedHandle (), validationParameters.GetHandle (), out var result); if (resultCode == 0) return result; @@ -606,7 +617,7 @@ public AudioComponentValidationResult Validate (NSDictionary validationParameter [iOS (16,0)] [MacCatalyst (16,0)] #endif - public AudioComponentValidationResult Validate (NSDictionary validationParameters) => Validate (validationParameters, out var _); + public AudioComponentValidationResult Validate (NSDictionary? validationParameters = null) => Validate (validationParameters, out var _); delegate void TrampolineCallback (IntPtr blockPtr, AudioComponentValidationResult result, IntPtr dictionary); @@ -645,7 +656,7 @@ static void TrampolineAction (IntPtr blockPtr, AudioComponentValidationResult re [Mac (13,0)] [iOS (16,0)] #endif - public void ValidateAsync (NSDictionary validationParameters, + public void ValidateAsync (NSDictionary? validationParameters, Action onCompletion, out int resultCode) { if (onCompletion is null) ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (onCompletion)); @@ -670,9 +681,22 @@ public void ValidateAsync (NSDictionary validationParameters, [Mac (13,0)] [iOS (16,0)] #endif - public void ValidateAsync (NSDictionary validationParameters, + public void ValidateAsync (NSDictionary? validationParameters, Action onCompletion) => ValidateAsync (validationParameters, onCompletion, out var _); +#if NET + [SupportedOSPlatform ("macos13.0")] + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [UnsupportedOSPlatform ("tvos")] +#else + [NoWatch] + [NoTV] + [Mac (13,0)] + [iOS (16,0)] +#endif + public void ValidateAsync (Action onCompletion) => ValidateAsync (null, onCompletion, out var _); + #if NET [SupportedOSPlatform ("macos10.13")] [SupportedOSPlatform ("ios11.0")] diff --git a/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs b/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs index 4df2c51263e2..c4d41b633e6e 100644 --- a/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs +++ b/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs @@ -5,6 +5,7 @@ using System.Drawing; using System.IO; using System.Collections.Generic; +using System.Threading; using Foundation; using AudioToolbox; using AudioUnit; @@ -117,6 +118,79 @@ public void TestResourceUsageInfoMachLookUpGlobalName () resources.MachLookUpGlobalName = null; Assert.IsNull (resources.MachLookUpGlobalName, "Value was no set to null."); } + + [Test] + public void TestConfigurationInfo () + { + TestRuntime.AssertXcodeVersion (14, 0); + var resources = new ResourceUsageInfo (); + resources.IOKitUserClient = new string[] { "CustomUserClient1" }; + resources.MachLookUpGlobalName = new string[] { "MachServiceName1" }; + resources.NetworkClient = false; + resources.TemporaryExceptionReadWrite = false; + + var componentInfo = new AudioComponentInfo (); + componentInfo.Type = AudioTypeOutput.Generic.ToString (); + componentInfo.Subtype = "XMPL"; + componentInfo.Name = "XMPL"; + componentInfo.Version = 1; + componentInfo.ResourceUsage = resources; + using var component = AudioComponent.FindComponent (AudioTypeOutput.Generic); + Assert.IsNotNull (component); + // assert the property and break + var configInfo = component.GetConfigurationInfo (); + Assert.IsNotNull (configInfo); + } + + [Test] + public void TestValidation () + { + TestRuntime.AssertXcodeVersion (14, 0); + var resources = new ResourceUsageInfo (); + resources.IOKitUserClient = new string[] { "CustomUserClient1" }; + resources.MachLookUpGlobalName = new string[] { "MachServiceName1" }; + resources.NetworkClient = false; + resources.TemporaryExceptionReadWrite = false; + + var componentInfo = new AudioComponentInfo (); + componentInfo.Type = AudioTypeOutput.Generic.ToString (); + componentInfo.Subtype = "XMPL"; + componentInfo.Name = "XMPL"; + componentInfo.Version = 1; + componentInfo.ResourceUsage = resources; + using var component = AudioComponent.FindComponent (AudioTypeOutput.Generic); + Assert.IsNotNull (component); + // validate and break + var validation = component.Validate(null); + Assert.AreEqual (AudioComponentValidationResult.Unknown, validation); + } + + [Test] + public void TestValidationAsync () + { + TestRuntime.AssertXcodeVersion (14, 0); + var resources = new ResourceUsageInfo (); + resources.IOKitUserClient = new string[] { "CustomUserClient1" }; + resources.MachLookUpGlobalName = new string[] { "MachServiceName1" }; + resources.NetworkClient = false; + resources.TemporaryExceptionReadWrite = false; + + var componentInfo = new AudioComponentInfo (); + componentInfo.Type = AudioTypeOutput.Generic.ToString (); + componentInfo.Subtype = "XMPL"; + componentInfo.Name = "XMPL"; + componentInfo.Version = 1; + componentInfo.ResourceUsage = resources; + using var component = AudioComponent.FindComponent (AudioTypeOutput.Generic); + Assert.IsNotNull (component); + + var cbEvent = new AutoResetEvent(false); + Action cb = (AudioComponentValidationResult _, NSDictionary? _) => { + cbEvent.Set (); + }; + component.ValidateAsync(cb); + Assert.True (cbEvent.WaitOne (20000), "Cb was not called."); + } } } From d38d6e46d4bc868cc769f607c101e5529ad2a387 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Fri, 9 Sep 2022 13:51:54 -0400 Subject: [PATCH 4/5] Fix flacky test. --- tests/monotouch-test/AudioToolbox/AudioComponentTest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs b/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs index c4d41b633e6e..ee331a408ca9 100644 --- a/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs +++ b/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs @@ -162,7 +162,8 @@ public void TestValidation () Assert.IsNotNull (component); // validate and break var validation = component.Validate(null); - Assert.AreEqual (AudioComponentValidationResult.Unknown, validation); + Assert.Contains (validation, + new List () {AudioComponentValidationResult.Unknown, AudioComponentValidationResult.Passed}, "validation"); } [Test] From 501c2e1b47d297a57ce7102e139ae2171068242a Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Fri, 9 Sep 2022 18:33:21 -0400 Subject: [PATCH 5/5] Fix issue with block. --- src/AudioUnit/AudioComponent.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AudioUnit/AudioComponent.cs b/src/AudioUnit/AudioComponent.cs index 698a63aa41d9..be76dc9da503 100644 --- a/src/AudioUnit/AudioComponent.cs +++ b/src/AudioUnit/AudioComponent.cs @@ -656,6 +656,7 @@ static void TrampolineAction (IntPtr blockPtr, AudioComponentValidationResult re [Mac (13,0)] [iOS (16,0)] #endif + [BindingImpl (BindingImplOptions.Optimizable)] public void ValidateAsync (NSDictionary? validationParameters, Action onCompletion, out int resultCode) { if (onCompletion is null)