diff --git a/src/AudioUnit/AudioComponent.cs b/src/AudioUnit/AudioComponent.cs index 3953d31a13c0..82fe5e511565 100644 --- a/src/AudioUnit/AudioComponent.cs +++ b/src/AudioUnit/AudioComponent.cs @@ -55,20 +55,30 @@ public ResourceUsageInfo (NSDictionary dic) : base (dic) {} public string[] IOKitUserClient { get { var array = GetNativeValue (userClientK); - return NSArray.StringArrayFromHandle (array.ClassHandle); + if (array == null ) + return null; + return NSArray.StringArrayFromHandle (array.Handle); } set { - SetArrayValue (userClientK, value); + if (value == null) + SetArrayValue (userClientK, value); + else + RemoveValue (userClientK); } } public string[] MachLookUpGlobalName { get { var array = GetNativeValue (globalNameK); - return NSArray.StringArrayFromHandle (array.ClassHandle); + if (array == null) + return null; + return NSArray.StringArrayFromHandle (array.Handle); } set { - SetArrayValue (globalNameK, value); + if (value == null) + SetArrayValue (globalNameK, value); + else + RemoveValue (globalNameK); } } @@ -176,17 +186,22 @@ public ResourceUsageInfo ResourceUsage { return GetStrongDictionary (resourceUsageK); } set { - SetNativeValue (resourceUsageK, value.Dictionary, true); + SetNativeValue (resourceUsageK, value?.Dictionary, true); } } public string[] Tags { get { var array = GetNativeValue (tagsK); - return NSArray.StringArrayFromHandle (array.ClassHandle); + if (array == null) + return null; + return NSArray.StringArrayFromHandle (array.Handle); } set { - SetArrayValue (tagsK, value); + if (value == null) + RemoveValue (tagsK); + else + SetArrayValue (tagsK, value); } } } diff --git a/src/AudioUnit/AudioUnit.cs b/src/AudioUnit/AudioUnit.cs index 6f535924e5a5..3063bc829c16 100644 --- a/src/AudioUnit/AudioUnit.cs +++ b/src/AudioUnit/AudioUnit.cs @@ -389,7 +389,7 @@ public struct RampStruct [StructLayout (LayoutKind.Sequential)] public struct ImmediateStruct { - public uint bBufferOffset; + public uint BufferOffset; public float Value; } diff --git a/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs b/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs index 25232d729606..62af2ec63ca5 100644 --- a/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs +++ b/tests/monotouch-test/AudioToolbox/AudioComponentTest.cs @@ -52,6 +52,43 @@ public void GetSetComponentList () Assert.Throws (() => component.ComponentList = l); } } + + // test the diff properties of the ResourceUsageInfo since it was manually done + + [Test] + public void TestResourceUsageInfoIOKitUserClient () + { + TestRuntime.AssertXcodeVersion (9, 0); + var clientId = "CustomUserClient1"; + var resources = new ResourceUsageInfo (); + resources.IOKitUserClient = new string[] { clientId }; + var userClientList = resources.IOKitUserClient; + Assert.AreEqual (1, userClientList.Length, "List does not have all client ids."); + Assert.AreEqual (clientId, userClientList [0], "Client ids are not the same."); + + // similar test but with null values. + + resources.IOKitUserClient = null; + Assert.IsNull (resources.IOKitUserClient, "Value was not set to null."); + } + + [Test] + public void TestResourceUsageInfoMachLookUpGlobalName () + { + TestRuntime.AssertXcodeVersion (9, 0); + var serviceName = "MachServiceName1"; + var resources = new ResourceUsageInfo (); + resources.MachLookUpGlobalName = new string[] { serviceName }; + var serviceNames = resources.MachLookUpGlobalName; + + Assert.AreEqual (1, serviceNames.Length, "List does not have all service names."); + Assert.AreEqual (serviceName, serviceNames [0], "Service names are not equal."); + + // similar test but with null values + + resources.MachLookUpGlobalName = null; + Assert.IsNull (resources.MachLookUpGlobalName, "Value was no set to null."); + } } }