-
Notifications
You must be signed in to change notification settings - Fork 565
[AudioToolbox] Update bindings to Xcode 9 beta2. #2294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
65b8ca7
0e21b1b
a7b19ba
0c5249d
746bdb4
bda6a10
fe14509
0f0a8a6
d53867d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,8 @@ public enum AudioFileType { // UInt32 AudioFileTypeID | |
| AIFF = 0x41494646, // AIFF | ||
| AIFC = 0x41494643, // AIFC | ||
| WAVE = 0x57415645, // WAVE | ||
| [NoWatch, iOS (11,0), Mac(10,13), TV (11,0)] | ||
| RF64 = 0x52463634, // RF64 | ||
| SoundDesigner2 = 0x53643266, // Sd2f | ||
| Next = 0x4e655854, // NeXT | ||
| MP3 = 0x4d504733, // MPG3 | ||
|
|
@@ -60,6 +62,8 @@ public enum AudioFileType { // UInt32 AudioFileTypeID | |
| ThreeGP = 0x33677070, // 3gpp | ||
| ThreeGP2 = 0x33677032, // 3gp2 | ||
| AMR = 0x616d7266, // amrf | ||
| [NoWatch, iOS (11,0), Mac(10,13), TV (11,0)] | ||
| FLAC = 0x666c6163, // flac | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If new (and not missing) then it should have availability attributes It should be |
||
| } | ||
|
|
||
| public enum AudioFileError {// Implictly cast to OSType in AudioFile.h | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,177 @@ | |
|
|
||
| namespace XamCore.AudioUnit | ||
| { | ||
|
|
||
| #if !COREBUILD | ||
| // keys are not constants and had to be found in AudioToolbox.framework/Headers/AudioComponent.h | ||
| [NoWatch, NoTV, Mac (10,13), iOS (11,0)] | ||
| public partial class ResourceUsageInfo : DictionaryContainer { | ||
| static NSString userClientK = new NSString ("iokit.user-client"); | ||
| static NSString globalNameK = new NSString ("mach-lookup.global-name"); | ||
| static NSString networkClientK = new NSString ("network.client"); | ||
| static NSString exceptionK = new NSString ("temporary-exception.files.all.read-write"); | ||
|
|
||
| public ResourceUsageInfo () : base () {} | ||
|
|
||
| public ResourceUsageInfo (NSDictionary dic) : base (dic) {} | ||
|
|
||
| public string[] IOKitUserClient { | ||
| get { | ||
| var array = GetNativeValue<NSArray> (userClientK); | ||
| if (array == null ) | ||
| return null; | ||
| return NSArray.StringArrayFromHandle (array.Handle); | ||
| } | ||
| set { | ||
| if (value == null) | ||
| RemoveValue (userClientK); | ||
| else | ||
| SetArrayValue (userClientK, value); | ||
| } | ||
| } | ||
|
|
||
| public string[] MachLookUpGlobalName { | ||
| get { | ||
| var array = GetNativeValue<NSArray> (globalNameK); | ||
| if (array == null) | ||
| return null; | ||
| return NSArray.StringArrayFromHandle (array.Handle); | ||
| } | ||
| set { | ||
| if (value == null) | ||
| RemoveValue (globalNameK); | ||
| else | ||
| SetArrayValue (globalNameK, value); | ||
| } | ||
| } | ||
|
|
||
| public bool? NetworkClient { | ||
| get { | ||
| return GetBoolValue (networkClientK); | ||
| } | ||
| set { | ||
| SetBooleanValue (networkClientK, value); | ||
| } | ||
| } | ||
|
|
||
| public bool? TemporaryExceptionReadWrite { | ||
| get { | ||
| return GetBoolValue (exceptionK); | ||
| } | ||
| set { | ||
| SetBooleanValue (exceptionK, value); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // keys are not constants and had to be found in AudioToolbox.framework/Headers/AudioComponent.h | ||
| [NoWatch, NoTV, Mac (10,13), iOS (11,0)] | ||
| public partial class AudioComponentInfo : DictionaryContainer { | ||
| static NSString typeK = new NSString ("type"); | ||
| static NSString subtypeK = new NSString ("subtype"); | ||
| static NSString manufacturerK = new NSString ("manufacturer"); | ||
| static NSString nameK = new NSString ("name"); | ||
| static NSString versionK = new NSString ("version"); | ||
| static NSString factoryFunctionK = new NSString ("factoryFunction"); | ||
| static NSString sandboxSafeK = new NSString ("sandboxSafe"); | ||
| static NSString resourceUsageK = new NSString ("resourceUsage"); | ||
| static NSString tagsK = new NSString ("tags"); | ||
|
|
||
| public AudioComponentInfo () : base () {} | ||
|
|
||
| public AudioComponentInfo (NSDictionary dic) : base (dic) {} | ||
|
|
||
| public string Type { | ||
| get { | ||
| return GetStringValue (typeK); | ||
| } | ||
| set { | ||
| SetStringValue (typeK, value); | ||
| } | ||
| } | ||
|
|
||
| public string Subtype { | ||
| get { | ||
| return GetStringValue (subtypeK); | ||
| } | ||
| set { | ||
| SetStringValue (subtypeK, value); | ||
| } | ||
| } | ||
|
|
||
| public string Manufacturer { | ||
| get { | ||
| return GetStringValue (manufacturerK); | ||
| } | ||
| set { | ||
| SetStringValue (manufacturerK, value); | ||
| } | ||
| } | ||
|
|
||
| public string Name { | ||
| get { | ||
| return GetStringValue (nameK); | ||
| } | ||
| set { | ||
| SetStringValue (nameK, value); | ||
| } | ||
| } | ||
|
|
||
| public nuint? Version { | ||
| get { | ||
| return GetNUIntValue (versionK); | ||
| } | ||
| set { | ||
| SetNumberValue (versionK, value); | ||
| } | ||
| } | ||
|
|
||
| public string FactoryFunction { | ||
| get { | ||
| return GetStringValue (factoryFunctionK); | ||
| } | ||
| set { | ||
| SetStringValue (factoryFunctionK, value); | ||
| } | ||
| } | ||
|
|
||
| public bool? SandboxSafe { | ||
| get { | ||
| return GetBoolValue (sandboxSafeK); | ||
| } | ||
| set { | ||
| SetBooleanValue (sandboxSafeK, value); | ||
| } | ||
| } | ||
|
|
||
| public ResourceUsageInfo ResourceUsage { | ||
| get { | ||
| return GetStrongDictionary<ResourceUsageInfo> (resourceUsageK); | ||
| } | ||
| set { | ||
| SetNativeValue (resourceUsageK, value?.Dictionary, true); | ||
| } | ||
| } | ||
|
|
||
| public string[] Tags { | ||
| get { | ||
| var array = GetNativeValue<NSArray> (tagsK); | ||
| if (array == null) | ||
| return null; | ||
| return NSArray.StringArrayFromHandle (array.Handle); | ||
| } | ||
| set { | ||
| if (value == null) | ||
| RemoveValue (tagsK); | ||
| else | ||
| SetArrayValue (tagsK, value); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
|
|
||
|
|
||
| public class AudioComponent : INativeObject { | ||
| #if !COREBUILD | ||
| internal IntPtr handle; | ||
|
|
@@ -224,6 +395,54 @@ public XamCore.AppKit.NSImage GetIcon () | |
| return new XamCore.AppKit.NSImage (AudioComponentGetIcon (handle)); | ||
| } | ||
| #endif | ||
| [NoWatch, NoTV, Mac (10,13), iOS (11,0)] | ||
| [DllImport (Constants.AudioUnitLibrary)] | ||
| static extern int /* OSStatus */ AudioUnitExtensionSetComponentList (IntPtr /* CFString */ extensionIdentifier, /* CFArrayRef */ IntPtr audioComponentInfo); | ||
|
|
||
| [NoWatch, NoTV, Mac (10,13), iOS (11,0)] | ||
| [DllImport (Constants.AudioUnitLibrary)] | ||
| static extern /* CFArrayRef */ IntPtr AudioUnitExtensionCopyComponentList (IntPtr /* CFString */ extensionIdentifier); | ||
|
|
||
| [NoWatch, NoTV, Mac (10,13), iOS (11,0)] | ||
| public AudioComponentInfo[] ComponentList { | ||
| get { | ||
| using (var cfString = new CFString (Name)) { | ||
| var cHandle = AudioUnitExtensionCopyComponentList (cfString.Handle); | ||
| if (cHandle == IntPtr.Zero) | ||
| return null; | ||
| using (var nsArray = Runtime.GetNSObject<NSArray> (cHandle, owns: true)) { | ||
| if (nsArray == null) | ||
| return null; | ||
| // make things easier for developers since we do not know how to have an implicit conversion from NSObject to AudioComponentInfo | ||
| var dics = NSArray.FromArray <NSDictionary> (nsArray); | ||
| var result = new AudioComponentInfo [dics.Length]; | ||
| for (var i = 0; i < result.Length; i++) { | ||
| result [i] = new AudioComponentInfo (dics[i]); | ||
| } | ||
| return result; | ||
| } | ||
| } | ||
| } | ||
| set { | ||
| using (var cfString = new CFString (Name)) { | ||
| var dics = new NSDictionary [value.Length]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also add a unit test for |
||
| for (var i = 0; i < value.Length; i++) { | ||
| dics [i] = value [i].Dictionary; | ||
| } | ||
| using (var array = NSArray.FromNSObjects (dics)) { | ||
| var result = (AudioConverterError) AudioUnitExtensionSetComponentList (cfString.Handle, array.Handle); | ||
| switch (result) { | ||
| case AudioConverterError.None: | ||
| return; | ||
| default: | ||
| throw new InvalidOperationException ($"ComponentList could not be set, error {result.ToString ()}"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure there's much value in all the similar (but different) strings, they just end up taking 2xspace in the metadata (unicode).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, we can remove that , it is the main two errors we will get, but lets do that and the string should be helpfull enough when searching the web. |
||
|
|
||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif // !COREBUILD | ||
| } | ||
|
|
||
|
|
@@ -241,4 +460,4 @@ public static class AudioComponentConfigurationInfo { | |
| public static NSString ValidationResult = new NSString ("ValidationResult"); | ||
| } | ||
| #endif | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If new (and not missing) then it should have availability attributes