[AudioUnit] Make P/Invokes in AudioComponent.cs have blittable signatures. (#20146)
Contributes towards #15684.
This commit is contained in:
Родитель
a164c1fb18
Коммит
78ae4b0686
|
@ -32,6 +32,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ObjCRuntime;
|
||||
using AudioToolbox;
|
||||
|
@ -261,7 +262,9 @@ namespace AudioUnit {
|
|||
public static AudioComponent? FindNextComponent (AudioComponent? cmp, ref AudioComponentDescription cd)
|
||||
{
|
||||
var handle = cmp.GetHandle ();
|
||||
handle = AudioComponentFindNext (handle, ref cd);
|
||||
unsafe {
|
||||
handle = AudioComponentFindNext (handle, (AudioComponentDescription*) Unsafe.AsPointer<AudioComponentDescription> (ref cd));
|
||||
}
|
||||
return (handle != IntPtr.Zero) ? new AudioComponent (handle, false) : null;
|
||||
}
|
||||
|
||||
|
@ -313,38 +316,47 @@ namespace AudioUnit {
|
|||
}
|
||||
|
||||
[DllImport (Constants.AudioUnitLibrary)]
|
||||
static extern IntPtr AudioComponentFindNext (IntPtr inComponent, ref AudioComponentDescription inDesc);
|
||||
unsafe static extern IntPtr AudioComponentFindNext (IntPtr inComponent, AudioComponentDescription* inDesc);
|
||||
|
||||
[DllImport (Constants.AudioUnitLibrary, EntryPoint = "AudioComponentCopyName")]
|
||||
static extern int /* OSStatus */ AudioComponentCopyName (IntPtr component, out IntPtr cfstr);
|
||||
unsafe static extern int /* OSStatus */ AudioComponentCopyName (IntPtr component, IntPtr* cfstr);
|
||||
|
||||
public string? Name {
|
||||
get {
|
||||
if (AudioComponentCopyName (Handle, out var r) == 0)
|
||||
return CFString.FromHandle (r);
|
||||
IntPtr r;
|
||||
unsafe {
|
||||
if (AudioComponentCopyName (Handle, &r) == 0)
|
||||
return CFString.FromHandle (r);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Constants.AudioUnitLibrary)]
|
||||
static extern int /* OSStatus */ AudioComponentGetDescription (IntPtr component, out AudioComponentDescription desc);
|
||||
unsafe static extern int /* OSStatus */ AudioComponentGetDescription (IntPtr component, AudioComponentDescription* desc);
|
||||
|
||||
public AudioComponentDescription? Description {
|
||||
get {
|
||||
if (AudioComponentGetDescription (Handle, out var desc) == 0)
|
||||
return desc;
|
||||
AudioComponentDescription desc;
|
||||
unsafe {
|
||||
if (AudioComponentGetDescription (Handle, &desc) == 0)
|
||||
return desc;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Constants.AudioUnitLibrary)]
|
||||
static extern int /* OSStatus */ AudioComponentGetVersion (IntPtr component, out int /* UInt32* */ version);
|
||||
unsafe static extern int /* OSStatus */ AudioComponentGetVersion (IntPtr component, int* /* UInt32* */ version);
|
||||
|
||||
public Version? Version {
|
||||
get {
|
||||
if (AudioComponentGetVersion (Handle, out var ret) == 0)
|
||||
return new Version (ret >> 16, (ret >> 8) & 0xff, ret & 0xff);
|
||||
int ret;
|
||||
unsafe {
|
||||
if (AudioComponentGetVersion (Handle, &ret) == 0)
|
||||
return new Version (ret >> 16, (ret >> 8) & 0xff, ret & 0xff);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -495,7 +507,7 @@ namespace AudioUnit {
|
|||
[iOS (16,0)]
|
||||
#endif
|
||||
[DllImport (Constants.AudioUnitLibrary)]
|
||||
static extern int AudioComponentCopyConfigurationInfo (IntPtr /* AudioComponent */ inComponent, out /* CFDictionaryRef** */ IntPtr outConfigurationInfo);
|
||||
unsafe static extern int AudioComponentCopyConfigurationInfo (IntPtr /* AudioComponent */ inComponent, /* CFDictionaryRef** */ IntPtr* outConfigurationInfo);
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos13.0")]
|
||||
|
@ -509,7 +521,10 @@ namespace AudioUnit {
|
|||
[iOS (16,0)]
|
||||
#endif
|
||||
public NSDictionary? GetConfigurationInfo (out int resultCode) {
|
||||
resultCode = AudioComponentCopyConfigurationInfo (GetCheckedHandle (), out var dictPtr);
|
||||
IntPtr dictPtr;
|
||||
unsafe {
|
||||
resultCode = AudioComponentCopyConfigurationInfo (GetCheckedHandle (), &dictPtr);
|
||||
}
|
||||
if (resultCode == 0) {
|
||||
return Runtime.GetNSObject<NSDictionary> (dictPtr, owns: true);
|
||||
}
|
||||
|
@ -542,8 +557,8 @@ namespace AudioUnit {
|
|||
[MacCatalyst (16,0)]
|
||||
#endif
|
||||
[DllImport (Constants.AudioUnitLibrary)]
|
||||
static extern int AudioComponentValidate (IntPtr /* AudioComponent* */ inComponent, IntPtr /* CFDictionaryRef* */ inValidationParameters,
|
||||
out AudioComponentValidationResult outValidationResult);
|
||||
unsafe static extern int AudioComponentValidate (IntPtr /* AudioComponent* */ inComponent, IntPtr /* CFDictionaryRef* */ inValidationParameters,
|
||||
AudioComponentValidationResult* outValidationResult);
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos13.0")]
|
||||
|
@ -558,7 +573,10 @@ namespace AudioUnit {
|
|||
[MacCatalyst (16,0)]
|
||||
#endif
|
||||
public AudioComponentValidationResult Validate (NSDictionary? validationParameters, out int resultCode) {
|
||||
resultCode = AudioComponentValidate (GetCheckedHandle (), validationParameters.GetHandle (), out var result);
|
||||
AudioComponentValidationResult result;
|
||||
unsafe {
|
||||
resultCode = AudioComponentValidate (GetCheckedHandle (), validationParameters.GetHandle (), &result);
|
||||
}
|
||||
if (resultCode == 0)
|
||||
return result;
|
||||
return AudioComponentValidationResult.Unknown;
|
||||
|
|
|
@ -369,11 +369,6 @@ namespace Cecil.Tests {
|
|||
"System.Boolean SystemConfiguration.NetworkReachability::SCNetworkReachabilitySetDispatchQueue(System.IntPtr,System.IntPtr)",
|
||||
"System.Byte Security.SecProtocolMetadata::sec_protocol_metadata_access_supported_signature_algorithms(System.IntPtr,ObjCRuntime.BlockLiteral*)",
|
||||
"System.Byte* Network.NWEndpoint::nw_endpoint_get_signature(System.IntPtr,System.UIntPtr&)",
|
||||
"System.Int32 AudioUnit.AudioComponent::AudioComponentCopyConfigurationInfo(System.IntPtr,System.IntPtr&)",
|
||||
"System.Int32 AudioUnit.AudioComponent::AudioComponentCopyName(System.IntPtr,System.IntPtr&)",
|
||||
"System.Int32 AudioUnit.AudioComponent::AudioComponentGetDescription(System.IntPtr,AudioUnit.AudioComponentDescription&)",
|
||||
"System.Int32 AudioUnit.AudioComponent::AudioComponentGetVersion(System.IntPtr,System.Int32&)",
|
||||
"System.Int32 AudioUnit.AudioComponent::AudioComponentValidate(System.IntPtr,System.IntPtr,AudioUnit.AudioComponentValidationResult&)",
|
||||
"System.Int32 AudioUnit.AudioUnit::AudioObjectGetPropertyData(System.UInt32,AudioUnit.AudioObjectPropertyAddress&,System.UInt32&,System.IntPtr&,System.UInt32&,System.UInt32&)",
|
||||
"System.Int32 AudioUnit.AudioUnit::AudioUnitGetProperty(System.IntPtr,AudioUnit.AudioUnitPropertyIDType,AudioUnit.AudioUnitScopeType,System.UInt32,System.UInt32&,System.UInt32&)",
|
||||
"System.Int32 AudioUnit.AudioUnit::AudioUnitSetProperty(System.IntPtr,AudioUnit.AudioUnitPropertyIDType,AudioUnit.AudioUnitScopeType,System.UInt32,AudioToolbox.AudioStreamBasicDescription&,System.UInt32)",
|
||||
|
@ -394,7 +389,6 @@ namespace Cecil.Tests {
|
|||
"System.Int32 Security.SslContext::SSLCopyALPNProtocols(System.IntPtr,System.IntPtr&)",
|
||||
"System.Int32 Security.SslContext::SSLSetSessionTicketsEnabled(System.IntPtr,System.Boolean)",
|
||||
"System.Int32 SystemConfiguration.NetworkReachability::SCNetworkReachabilityGetFlags(System.IntPtr,SystemConfiguration.NetworkReachabilityFlags&)",
|
||||
"System.IntPtr AudioUnit.AudioComponent::AudioComponentFindNext(System.IntPtr,AudioUnit.AudioComponentDescription&)",
|
||||
"System.IntPtr CoreGraphics.CGEvent::CGEventCreateKeyboardEvent(System.IntPtr,System.UInt16,System.Boolean)",
|
||||
"System.IntPtr CoreGraphics.CGFunction::CGFunctionCreate(System.IntPtr,System.IntPtr,System.Runtime.InteropServices.NFloat*,System.IntPtr,System.Runtime.InteropServices.NFloat*,CoreGraphics.CGFunction/CGFunctionCallbacks&)",
|
||||
"System.IntPtr CoreGraphics.CGImage::CGImageCreate(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,CoreGraphics.CGBitmapFlags,System.IntPtr,System.Runtime.InteropServices.NFloat*,System.Boolean,CoreGraphics.CGColorRenderingIntent)",
|
||||
|
|
Загрузка…
Ссылка в новой задаче