objc2_core_midi/generated/
MIDISetup.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4#[cfg(feature = "objc2-core-foundation")]
5use objc2_core_foundation::*;
6
7use crate::*;
8
9/// Derives from MIDIObjectRef, does not have an owner object.
10///
11/// This represents the global state of the MIDI system,
12/// containing lists of the MIDI devices and serial port
13/// owners.
14///
15/// Generally, only MIDI drivers and specialized configuration
16/// editors will need to manipulate MIDISetup objects, not the
17/// average MIDI client application.  As of CoreMIDI 1.1, the
18/// MIDIServer maintains a single global MIDISetupRef, stored
19/// persistently in a preference file.
20///
21/// See also [Apple's documentation](https://developer.apple.com/documentation/coremidi/midisetupref?language=objc)
22#[cfg(feature = "MIDIServices")]
23pub type MIDISetupRef = MIDIObjectRef;
24
25extern "C-unwind" {
26    /// Interrogates drivers, to discover what hardware is present.
27    ///
28    /// As of CoreMIDI 1.1, it is usually not necessary to call
29    /// this function, as CoreMIDI manages a single persistent
30    /// MIDISetup itself.
31    ///
32    ///
33    /// Parameter `outSetup`: On successful return, points to a newly-created MIDISetup
34    /// object.  The caller is responsible for disposing it,
35    /// or transferring ownership of the object back to the
36    /// system, with MIDISetupInstall.
37    ///
38    /// Returns: An OSStatus result code.
39    ///
40    /// # Safety
41    ///
42    /// `out_setup` must be a valid pointer.
43    #[cfg(feature = "MIDIServices")]
44    #[deprecated = "No longer supported"]
45    pub fn MIDISetupCreate(out_setup: NonNull<MIDISetupRef>) -> OSStatus;
46}
47
48extern "C-unwind" {
49    /// Dispose a MIDISetup object.
50    ///
51    /// As of CoreMIDI 1.1, it is usually not necessary to call
52    /// this function, as CoreMIDI manages a single persistent
53    /// MIDISetup itself.
54    ///
55    ///
56    /// Parameter `setup`: The MIDISetup to be disposed.
57    ///
58    /// Returns: An OSStatus result code.
59    #[cfg(feature = "MIDIServices")]
60    #[deprecated = "No longer supported"]
61    pub fn MIDISetupDispose(setup: MIDISetupRef) -> OSStatus;
62}
63
64extern "C-unwind" {
65    /// Install a MIDISetup as the system's current state.
66    ///
67    /// A client can create a MIDISetup object using
68    /// MIDISetupCreate, or MIDISetupFromData.  This function will
69    /// install this state as the current state of the system,
70    /// possibly changing the devices visible to clients.
71    ///
72    /// As of CoreMIDI 1.1, it is usually not necessary to call
73    /// this function, as CoreMIDI manages a single persistent
74    /// MIDISetup itself.
75    ///
76    ///
77    /// Parameter `setup`: The MIDISetup object to install.  Ownership of this
78    /// object is transferred from the client to the system; the
79    /// client must
80    /// <b>
81    /// not
82    /// </b>
83    /// dispose of this MIDISetup.
84    ///
85    /// Returns: An OSStatus result code.
86    #[cfg(feature = "MIDIServices")]
87    #[deprecated = "No longer supported"]
88    pub fn MIDISetupInstall(setup: MIDISetupRef) -> OSStatus;
89}
90
91extern "C-unwind" {
92    /// Return the system's current MIDISetup.
93    ///
94    /// As of CoreMIDI 1.1, it is usually not necessary to call
95    /// this function, as CoreMIDI manages a single persistent
96    /// MIDISetup itself.
97    ///
98    ///
99    /// Parameter `outSetup`: On successful return, points to the system's most
100    /// recently installed MIDISetup.  The system retains
101    /// ownership of the object; the client must
102    /// <b>
103    /// not
104    /// </b>
105    /// dispose of this MIDISetup.
106    ///
107    /// Returns: An OSStatus result code.
108    ///
109    /// # Safety
110    ///
111    /// `out_setup` must be a valid pointer.
112    #[cfg(feature = "MIDIServices")]
113    #[deprecated = "No longer supported"]
114    pub fn MIDISetupGetCurrent(out_setup: NonNull<MIDISetupRef>) -> OSStatus;
115}
116
117extern "C-unwind" {
118    /// Create an XML representation of a MIDISetup object.
119    ///
120    /// As of CoreMIDI 1.1, it is usually not necessary to call
121    /// this function, as CoreMIDI manages a single persistent
122    /// MIDISetup itself.
123    ///
124    ///
125    /// Parameter `setup`: The MIDISetup object whose XML representation is to be
126    /// returned.
127    ///
128    /// Parameter `outData`: On successful return, points to a newly-created CFDataRef
129    /// containing the XML text.  The client is responsible for
130    /// releasing this CFData object when done with it.
131    ///
132    /// Returns: An OSStatus result code.
133    ///
134    /// # Safety
135    ///
136    /// `out_data` must be a valid pointer.
137    #[cfg(all(feature = "MIDIServices", feature = "objc2-core-foundation"))]
138    #[deprecated = "No longer supported"]
139    pub fn MIDISetupToData(setup: MIDISetupRef, out_data: NonNull<*const CFData>) -> OSStatus;
140}
141
142extern "C-unwind" {
143    /// Create a MIDISetup object from an XML stream.
144    ///
145    /// As of CoreMIDI 1.1, it is usually not necessary to call
146    /// this function, as CoreMIDI manages a single persistent
147    /// MIDISetup itself.
148    ///
149    ///
150    /// Parameter `data`: The XML text from which a MIDISetup object is to be built.
151    ///
152    /// Parameter `outSetup`: On successful return, points to a newly-created MIDISetup
153    /// object.  The caller is responsible for disposing it, or
154    /// transferring ownership of the object back to the system,
155    /// with MIDISetupInstall.
156    ///
157    /// Returns: An OSStatus result code.
158    ///
159    /// # Safety
160    ///
161    /// `out_setup` must be a valid pointer.
162    #[cfg(all(feature = "MIDIServices", feature = "objc2-core-foundation"))]
163    #[deprecated = "No longer supported"]
164    pub fn MIDISetupFromData(data: &CFData, out_setup: NonNull<MIDISetupRef>) -> OSStatus;
165}
166
167/// Drivers call this function to specify one of the entities that
168/// comprise a device.
169///
170/// Non-drivers may call this function as of macOS 11.0
171/// &
172/// iOS 14 to
173/// add entities to external devices.
174///
175///
176/// Parameter `device`: The device to which an entity is to be added.
177///
178/// Parameter `name`: The name of the new entity.
179///
180/// Parameter `protocol`: The MIDI protocol variant used by the sources and
181/// destinations that comprise this entity.
182///
183/// Parameter `embedded`: True if this entity is inside the device, false if the
184/// entity simply consists of external connectors to which
185/// other devices can be attached.
186///
187/// Parameter `numSourceEndpoints`: The number of source endpoints the entity has.
188///
189/// Parameter `numDestinationEndpoints`: The number of destination endpoints the entity has.
190///
191/// Parameter `newEntity`: On successful return, points to the newly-created entity.
192///
193/// Returns: An OSStatus result code.
194///
195/// # Safety
196///
197/// `new_entity` must be a valid pointer.
198#[cfg(all(feature = "MIDIServices", feature = "objc2-core-foundation"))]
199#[inline]
200pub unsafe extern "C-unwind" fn MIDIDeviceNewEntity(
201    device: MIDIDeviceRef,
202    name: &CFString,
203    protocol: MIDIProtocolID,
204    embedded: bool,
205    num_source_endpoints: ItemCount,
206    num_destination_endpoints: ItemCount,
207    new_entity: NonNull<MIDIEntityRef>,
208) -> OSStatus {
209    extern "C-unwind" {
210        fn MIDIDeviceNewEntity(
211            device: MIDIDeviceRef,
212            name: &CFString,
213            protocol: MIDIProtocolID,
214            embedded: Boolean,
215            num_source_endpoints: ItemCount,
216            num_destination_endpoints: ItemCount,
217            new_entity: NonNull<MIDIEntityRef>,
218        ) -> OSStatus;
219    }
220    unsafe {
221        MIDIDeviceNewEntity(
222            device,
223            name,
224            protocol,
225            embedded as _,
226            num_source_endpoints,
227            num_destination_endpoints,
228            new_entity,
229        )
230    }
231}
232
233/// Drivers call this function to specify one of the entities that
234/// comprise a device.
235///
236/// Non-drivers may call this function as of CoreMIDI 1.1 to
237/// add entities to external devices.
238///
239///
240/// Parameter `device`: The device to which an entity is to be added.
241///
242/// Parameter `name`: The name of the new entity.
243///
244/// Parameter `embedded`: True if this entity is inside the device, false if the
245/// entity simply consists of external connectors to which
246/// other devices can be attached.
247///
248/// Parameter `numSourceEndpoints`: The number of source endpoints the entity has.
249///
250/// Parameter `numDestinationEndpoints`: The number of destination endpoints the entity has.
251///
252/// Parameter `newEntity`: On successful return, points to the newly-created entity.
253///
254/// Returns: An OSStatus result code.
255///
256/// # Safety
257///
258/// `new_entity` must be a valid pointer.
259#[cfg(all(feature = "MIDIServices", feature = "objc2-core-foundation"))]
260#[deprecated]
261#[inline]
262pub unsafe extern "C-unwind" fn MIDIDeviceAddEntity(
263    device: MIDIDeviceRef,
264    name: &CFString,
265    embedded: bool,
266    num_source_endpoints: ItemCount,
267    num_destination_endpoints: ItemCount,
268    new_entity: NonNull<MIDIEntityRef>,
269) -> OSStatus {
270    extern "C-unwind" {
271        fn MIDIDeviceAddEntity(
272            device: MIDIDeviceRef,
273            name: &CFString,
274            embedded: Boolean,
275            num_source_endpoints: ItemCount,
276            num_destination_endpoints: ItemCount,
277            new_entity: NonNull<MIDIEntityRef>,
278        ) -> OSStatus;
279    }
280    unsafe {
281        MIDIDeviceAddEntity(
282            device,
283            name,
284            embedded as _,
285            num_source_endpoints,
286            num_destination_endpoints,
287            new_entity,
288        )
289    }
290}
291
292extern "C-unwind" {
293    /// Drivers may call this function to remove one of a device's
294    /// entities.
295    ///
296    /// New for CoreMIDI 1.1.
297    ///
298    ///
299    /// Parameter `device`: The device from which an entity is to be removed.
300    ///
301    /// Parameter `entity`: The entity to be removed.
302    ///
303    /// Returns: An OSStatus result code.
304    #[cfg(feature = "MIDIServices")]
305    pub fn MIDIDeviceRemoveEntity(device: MIDIDeviceRef, entity: MIDIEntityRef) -> OSStatus;
306}
307
308extern "C-unwind" {
309    /// Drivers and configuration editors may call this function to add to
310    /// or remove an entity's endpoints.
311    ///
312    /// New for CoreMIDI 1.3.
313    ///
314    /// The MIDIProtocolID of new endpoints is initially the same as that of
315    /// the entity.
316    ///
317    ///
318    /// Parameter `entity`: The entity whose endpoints are to be manipulated.
319    ///
320    /// Parameter `numSourceEndpoints`: The desired new number of source endpoints.
321    ///
322    /// Parameter `numDestinationEndpoints`: The desired new number of destination endpoints.
323    ///
324    /// Returns: An OSStatus result code.
325    #[cfg(feature = "MIDIServices")]
326    pub fn MIDIEntityAddOrRemoveEndpoints(
327        entity: MIDIEntityRef,
328        num_source_endpoints: ItemCount,
329        num_destination_endpoints: ItemCount,
330    ) -> OSStatus;
331}
332
333extern "C-unwind" {
334    /// Adds a driver-owner MIDI device to the current MIDISetup
335    ///
336    ///
337    /// Only MIDI drivers may make this call; it is in this header
338    /// file only for consistency with MIDISetupRemoveDevice.
339    ///
340    /// New for CoreMIDI 1.1.
341    ///
342    ///
343    /// Parameter `device`: The device to be added.
344    #[cfg(feature = "MIDIServices")]
345    pub fn MIDISetupAddDevice(device: MIDIDeviceRef) -> OSStatus;
346}
347
348extern "C-unwind" {
349    /// Removes a driver-owned MIDI device from the current MIDISetup
350    ///
351    ///
352    /// Generally this should only be called from a studio configuration
353    /// editor, to remove a device which is offline and which the user
354    /// has specified as being permanently missing.
355    ///
356    /// Instead of removing devices from the setup, drivers should
357    /// set the device's kMIDIPropertyOffline to 1 so that if the
358    /// device reappears later, none of its properties are lost.
359    ///
360    /// New for CoreMIDI 1.1.
361    ///
362    ///
363    /// Parameter `device`: The device to be added.
364    #[cfg(feature = "MIDIServices")]
365    pub fn MIDISetupRemoveDevice(device: MIDIDeviceRef) -> OSStatus;
366}
367
368extern "C-unwind" {
369    /// Adds an external MIDI device to the current MIDISetup
370    ///
371    ///
372    /// Useful for a studio configuration editor.  New for CoreMIDI 1.1.
373    ///
374    ///
375    /// Parameter `device`: The device to be added.
376    #[cfg(feature = "MIDIServices")]
377    pub fn MIDISetupAddExternalDevice(device: MIDIDeviceRef) -> OSStatus;
378}
379
380extern "C-unwind" {
381    /// Removes an external MIDI device from the current MIDISetup
382    ///
383    ///
384    /// Useful for a studio configuration editor.  New for CoreMIDI 1.1.
385    ///
386    ///
387    /// Parameter `device`: The device to be removed.
388    #[cfg(feature = "MIDIServices")]
389    pub fn MIDISetupRemoveExternalDevice(device: MIDIDeviceRef) -> OSStatus;
390}
391
392extern "C-unwind" {
393    /// Returns the MIDI driver that owns a serial port.
394    ///
395    ///
396    /// The current MIDISetup tracks ownership of serial ports
397    /// to one of the MIDI drivers installed in the system.
398    ///
399    /// Serial ports can be enumerated using IOServiceMatching(
400    /// kIOSerialBSDServiceValue).  The port's unique name is
401    /// the IOService's kIOTTYDeviceKey property.
402    ///
403    /// New for CoreMIDI 1.1.
404    ///
405    /// A previous version of this documentation specified an incorrect
406    /// key for obtaining the port's unique name (IOTTYBaseName).
407    ///
408    ///
409    /// Parameter `portName`: The name of a serial port.
410    ///
411    /// Parameter `outDriverName`: On exit, the name of the driver owning the port,
412    /// or NULL if no driver owns it.
413    ///
414    ///
415    /// Returns: An OSStatus result code.
416    ///
417    /// # Safety
418    ///
419    /// `out_driver_name` must be a valid pointer.
420    #[cfg(feature = "objc2-core-foundation")]
421    #[deprecated = "No longer supported"]
422    pub fn MIDIGetSerialPortOwner(
423        port_name: &CFString,
424        out_driver_name: NonNull<*const CFString>,
425    ) -> OSStatus;
426}
427
428extern "C-unwind" {
429    /// Specifies the MIDI driver that owns a serial port.
430    ///
431    ///
432    /// Use this to assign ownership of a serial port
433    /// to one of the MIDI drivers installed in the system.
434    ///
435    /// New for CoreMIDI 1.1.
436    ///
437    ///
438    /// Parameter `portName`: The name of a serial port.
439    ///
440    /// Parameter `driverName`: The name of the driver that owns the serial port,
441    /// or NULL to specify that no driver owns it.
442    ///
443    ///
444    /// Returns: An OSStatus result code.
445    #[cfg(feature = "objc2-core-foundation")]
446    #[deprecated = "No longer supported"]
447    pub fn MIDISetSerialPortOwner(port_name: &CFString, driver_name: &CFString) -> OSStatus;
448}
449
450extern "C-unwind" {
451    /// Returns a list of installed MIDI drivers for serial port
452    /// MIDI devices.
453    ///
454    ///
455    /// Use this to determine which of the installed MIDI drivers
456    /// are for devices which may attach to serial ports.
457    ///
458    /// New for CoreMIDI 1.1.
459    ///
460    ///
461    /// Parameter `outDriverNames`: On exit, a CFArrayRef containing a list of CFStringRef's
462    /// which are the names of the serial port MIDI drivers.
463    /// The array should be released by the caller.
464    ///
465    ///
466    /// Returns: An OSStatus result code.
467    ///
468    /// # Safety
469    ///
470    /// `out_driver_names` must be a valid pointer.
471    #[cfg(feature = "objc2-core-foundation")]
472    #[deprecated = "No longer supported"]
473    pub fn MIDIGetSerialPortDrivers(out_driver_names: NonNull<*const CFArray>) -> OSStatus;
474}
475
476extern "C-unwind" {
477    /// Create a new external MIDI device.
478    ///
479    ///
480    /// Non-drivers may call this function as of CoreMIDI 1.1, to
481    /// create external devices.
482    ///
483    /// The new device is not added to the current MIDISetupRef;
484    /// to do this, use MIDISetupAddExternalDevice.
485    ///
486    ///
487    /// Parameter `name`: The name of the new device.
488    ///
489    /// Parameter `manufacturer`: The name of the device's manufacturer.
490    ///
491    /// Parameter `model`: The device's model name.
492    ///
493    /// Parameter `outDevice`: On successful return, points to the newly-created device.
494    ///
495    /// Returns: An OSStatus result code.
496    ///
497    /// # Safety
498    ///
499    /// `out_device` must be a valid pointer.
500    #[cfg(all(feature = "MIDIServices", feature = "objc2-core-foundation"))]
501    pub fn MIDIExternalDeviceCreate(
502        name: &CFString,
503        manufacturer: &CFString,
504        model: &CFString,
505        out_device: NonNull<MIDIDeviceRef>,
506    ) -> OSStatus;
507}