Skip to content

Commit 0f1de92

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

3 files changed

Lines changed: 60 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+
SetArrayValue (userClientK, value);
65+
else
66+
RemoveValue (userClientK);
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+
SetArrayValue (globalNameK, value);
80+
else
81+
RemoveValue (globalNameK);
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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,43 @@ 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.AreEqual (1, userClientList.Length, "List does not have all client ids.");
67+
Assert.AreEqual (clientId, userClientList [0], "Client ids are not the same.");
68+
69+
// similar test but with null values.
70+
71+
resources.IOKitUserClient = null;
72+
Assert.IsNull (resources.IOKitUserClient, "Value was not set to null.");
73+
}
74+
75+
[Test]
76+
public void TestResourceUsageInfoMachLookUpGlobalName ()
77+
{
78+
TestRuntime.AssertXcodeVersion (9, 0);
79+
var serviceName = "MachServiceName1";
80+
var resources = new ResourceUsageInfo ();
81+
resources.MachLookUpGlobalName = new string[] { serviceName };
82+
var serviceNames = resources.MachLookUpGlobalName;
83+
84+
Assert.AreEqual (1, serviceNames.Length, "List does not have all service names.");
85+
Assert.AreEqual (serviceName, serviceNames [0], "Service names are not equal.");
86+
87+
// similar test but with null values
88+
89+
resources.MachLookUpGlobalName = null;
90+
Assert.IsNull (resources.MachLookUpGlobalName, "Value was no set to null.");
91+
}
5592
}
5693
}
5794

0 commit comments

Comments
 (0)