Skip to content

Commit

Permalink
Made changes as per reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel-macaque committed Jul 19, 2017
1 parent d820f79 commit faa8965
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 32 deletions.
18 changes: 10 additions & 8 deletions src/AudioUnit/AudioComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,23 @@ public ResourceUsageInfo () : base () {}

public ResourceUsageInfo (NSDictionary dic) : base (dic) {}

public NSString[] IOKitUserClient {
public string[] IOKitUserClient {
get {
return GetArray<NSString> (userClientK);
var array = GetNativeValue<NSArray> (userClientK);
return NSArray.StringArrayFromHandle (array.ClassHandle);
}
set {
SetArrayValue <NSString> (userClientK, value);
SetArrayValue (userClientK, value);
}
}

public NSString[] MachLookUpGlobalName {
public string[] MachLookUpGlobalName {
get {
return GetArray<NSString> (globalNameK);
var array = GetNativeValue<NSArray> (globalNameK);
return NSArray.StringArrayFromHandle (array.ClassHandle);
}
set {
SetArrayValue <NSString> (globalNameK, value);
SetArrayValue (globalNameK, value);
}
}

Expand Down Expand Up @@ -392,7 +394,7 @@ public AudioComponentInfo[] ComponentList {
var cHandle = CopyComponentList (cfString.Handle);
if (cHandle == IntPtr.Zero)
return null;
using (var nsArray = Runtime.GetNSObject<NSArray> (cHandle)) {
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
Expand Down Expand Up @@ -421,7 +423,7 @@ public AudioComponentInfo[] ComponentList {
case AudioConverterError.None:
return;
default:
throw new InvalidOperationException ("ComponentList could not be set.");
throw new InvalidOperationException ($"ComponentList could not be set, error {result.ToString ()}");

}
}
Expand Down
37 changes: 18 additions & 19 deletions src/AudioUnit/AudioUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,39 +365,39 @@ public enum AUParameterEventType : uint
[StructLayout (LayoutKind.Sequential)]
public struct AudioUnitParameterEvent
{
public uint scope;
public uint element;
public uint parameter;
public AUParameterEventType eventType;
public uint Scope;
public uint Element;
public uint Parameter;
public AUParameterEventType EventType;

[StructLayout (LayoutKind.Explicit)]
public struct EventValues
public struct EventValuesStruct
{
[StructLayout (LayoutKind.Sequential)]
public struct Ramp
public struct RampStruct
{
public int startBufferOffset;
public uint durationInFrames;
public float startValue;
public float endValue;
public int StartBufferOffset;
public uint DurationInFrames;
public float StartValue;
public float EndValue;
}


[FieldOffset (0)]
public Ramp ramp;
public RampStruct Ramp;

[StructLayout (LayoutKind.Sequential)]
public struct Immediate
public struct ImmediateStruct
{
public uint bufferOffset;
public float value;
public uint bBufferOffset;
public float Value;
}

[FieldOffset (0)]
public Immediate immediate;
public ImmediateStruct Immediate;
}

public EventValues eventValues;
public EventValuesStruct EventValues;
}

public class AudioUnit : IDisposable, XamCore.ObjCRuntime.INativeObject
Expand Down Expand Up @@ -1085,9 +1085,8 @@ static extern AudioUnitStatus AudioUnitGetPropertyInfo (IntPtr inUnit, AudioUnit
static extern AudioUnitStatus AudioUnitSetParameter (IntPtr inUnit, AudioUnitParameterType inID, AudioUnitScopeType inScope,
uint inElement, float inValue, uint inBufferOffsetInFrames);

[iOS (2,0)]
[DllImport (Constants.AudioUnitLibrary)]
static extern AudioUnitStatus AudioUnitScheduleParameters (IntPtr inUnit, AudioUnitParameterEvent inParameterEvent, uint inNumParamEvents);
static extern AudioUnitStatus AudioUnitScheduleParameters (IntPtr inUnit, AudioUnitParameterEvent inParameterEvent, uint inNumParamEvents);

#if MONOMAC
[DllImport (Constants.AudioUnitLibrary)]
Expand Down Expand Up @@ -2012,7 +2011,7 @@ public enum AUSpatializationAlgorithm : uint
SoundField = 3,
VectorBasedPanning = 4,
StereoPassThrough = 5,
HRTFHQ = 6,
HrtfHQ = 6,
}

public enum AU3DMixerAttenuationCurve : uint
Expand Down
7 changes: 4 additions & 3 deletions src/audiounit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

using XamCore.AudioUnit;
using XamCore.CoreFoundation;
Expand Down Expand Up @@ -40,7 +41,7 @@ internal delegate AudioUnitStatus AURenderPullInputBlock (ref AudioUnitRenderAct

delegate void AUScheduleParameterBlock (AUEventSampleTime eventSampleTime, uint rampDurationSampleFrames, ulong parameterAddress, float value);
[iOS (11, 0), Mac (10,13), TV (11,0), NoWatch]
delegate int AUMidiOutputEventBlock (long eventSampleTime, byte cable, nint length, ref byte midiBytes);
delegate int AUMidiOutputEventBlock (long eventSampleTime, byte cable, nint length, IntPtr midiBytes);
delegate void AUImplementorValueObserver (AUParameter param, float value);
delegate float AUImplementorValueProvider (AUParameter param);

Expand Down Expand Up @@ -263,11 +264,11 @@ interface AUAudioUnit_AUAudioInputOutputUnit {

[Mac (10,12), NoTV, NoiOS, NoWatch]
[Export ("deviceID")]
uint GetDeviceID ();
uint GetDeviceId ();

[Mac (10,12), NoTV, NoiOS, NoWatch]
[Export ("setDeviceID:error:")]
bool SetDeviceID (uint deviceID, out NSError outError);
bool SetDeviceId (uint deviceID, out NSError outError);

[Export ("canPerformInput")]
bool GetCanPerformInput ();
Expand Down
3 changes: 1 addition & 2 deletions tests/monotouch-test/AudioToolbox/AudioComponentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public class AudioComponentTest {
[Test]
public void GetSetComponentList ()
{
if (IntPtr.Size == 4)
Assert.Ignore ("API only available in 64 bits.");
TestRuntime.AssertXcodeVersion (9, 0);
var types = new List<AudioTypeOutput> { AudioTypeOutput.Generic, AudioTypeOutput.Remote, AudioTypeOutput.VoiceProcessingIO };
foreach (var t in types) {
var resources = new ResourceUsageInfo ();
Expand Down

0 comments on commit faa8965

Please sign in to comment.