Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Auto-format source code
  • Loading branch information
GitHub Actions Autoformatter committed Jun 4, 2025
commit b38aef8a57bd5e984d0afea19fb8c4025509564b
12 changes: 6 additions & 6 deletions src/CoreMidi/MidiDriverInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ unsafe protected MidiDriver ()

unsafe MidiDriverInterface* CreateDriver ()
{
var iface = (MidiDriverInterface *) Marshal.AllocHGlobal (sizeof (MidiDriverInterface));
var iface = (MidiDriverInterface*) Marshal.AllocHGlobal (sizeof (MidiDriverInterface));
iface->QueryInterface = &QueryInterface;
iface->AddRef = &AddRef;
iface->Release = &Release;
Expand All @@ -77,7 +77,7 @@ unsafe protected MidiDriver ()
}

[UnmanagedCallersOnly]
unsafe static HRESULT QueryInterface (MidiDriverInterface *self, CFUuidBytes iid, void * ppv)
unsafe static HRESULT QueryInterface (MidiDriverInterface* self, CFUuidBytes iid, void* ppv)
{
var driver = self->GetObject ();
Console.WriteLine ($"MidiDriver.QueryInterface ({(IntPtr) self}, {iid}, {(IntPtr) ppv}) => {driver}");
Expand All @@ -93,7 +93,7 @@ internal virtual HRESULT QueryInterface (CFUuidBytes iid, IntPtr ppv)
static List<MidiDriver> strongReferences = new List<MidiDriver> ();

[UnmanagedCallersOnly]
unsafe static uint AddRef (MidiDriverInterface *self)
unsafe static uint AddRef (MidiDriverInterface* self)
{
var driver = self->GetObject ();
Console.WriteLine ($"MidiDriver.AddRef ({(IntPtr) self}) => {driver}");
Expand All @@ -114,7 +114,7 @@ unsafe internal virtual uint AddRef ()
}

[UnmanagedCallersOnly]
unsafe static uint Release (MidiDriverInterface *self)
unsafe static uint Release (MidiDriverInterface* self)
{
var driver = self->GetObject ();
Console.WriteLine ($"MidiDriver.Release ({(IntPtr) self}) => {driver}");
Expand All @@ -141,7 +141,7 @@ unsafe internal virtual uint Release ()
}

[UnmanagedCallersOnly]
unsafe static OSStatus FindDevices (MidiDriverInterface *self, MidiDeviceListRef devList)
unsafe static OSStatus FindDevices (MidiDriverInterface* self, MidiDeviceListRef devList)
{
var driver = self->GetObject ();
Console.WriteLine ($"MidiDriver.FindDevices ({(IntPtr) self}, {devList}) => {driver}");
Expand Down Expand Up @@ -341,7 +341,7 @@ struct MidiDriverInterface {
#pragma warning disable CS0169 // The field 'MidiDriverInterface._reserved' is never used
IntPtr _reserved;
#pragma warning restore CS0169
internal unsafe delegate* unmanaged<MidiDriverInterface* /* thisPointer */, CFUuidBytes /* REFIID iid */, void * /* ppv */, int /* HRESULT */> QueryInterface;
internal unsafe delegate* unmanaged<MidiDriverInterface* /* thisPointer */, CFUuidBytes /* REFIID iid */, void* /* ppv */, int /* HRESULT */> QueryInterface;
internal unsafe delegate* unmanaged<MidiDriverInterface* /* thisPointer */, uint /* ULONG */> AddRef;
internal unsafe delegate* unmanaged<MidiDriverInterface* /* thisPointer */, uint /* ULONG */ > Release;
internal unsafe delegate* unmanaged<MidiDriverInterface* /* self */, MidiDeviceListRef /* devList */, OSStatus> FindDevices;
Expand Down
4 changes: 2 additions & 2 deletions src/CoreMidi/MidiEventList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public MidiEventList (MidiProtocolId protocol, int size)
midiDataSize = size;
owns = true;
unsafe {
midiDataPointer = (MIDIEventList *) Marshal.AllocHGlobal (midiDataSize);
midiDataPointer = (MIDIEventList*) Marshal.AllocHGlobal (midiDataSize);
currentPacket = MIDIEventListInit (midiDataPointer, protocol);
if (currentPacket is null)
throw new Exception ($"Failed to create midi event list.");
Expand All @@ -101,7 +101,7 @@ public MidiEventList (MidiProtocolId protocol, int size)
public MidiEventList (IntPtr eventListPointer)
{
unsafe {
midiDataPointer = (MIDIEventList *) eventListPointer;
midiDataPointer = (MIDIEventList*) eventListPointer;
owns = false;
midiDataSize = -1;
}
Expand Down
36 changes: 18 additions & 18 deletions src/CoreMidi/MidiServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ public override string ToString ()
/// <param name="status">A status code that describes the result of this operation. This will be <see cref="MidiError.Ok" /> in case of success.</param>
/// <returns>A newly created <see cref="MidiEndpoint" /> if successful, otherwise null.</returns>
/// <remarks> FIXME: ADD BETTER DOCS HERE </remarks>
public unsafe MidiEndpoint? CreateVirtualDestination (string name, MidiProtocolId protocol, delegate* unmanaged<void*,void*,void> readBlock, out MidiError status)
public unsafe MidiEndpoint? CreateVirtualDestination (string name, MidiProtocolId protocol, delegate* unmanaged<void*, void*, void> readBlock, out MidiError status)
{
using var namePtr = new TransientCFString (name);
var handle = default (MidiEndpointRef);
Expand All @@ -787,7 +787,7 @@ public override string ToString ()
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
[DllImport (Constants.CoreMidiLibrary)]
unsafe extern static OSStatus MIDIDestinationCreateWithProtocol (MidiClientRef client, IntPtr /* CFStringRef */ name, MidiProtocolId protocol, MidiEndpointRef* outSrc, delegate* unmanaged<void * /* const MIDIEventList * */, void * /* __nullable srcConnRefCon */, void> readBlock);
unsafe extern static OSStatus MIDIDestinationCreateWithProtocol (MidiClientRef client, IntPtr /* CFStringRef */ name, MidiProtocolId protocol, MidiEndpointRef* outSrc, delegate* unmanaged<void* /* const MIDIEventList * */, void* /* __nullable srcConnRefCon */, void> readBlock);

/// <param name="name">name for the input port.</param>
/// <summary>Creates a new MIDI input port.</summary>
Expand Down Expand Up @@ -819,7 +819,7 @@ unsafe extern static OSStatus MIDIInputPortCreateWithProtocol (
IntPtr /* CFStringRef */ name,
MidiProtocolId protocol,
MidiPortRef* outPort,
delegate* unmanaged<void * /* const MIDIEventList * */, void * /* __nullable srcConnRefCon */, void> receiveBlock);
delegate* unmanaged<void* /* const MIDIEventList * */, void* /* __nullable srcConnRefCon */, void> receiveBlock);

/// <summary>Create a input port for this client.</summary>
/// <param name="name">The name for the port.</param>
Expand All @@ -832,7 +832,7 @@ unsafe extern static OSStatus MIDIInputPortCreateWithProtocol (
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("tvos")]
public unsafe MidiPort? CreateInputPort (string name, MidiProtocolId protocol, delegate* unmanaged<void*,void*,void> readBlock, out MidiError status)
public unsafe MidiPort? CreateInputPort (string name, MidiProtocolId protocol, delegate* unmanaged<void*, void*, void> readBlock, out MidiError status)
{
using var namePtr = new TransientCFString (name);
var handle = default (MidiEndpointRef);
Expand Down Expand Up @@ -3317,7 +3317,7 @@ public MidiError SetRefCons (IntPtr ref1, IntPtr ref2)
/// <param name="data">The data to send.</param>
/// <param name="cancellationToken">An optional cancellation token that can be used to cancel the request.</param>
/// <returns>A <see cref="MidiError" /> value for the request. This will be <see cref="MidiError.Ok" /> if the request was successful, an error code otherwise.</returns>
public unsafe Task<MidiError> SendSysexAsync (byte[] data, CancellationToken? cancellationToken = null)
public unsafe Task<MidiError> SendSysexAsync (byte [] data, CancellationToken? cancellationToken = null)
{
if (data is null)
ThrowHelper.ThrowArgumentNullException (nameof (data));
Expand Down Expand Up @@ -3348,7 +3348,7 @@ public unsafe Task<MidiError> SendSysexAsync (byte[] data, CancellationToken? ca
[SupportedOSPlatform ("maccatalyst17.0")]
[SupportedOSPlatform ("macos14.0")]
[UnsupportedOSPlatform ("tvos")]
public unsafe Task<MidiError> SendSysexUmpAsync (uint[] data, CancellationToken? cancellationToken = null)
public unsafe Task<MidiError> SendSysexUmpAsync (uint [] data, CancellationToken? cancellationToken = null)
{
if (data is null)
ThrowHelper.ThrowArgumentNullException (nameof (data));
Expand Down Expand Up @@ -3379,7 +3379,7 @@ public unsafe Task<MidiError> SendSysexUmpAsync (uint[] data, CancellationToken?
[SupportedOSPlatform ("maccatalyst17.0")]
[SupportedOSPlatform ("macos14.0")]
[UnsupportedOSPlatform ("tvos")]
public unsafe Task<MidiError> SendSysexUmp8Async (uint[] data, CancellationToken? cancellationToken = null)
public unsafe Task<MidiError> SendSysexUmp8Async (uint [] data, CancellationToken? cancellationToken = null)
{
if (data is null)
ThrowHelper.ThrowArgumentNullException (nameof (data));
Expand All @@ -3398,14 +3398,14 @@ public unsafe Task<MidiError> SendSysexUmp8Async (uint[] data, CancellationToken
class SysexRequest : IDisposable {
IntPtr structPointer;
MidiEndpoint endpoint;
byte[]? byteData;
uint[]? uintData;
byte []? byteData;
uint []? uintData;
GCHandle dataHandle;
GCHandle thisHandle;
TaskCompletionSource<MidiError> onCompletion;
CancellationTokenRegistration? cancellationTokenRegistration;

public SysexRequest (MidiEndpoint endpoint, byte[] data, TaskCompletionSource<MidiError> onCompletion)
public SysexRequest (MidiEndpoint endpoint, byte [] data, TaskCompletionSource<MidiError> onCompletion)
{
this.endpoint = endpoint;
this.byteData = data;
Expand All @@ -3418,7 +3418,7 @@ public SysexRequest (MidiEndpoint endpoint, byte[] data, TaskCompletionSource<Mi
thisHandle = GCHandle.Alloc (this);
}

public SysexRequest (MidiEndpoint endpoint, uint[] data, TaskCompletionSource<MidiError> onCompletion)
public SysexRequest (MidiEndpoint endpoint, uint [] data, TaskCompletionSource<MidiError> onCompletion)
{
this.endpoint = endpoint;
this.uintData = data;
Expand All @@ -3436,7 +3436,7 @@ public SysexRequest (MidiEndpoint endpoint, uint[] data, TaskCompletionSource<Mi
if (byteData is null)
throw new InvalidOperationException ($"No byte[] data specified.");

var rv = (MidiSysexSendRequest *) structPointer;
var rv = (MidiSysexSendRequest*) structPointer;

rv->Destination = endpoint.GetCheckedHandle ();
rv->Data = dataHandle.AddrOfPinnedObject ();
Expand All @@ -3454,7 +3454,7 @@ public SysexRequest (MidiEndpoint endpoint, uint[] data, TaskCompletionSource<Mi
if (uintData is null)
throw new InvalidOperationException ($"No uint[] data specified.");

var rv = (MidiSysexSendRequestUmp *) structPointer;
var rv = (MidiSysexSendRequestUmp*) structPointer;

rv->Destination = endpoint.GetCheckedHandle ();
rv->Words = dataHandle.AddrOfPinnedObject ();
Expand All @@ -3481,24 +3481,24 @@ unsafe static void SysexCompletion (MidiSysexSendRequest* request)
}

[UnmanagedCallersOnly]
unsafe static void UmpSysexCompletion (MidiSysexSendRequestUmp * request)
unsafe static void UmpSysexCompletion (MidiSysexSendRequestUmp* request)
{
var obj = (SysexRequest?) GCHandle.FromIntPtr (request->Context).Target;
obj?.OnCompleted ();
}

unsafe void SysexCancellationRequest ()
{
var rv = (MidiSysexSendRequest *) structPointer;
if (rv == null)
var rv = (MidiSysexSendRequest*) structPointer;
if (rv is null)
return;
rv->Complete = true;
}

unsafe void UmpSysexCancellationRequest ()
{
var rv = (MidiSysexSendRequestUmp *) structPointer;
if (rv == null)
var rv = (MidiSysexSendRequestUmp*) structPointer;
if (rv is null)
return;
rv->Complete = true;
}
Expand Down
70 changes: 34 additions & 36 deletions src/CoreMidi/MidiStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,15 @@ public unsafe MidiCIProfileIdManufacturerSpecific ManufacturerSpecific {

/// <summary>A struct that represents a request to transmit a single system-exclusive event.</summary>
[NativeName ("MIDISysexSendRequest")]
struct MidiSysexSendRequest
{
MidiEndpointRef destination;
struct MidiSysexSendRequest {
MidiEndpointRef destination;
IntPtr /* const Byte * */ data;
uint bytesToSend;
uint bytesToSend;
byte /* Boolean */ complete;
#pragma warning disable CS0169 // The field '...' is never used
byte reserved1;
byte reserved2;
byte reserved3;
byte reserved1;
byte reserved2;
byte reserved3;
#pragma warning restore CS0169
unsafe delegate* unmanaged<MidiSysexSendRequest*, void> /* MIDICompletionProc */ completionProc;
IntPtr /* void * __nullable */ completionRefCon;
Expand Down Expand Up @@ -199,38 +198,37 @@ public IntPtr Context {
}


/*!
@struct MIDISysexSendRequestUMP
@abstract A request to transmit a UMP system-exclusive event.

@discussion
This represents a request to send a single UMP system-exclusive MIDI event to
a MIDI destination asynchronously.

@field destination
The endpoint to which the event is to be sent.
@field words
Initially, a pointer to the UMP SysEx event to be sent.
MIDISendUMPSysex will advance this pointer as data is
sent.
@field wordsToSend
Initially, the number of words to be sent. MIDISendUMPSysex
will decrement this counter as data is sent.
@field complete
The client may set this to true at any time to abort
transmission. The implementation sets this to true when
all data been transmitted.
@field completionProc
Called when all bytes have been sent, or after the client
has set complete to true.
@field completionRefCon
Passed as a refCon to completionProc.
*/
/*!
@struct MIDISysexSendRequestUMP
@abstract A request to transmit a UMP system-exclusive event.

@discussion
This represents a request to send a single UMP system-exclusive MIDI event to
a MIDI destination asynchronously.

@field destination
The endpoint to which the event is to be sent.
@field words
Initially, a pointer to the UMP SysEx event to be sent.
MIDISendUMPSysex will advance this pointer as data is
sent.
@field wordsToSend
Initially, the number of words to be sent. MIDISendUMPSysex
will decrement this counter as data is sent.
@field complete
The client may set this to true at any time to abort
transmission. The implementation sets this to true when
all data been transmitted.
@field completionProc
Called when all bytes have been sent, or after the client
has set complete to true.
@field completionRefCon
Passed as a refCon to completionProc.
*/

/// <summary>A struct that represents a request to transmit a single UMP system-exclusive event.</summary>
[NativeName ("MIDISysexSendRequestUMP")]
struct MidiSysexSendRequestUmp
{
struct MidiSysexSendRequestUmp {
MidiEndpointRef destination;
IntPtr /* UInt32* */ words;
uint /* UInt32 */ wordsToSend;
Expand Down
Loading