use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use crate::*;
pub type MIDIDriverRef = *mut NonNull<MIDIDriverInterface>;
#[cfg(feature = "MIDIServices")]
pub type MIDIDeviceListRef = MIDIObjectRef;
#[cfg(all(feature = "MIDIServices", feature = "objc2-core-foundation"))]
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MIDIDriverInterface {
pub(crate) _reserved: NonNull<c_void>,
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) -> OSStatus,
pub Start: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIDeviceListRef) -> OSStatus,
pub Stop: unsafe extern "C-unwind" fn(MIDIDriverRef) -> OSStatus,
pub Configure: unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIDeviceRef) -> OSStatus,
pub Send: unsafe extern "C-unwind" fn(
MIDIDriverRef,
NonNull<MIDIPacketList>,
NonNull<c_void>,
NonNull<c_void>,
) -> OSStatus,
pub EnableSource:
unsafe extern "C-unwind" fn(MIDIDriverRef, MIDIEndpointRef, Boolean) -> OSStatus,
pub Flush: unsafe extern "C-unwind" fn(
MIDIDriverRef,
MIDIEndpointRef,
*mut c_void,
*mut c_void,
) -> OSStatus,
pub Monitor: unsafe extern "C-unwind" fn(
MIDIDriverRef,
MIDIEndpointRef,
NonNull<MIDIPacketList>,
) -> OSStatus,
pub SendPackets: unsafe extern "C-unwind" fn(
MIDIDriverRef,
NonNull<MIDIEventList>,
NonNull<c_void>,
NonNull<c_void>,
) -> OSStatus,
pub MonitorEvents: unsafe extern "C-unwind" fn(
MIDIDriverRef,
MIDIEndpointRef,
NonNull<MIDIEventList>,
) -> OSStatus,
}
#[cfg(all(
feature = "MIDIServices",
feature = "objc2",
feature = "objc2-core-foundation"
))]
unsafe impl Encode for MIDIDriverInterface {
const ENCODING: Encoding = Encoding::Struct("MIDIDriverInterface", &[
<NonNull<c_void>>::ENCODING,
<unsafe extern "C-unwind" fn(NonNull<c_void>,REFIID,*mut LPVOID,) -> HRESULT>::ENCODING,
<unsafe extern "C-unwind" fn(NonNull<c_void>,) -> ULONG>::ENCODING,
<unsafe extern "C-unwind" fn(NonNull<c_void>,) -> ULONG>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,MIDIDeviceListRef,) -> OSStatus>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,MIDIDeviceListRef,) -> OSStatus>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,) -> OSStatus>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,MIDIDeviceRef,) -> OSStatus>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,NonNull<MIDIPacketList>,NonNull<c_void>,NonNull<c_void>,) -> OSStatus>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,MIDIEndpointRef,Boolean,) -> OSStatus>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,MIDIEndpointRef,*mut c_void,*mut c_void,) -> OSStatus>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,MIDIEndpointRef,NonNull<MIDIPacketList>,) -> OSStatus>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,NonNull<MIDIEventList>,NonNull<c_void>,NonNull<c_void>,) -> OSStatus>::ENCODING,
<unsafe extern "C-unwind" fn(MIDIDriverRef,MIDIEndpointRef,NonNull<MIDIEventList>,) -> OSStatus>::ENCODING,
]);
}
#[cfg(all(
feature = "MIDIServices",
feature = "objc2",
feature = "objc2-core-foundation"
))]
unsafe impl RefEncode for MIDIDriverInterface {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
#[cfg(feature = "objc2-core-foundation")]
pub static kMIDIDriverPropertyUsesSerial: &'static CFString;
}
extern "C-unwind" {
#[cfg(all(feature = "MIDIServices", feature = "objc2-core-foundation"))]
pub fn MIDIDeviceCreate(
owner: MIDIDriverRef,
name: &CFString,
manufacturer: &CFString,
model: &CFString,
out_device: NonNull<MIDIDeviceRef>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "MIDIServices")]
pub fn MIDIDeviceDispose(device: MIDIDeviceRef) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "MIDIServices")]
pub fn MIDIDeviceListGetNumberOfDevices(dev_list: MIDIDeviceListRef) -> ItemCount;
}
extern "C-unwind" {
#[cfg(feature = "MIDIServices")]
pub fn MIDIDeviceListGetDevice(dev_list: MIDIDeviceListRef, index0: ItemCount)
-> MIDIDeviceRef;
}
extern "C-unwind" {
#[cfg(feature = "MIDIServices")]
pub fn MIDIDeviceListAddDevice(dev_list: MIDIDeviceListRef, dev: MIDIDeviceRef) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "MIDIServices")]
pub fn MIDIDeviceListDispose(dev_list: MIDIDeviceListRef) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "MIDIServices")]
pub fn MIDIEndpointSetRefCons(
endpt: MIDIEndpointRef,
ref1: *mut c_void,
ref2: *mut c_void,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "MIDIServices")]
pub fn MIDIEndpointGetRefCons(
endpt: MIDIEndpointRef,
ref1: *mut NonNull<c_void>,
ref2: *mut NonNull<c_void>,
) -> OSStatus;
}
#[cfg(feature = "objc2-core-foundation")]
#[inline]
pub unsafe extern "C-unwind" fn MIDIGetDriverIORunLoop() -> CFRetained<CFRunLoop> {
extern "C-unwind" {
fn MIDIGetDriverIORunLoop() -> Option<NonNull<CFRunLoop>>;
}
let ret = unsafe { MIDIGetDriverIORunLoop() };
let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::retain(ret) }
}
extern "C-unwind" {
#[cfg(feature = "MIDIServices")]
pub fn MIDIGetDriverDeviceList(driver: MIDIDriverRef) -> MIDIDeviceListRef;
}
#[inline]
pub unsafe extern "C-unwind" fn MIDIDriverEnableMonitoring(
driver: MIDIDriverRef,
enabled: bool,
) -> OSStatus {
extern "C-unwind" {
fn MIDIDriverEnableMonitoring(driver: MIDIDriverRef, enabled: Boolean) -> OSStatus;
}
unsafe { MIDIDriverEnableMonitoring(driver, enabled as _) }
}