MIDIDriverInterface

Struct MIDIDriverInterface 

Source
pub struct MIDIDriverInterface {
Show 13 fields pub QueryInterface: unsafe extern "C-unwind" fn(NonNull<c_void>, REFIID, *mut LPVOID) -> HRESULT, pub AddRef: unsafe extern "C-unwind" fn(NonNull<c_void>) -> ULONG, pub Release: unsafe extern "C-unwind" fn(NonNull<c_void>) -> ULONG, pub FindDevices: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIDeviceListRef) -> i32, pub Start: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIDeviceListRef) -> i32, pub Stop: unsafe extern "C-unwind" fn(MIDIDriverRef) -> i32, pub Configure: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIDeviceRef) -> i32, pub Send: unsafe extern "C-unwind" fn(MIDIDriverRef, NonNull<MIDIPacketList>, NonNull<c_void>, NonNull<c_void>) -> i32, pub EnableSource: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIEndpointRef, u8) -> i32, pub Flush: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIEndpointRef, *mut c_void, *mut c_void) -> i32, pub Monitor: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIEndpointRef, NonNull<MIDIPacketList>) -> i32, pub SendPackets: unsafe extern "C-unwind" fn(MIDIDriverRef, NonNull<MIDIEventList>, NonNull<c_void>, NonNull<c_void>) -> i32, pub MonitorEvents: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIEndpointRef, NonNull<MIDIEventList>) -> i32, /* private fields */
}
Available on crate features MIDIDriver and MIDIServices and objc2-core-foundation only.
Expand description

The COM-style interface to a MIDI driver.

This is the function table interface to a MIDI driver. Version 1 and 2 drivers use this same table of function pointers (except as noted).

Drivers which support multiple version interfaces can tell which version of the server is running by checking to see whether kMIDIDriverInterface2ID or kMIDIDriverInterfaceID is passed to the factory function. If the version 1 interface is requested, the driver should behave as if it is a version 1 driver.

See also Apple’s documentation

Fields§

§QueryInterface: unsafe extern "C-unwind" fn(NonNull<c_void>, REFIID, *mut LPVOID) -> HRESULT§AddRef: unsafe extern "C-unwind" fn(NonNull<c_void>) -> ULONG§Release: unsafe extern "C-unwind" fn(NonNull<c_void>) -> ULONG§FindDevices: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIDeviceListRef) -> i32

This is only called for version 1 drivers. The server is requesting that the driver detect the devices which are present. For each device present, the driver should create a MIDIDeviceRef with entities, using MIDIDeviceCreate and MIDIDeviceAddEntity, and add the device to the supplied MIDIDeviceListRef, using MIDIDeviceListAddDevice.

The driver should not retain any references to the created devices and entities.

§Start: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIDeviceListRef) -> i32

The server is telling the driver to begin MIDI I/O.

The provided device list contains the devices which were previously located by FindDevices (in the case of a version 1 driver), or the devices which are owned by this driver and are currently in the current MIDISetup (for version 2 drivers).

The provided devices may or may not still be present. A version 1 driver should attempt to use as many of the devices as are actually present.

A version 2 driver may make calls such as MIDISetupAddDevice, MIDIDeviceAddEntity, MIDIDeviceRemoveEntity to dynamically modify the system’s current state. For devices in the provided device list which are not present, the driver should set their kMIDIPropertyOffline property to 1. A version 2 driver may also set up notifications when the IORegistry changes, to detect connection and disconnection of devices it wishes to control. At these times also, the driver may change the devices’ kMIDIPropertyOffline, and dynamically modify the system’s current state to reflect the devices which are present. When passing a CFRunLoopRef to IOKit for notification purposes, the driver must use the server’s main runloop, which is obtained with CFRunLoopGetCurrent().

The driver will probably want to iterate through the destination endpoints and assign their driver refCons, so as to identify multiple destinations when Send() is called.

The provided device list remains owned by the system and can be assumed to contain only devices owned by this driver. The driver may retain references to the devices in this list and any it creates while running.

§Stop: unsafe extern "C-unwind" fn(MIDIDriverRef) -> i32

The server is telling the driver to terminate MIDI I/O. All I/O operations that were begun in Start, or as a result of a subsequent IOKit notification, should be terminated.

§Configure: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIDeviceRef) -> i32

not currently used

§Send: unsafe extern "C-unwind" fn(MIDIDriverRef, NonNull<MIDIPacketList>, NonNull<c_void>, NonNull<c_void>) -> i32

Send a MIDIPacketList to the destination endpoint whose refCons are being passed as arguments.

§EnableSource: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIEndpointRef, u8) -> i32

A client has opened or closed a connection, and now the server is telling the driver that input from a particular source either does or does not have any listeners in the system. The driver may use this information to decide whether to pass messages from the source to the server, and it may even be able to tell the source hardware not to generate incoming MIDI I/O for that source.

§Flush: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIEndpointRef, *mut c_void, *mut c_void) -> i32

Only for version 2 drivers (new for CoreMIDI 1.1).

Drivers which support schedule-ahead, when receiving this message, should unschedule all pending output to the specified destination. If the destination is null/0, the driver should unschedule all pending output to all destinations.

§Monitor: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIEndpointRef, NonNull<MIDIPacketList>) -> i32

Only for version 2 drivers (new for CoreMIDI 1.1).

Some specialized drivers (e.g. a MIDI monitor display) may wish to intercept and look at all outgoing MIDI messages. After a driver calls MIDIDriverEnableMonitoring(true) on itself, this function is called with the outgoing MIDI packets for all destinations in the system. The Monitor function cannot rely on the MIDI events arriving in order, due to MIDIServer’s schedule-ahead facilities.

§SendPackets: unsafe extern "C-unwind" fn(MIDIDriverRef, NonNull<MIDIEventList>, NonNull<c_void>, NonNull<c_void>) -> i32

Only for version 3 drivers (new for macOS 12.0).

Send a MIDIEventList to the destination endpoint whose refCons are being passed as arguments.

§MonitorEvents: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIEndpointRef, NonNull<MIDIEventList>) -> i32

Only for version 3 drivers (new for macOS 12.0).

Same as Monitor but uses MIDEventList, whose protocol may vary from MIDI 1.0.

Trait Implementations§

Source§

impl Clone for MIDIDriverInterface

Source§

fn clone(&self) -> MIDIDriverInterface

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MIDIDriverInterface

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Encode for MIDIDriverInterface

Available on crate feature objc2 only.
Source§

const ENCODING: Encoding

The Objective-C type-encoding for this type.
Source§

impl PartialEq for MIDIDriverInterface

Source§

fn eq(&self, other: &MIDIDriverInterface) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for MIDIDriverInterface

Available on crate feature objc2 only.
Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Copy for MIDIDriverInterface

Source§

impl StructuralPartialEq for MIDIDriverInterface

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> EncodeArgument for T
where T: Encode,

Source§

const ENCODING_ARGUMENT: Encoding = T::ENCODING

The Objective-C type-encoding for this type.
Source§

impl<T> EncodeReturn for T
where T: Encode,

Source§

const ENCODING_RETURN: Encoding = T::ENCODING

The Objective-C type-encoding for this type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,