Skip to content

Commit fe14509

Browse files
Make changes as per reviews.
1 parent bda6a10 commit fe14509

3 files changed

Lines changed: 61 additions & 8 deletions

File tree

src/AudioUnit/AudioComponent.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,30 @@ public ResourceUsageInfo (NSDictionary dic) : base (dic) {}
5555
public string[] IOKitUserClient {
5656
get {
5757
var array = GetNativeValue<NSArray> (userClientK);
58-
return NSArray.StringArrayFromHandle (array.ClassHandle);
58+
if (array == null )
59+
return null;
60+
return NSArray.StringArrayFromHandle (array.Handle);
5961
}
6062
set {
61-
SetArrayValue (userClientK, value);
63+
if (value == null)
64+
RemoveValue (userClientK);
65+
else
66+
SetArrayValue (userClientK, value);
6267
}
6368
}
6469

6570
public string[] MachLookUpGlobalName {
6671
get {
6772
var array = GetNativeValue<NSArray> (globalNameK);
68-
return NSArray.StringArrayFromHandle (array.ClassHandle);
73+
if (array == null)
74+
return null;
75+
return NSArray.StringArrayFromHandle (array.Handle);
6976
}
7077
set {
71-
SetArrayValue (globalNameK, value);
78+
if (value == null)
79+
RemoveValue (globalNameK);
80+
else
81+
SetArrayValue (globalNameK, value);
7282
}
7383
}
7484

@@ -176,17 +186,22 @@ public ResourceUsageInfo ResourceUsage {
176186
return GetStrongDictionary<ResourceUsageInfo> (resourceUsageK);
177187
}
178188
set {
179-
SetNativeValue (resourceUsageK, value.Dictionary, true);
189+
SetNativeValue (resourceUsageK, value?.Dictionary, true);
180190
}
181191
}
182192

183193
public string[] Tags {
184194
get {
185195
var array = GetNativeValue<NSArray> (tagsK);
186-
return NSArray.StringArrayFromHandle (array.ClassHandle);
196+
if (array == null)
197+
return null;
198+
return NSArray.StringArrayFromHandle (array.Handle);
187199
}
188200
set {
189-
SetArrayValue (tagsK, value);
201+
if (value == null)
202+
RemoveValue (tagsK);
203+
else
204+
SetArrayValue (tagsK, value);
190205
}
191206
}
192207
}

src/AudioUnit/AudioUnit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public struct RampStruct
389389
[StructLayout (LayoutKind.Sequential)]
390390
public struct ImmediateStruct
391391
{
392-
public uint bBufferOffset;
392+
public uint BufferOffset;
393393
public float Value;
394394
}
395395

tests/monotouch-test/AudioToolbox/AudioComponentTest.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,44 @@ public void GetSetComponentList ()
5252
Assert.Throws <InvalidOperationException> (() => component.ComponentList = l);
5353
}
5454
}
55+
56+
// test the diff properties of the ResourceUsageInfo since it was manually done
57+
58+
[Test]
59+
public void TestResourceUsageInfoIOKitUserClient ()
60+
{
61+
TestRuntime.AssertXcodeVersion (9, 0);
62+
var clientId = "CustomUserClient1";
63+
var resources = new ResourceUsageInfo ();
64+
resources.IOKitUserClient = new string[] { clientId };
65+
var userClientList = resources.IOKitUserClient;
66+
Assert.IsNotNull (userClientList);
67+
Assert.AreEqual (1, userClientList.Length, "List does not have all client ids.");
68+
Assert.AreEqual (clientId, userClientList [0], "Client ids are not the same.");
69+
70+
// similar test but with null values.
71+
72+
resources.IOKitUserClient = null;
73+
Assert.IsNull (resources.IOKitUserClient, "Value was not set to null.");
74+
}
75+
76+
[Test]
77+
public void TestResourceUsageInfoMachLookUpGlobalName ()
78+
{
79+
TestRuntime.AssertXcodeVersion (9, 0);
80+
var serviceName = "MachServiceName1";
81+
var resources = new ResourceUsageInfo ();
82+
resources.MachLookUpGlobalName = new string[] { serviceName };
83+
var serviceNames = resources.MachLookUpGlobalName;
84+
Assert.NotNull (serviceNames, "Returned list is null");
85+
Assert.AreEqual (1, serviceNames.Length, "List does not have all service names.");
86+
Assert.AreEqual (serviceName, serviceNames [0], "Service names are not equal.");
87+
88+
// similar test but with null values
89+
90+
resources.MachLookUpGlobalName = null;
91+
Assert.IsNull (resources.MachLookUpGlobalName, "Value was no set to null.");
92+
}
5593
}
5694
}
5795

0 commit comments

Comments
 (0)