1 {
2      File:       CoreMIDI/MIDIDriver.h
3 
4      Contains:   MIDI Services driver interfaces
5 
6  	Copyright:  (c) 2000-2008 by Apple Inc., all rights reserved.
7 
8      Bugs?:      For bug reports, consult the following page on
9                  the World Wide Web:
10 
11                      http://bugs.freepascal.org
12 }
13 {  Pascal Translation:  Gorazd Krosl <gorazd_1957@yahoo.ca>, October 2009 }
14 {  Pascal Translation Update: Jonas Maebe <jonas@freepascal.org>, October 2012 }
15 
16 {
17     Modified for use with Free Pascal
18     Version 308
19     Please report any bugs to <gpc@microbizz.nl>
20 }
21 
22 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
23 {$mode macpas}
24 {$modeswitch cblocks}
25 {$packenum 1}
26 {$macro on}
27 {$inline on}
28 {$calling mwpascal}
29 
30 unit MIDIDriver;
31 interface
32 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
33 {$setc GAP_INTERFACES_VERSION := $0308}
34 
35 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
36     {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
37 {$endc}
38 
39 {$ifc defined CPUPOWERPC and defined CPUI386}
40 	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
41 {$endc}
42 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
43 	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
44 {$endc}
45 
46 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
47 	{$setc __ppc__ := 1}
48 {$elsec}
49 	{$setc __ppc__ := 0}
50 {$endc}
51 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
52 	{$setc __ppc64__ := 1}
53 {$elsec}
54 	{$setc __ppc64__ := 0}
55 {$endc}
56 {$ifc not defined __i386__ and defined CPUI386}
57 	{$setc __i386__ := 1}
58 {$elsec}
59 	{$setc __i386__ := 0}
60 {$endc}
61 {$ifc not defined __x86_64__ and defined CPUX86_64}
62 	{$setc __x86_64__ := 1}
63 {$elsec}
64 	{$setc __x86_64__ := 0}
65 {$endc}
66 {$ifc not defined __arm__ and defined CPUARM}
67 	{$setc __arm__ := 1}
68 {$elsec}
69 	{$setc __arm__ := 0}
70 {$endc}
71 {$ifc not defined __arm64__ and defined CPUAARCH64}
72   {$setc __arm64__ := 1}
73 {$elsec}
74   {$setc __arm64__ := 0}
75 {$endc}
76 
77 {$ifc defined cpu64}
78   {$setc __LP64__ := 1}
79 {$elsec}
80   {$setc __LP64__ := 0}
81 {$endc}
82 
83 
84 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
85 	{$error Conflicting definitions for __ppc__ and __i386__}
86 {$endc}
87 
88 {$ifc defined __ppc__ and __ppc__}
89 	{$setc TARGET_CPU_PPC := TRUE}
90 	{$setc TARGET_CPU_PPC64 := FALSE}
91 	{$setc TARGET_CPU_X86 := FALSE}
92 	{$setc TARGET_CPU_X86_64 := FALSE}
93 	{$setc TARGET_CPU_ARM := FALSE}
94 	{$setc TARGET_CPU_ARM64 := FALSE}
95 	{$setc TARGET_OS_MAC := TRUE}
96 	{$setc TARGET_OS_IPHONE := FALSE}
97 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
98 	{$setc TARGET_OS_EMBEDDED := FALSE}
99 {$elifc defined __ppc64__ and __ppc64__}
100 	{$setc TARGET_CPU_PPC := FALSE}
101 	{$setc TARGET_CPU_PPC64 := TRUE}
102 	{$setc TARGET_CPU_X86 := FALSE}
103 	{$setc TARGET_CPU_X86_64 := FALSE}
104 	{$setc TARGET_CPU_ARM := FALSE}
105 	{$setc TARGET_CPU_ARM64 := FALSE}
106 	{$setc TARGET_OS_MAC := TRUE}
107 	{$setc TARGET_OS_IPHONE := FALSE}
108 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
109 	{$setc TARGET_OS_EMBEDDED := FALSE}
110 {$elifc defined __i386__ and __i386__}
111 	{$setc TARGET_CPU_PPC := FALSE}
112 	{$setc TARGET_CPU_PPC64 := FALSE}
113 	{$setc TARGET_CPU_X86 := TRUE}
114 	{$setc TARGET_CPU_X86_64 := FALSE}
115 	{$setc TARGET_CPU_ARM := FALSE}
116 	{$setc TARGET_CPU_ARM64 := FALSE}
117 {$ifc defined iphonesim}
118  	{$setc TARGET_OS_MAC := FALSE}
119 	{$setc TARGET_OS_IPHONE := TRUE}
120 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
121 {$elsec}
122 	{$setc TARGET_OS_MAC := TRUE}
123 	{$setc TARGET_OS_IPHONE := FALSE}
124 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
125 {$endc}
126 	{$setc TARGET_OS_EMBEDDED := FALSE}
127 {$elifc defined __x86_64__ and __x86_64__}
128 	{$setc TARGET_CPU_PPC := FALSE}
129 	{$setc TARGET_CPU_PPC64 := FALSE}
130 	{$setc TARGET_CPU_X86 := FALSE}
131 	{$setc TARGET_CPU_X86_64 := TRUE}
132 	{$setc TARGET_CPU_ARM := FALSE}
133 	{$setc TARGET_CPU_ARM64 := FALSE}
134 {$ifc defined iphonesim}
135  	{$setc TARGET_OS_MAC := FALSE}
136 	{$setc TARGET_OS_IPHONE := TRUE}
137 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
138 {$elsec}
139 	{$setc TARGET_OS_MAC := TRUE}
140 	{$setc TARGET_OS_IPHONE := FALSE}
141 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
142 {$endc}
143 	{$setc TARGET_OS_EMBEDDED := FALSE}
144 {$elifc defined __arm__ and __arm__}
145 	{$setc TARGET_CPU_PPC := FALSE}
146 	{$setc TARGET_CPU_PPC64 := FALSE}
147 	{$setc TARGET_CPU_X86 := FALSE}
148 	{$setc TARGET_CPU_X86_64 := FALSE}
149 	{$setc TARGET_CPU_ARM := TRUE}
150 	{$setc TARGET_CPU_ARM64 := FALSE}
151 	{$setc TARGET_OS_MAC := FALSE}
152 	{$setc TARGET_OS_IPHONE := TRUE}
153 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
154 	{$setc TARGET_OS_EMBEDDED := TRUE}
155 {$elifc defined __arm64__ and __arm64__}
156 	{$setc TARGET_CPU_PPC := FALSE}
157 	{$setc TARGET_CPU_PPC64 := FALSE}
158 	{$setc TARGET_CPU_X86 := FALSE}
159 	{$setc TARGET_CPU_X86_64 := FALSE}
160 	{$setc TARGET_CPU_ARM := FALSE}
161 	{$setc TARGET_CPU_ARM64 := TRUE}
162 {$ifc defined ios}
163 	{$setc TARGET_OS_MAC := FALSE}
164 	{$setc TARGET_OS_IPHONE := TRUE}
165 	{$setc TARGET_OS_EMBEDDED := TRUE}
166 {$elsec}
167 	{$setc TARGET_OS_MAC := TRUE}
168 	{$setc TARGET_OS_IPHONE := FALSE}
169 	{$setc TARGET_OS_EMBEDDED := FALSE}
170 {$endc}
171 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
172 {$elsec}
173 	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
174 {$endc}
175 
176 {$ifc defined __LP64__ and __LP64__ }
177   {$setc TARGET_CPU_64 := TRUE}
178 {$elsec}
179   {$setc TARGET_CPU_64 := FALSE}
180 {$endc}
181 
182 {$ifc defined FPC_BIG_ENDIAN}
183 	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
184 	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
185 {$elifc defined FPC_LITTLE_ENDIAN}
186 	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
187 	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
188 {$elsec}
189 	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
190 {$endc}
191 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
192 {$setc CALL_NOT_IN_CARBON := FALSE}
193 {$setc OLDROUTINENAMES := FALSE}
194 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
195 {$setc OPAQUE_UPP_TYPES := TRUE}
196 {$setc OTCARBONAPPLICATION := TRUE}
197 {$setc OTKERNEL := FALSE}
198 {$setc PM_USE_SESSION_APIS := TRUE}
199 {$setc TARGET_API_MAC_CARBON := TRUE}
200 {$setc TARGET_API_MAC_OS8 := FALSE}
201 {$setc TARGET_API_MAC_OSX := TRUE}
202 {$setc TARGET_CARBON := TRUE}
203 {$setc TARGET_CPU_68K := FALSE}
204 {$setc TARGET_CPU_MIPS := FALSE}
205 {$setc TARGET_CPU_SPARC := FALSE}
206 {$setc TARGET_OS_UNIX := FALSE}
207 {$setc TARGET_OS_WIN32 := FALSE}
208 {$setc TARGET_RT_MAC_68881 := FALSE}
209 {$setc TARGET_RT_MAC_CFM := FALSE}
210 {$setc TARGET_RT_MAC_MACHO := TRUE}
211 {$setc TYPED_FUNCTION_POINTERS := TRUE}
212 {$setc TYPE_BOOL := FALSE}
213 {$setc TYPE_EXTENDED := FALSE}
214 {$setc TYPE_LONGLONG := TRUE}
215 uses MacTypes,CFBase,CFPlugIn,CFPlugInCOM,CFRunLoop,CFUUID,MIDIServices,MIDISetup,MIDIThruConnection;
216 {$endc} {not MACOSALLINCLUDE}
217 
218 
219 {$ifc TARGET_OS_MAC}
220 
221 {$ALIGN POWER}
222 
223 
224 {!
225 	@header MIDIDriver.h
226 
227 	This is the header file for Mac OS X's MIDI driver interface.
228 
229 	<h2>About MIDI drivers</h2>
230 	MIDI drivers are CFPlugIns, installed into the following places:
231 <pre>
232     /System/Library/Extensions      -- not recommended for non-Apple drivers, but
233                                     necessary for compatibility with CoreMIDI 1.0
234 
235     /Library/Audio/MIDI Drivers     -- starting with CoreMIDI 1.1
236 
237     ~/Library/Audio/MIDI Drivers    -- starting with CoreMIDI 1.1
238 </pre>
239 	Refer to the CFPlugIn documentation for more information about plug-ins.
240 
241 	<h2>Driver bundle/plug-in properties</h2>
242 	A driver's bundle settings should include settings resembling the following:
243 <pre>
244     Bundle settings:
245         CFBundleIdentifier              String          com.mycompany.midi.driver.mydevice
246             (note that this will be the driver's persistent ID in MIDISetup's)
247         CFPlugInDynamicRegistration     String          NO
248         CFPlugInFactories               Dictionary      1 key/value pair
249             [your new factory UUID]     String          [your factory function name]
250         CFPlugInTypes                   Dictionary      1 key/value pair
251             ECDE9574-0FE4-11D4-BB1A-0050E4CEA526        Array       1 object
252                 (this is kMIDIDriverTypeID)
253                 0                       String          [your new factory UUID]
254     Build settings:
255         WRAPPER_EXTENSION               plugin
256 </pre>
257 
258 	<h2>Driver access to the CoreMIDI API</h2>
259 	Drivers have access to most of the CoreMIDI API.  Starting in Mac OS X 10.6,
260 	drivers should link with CoreMIDI.framework. In previous versions of Mac OS X,
261 	drivers should link with CoreMIDIServer.framework, <b>not</b> CoreMIDI.framework.
262 
263 	On Mac OS X versions prior to 10.6, MIDI driver plugins linked against the
264 	CoreMIDIServer framework in order to access the CoreMIDI API. Drivers which
265 	are to run on earlier OS versions should be built 32-bit fat (ppc and i386)
266 	and link against CoreMIDIServer. Drivers which are to run on Mac OS X 10.6
267 	and later should be built for x86_64 and link against the CoreMIDI
268 	framework. Drivers which are to run on all versions of Mac OS X should be
269 	build 3-way fat (ppc, i386, and x86_64), with the ppc and i386 slices
270 	linking against CoreMIDIServer, and the x86_64 slice linking against
271 	CoreMIDI.
272 
273 	Unlike applications, drivers communicate with the server directly, not
274 	through Mach messaging.  This necessitates some limitations on the contexts from
275 	which a driver may call the server.
276 
277 	The MIDI I/O functions MIDISend and MIDIReceived may be called from any thread.
278 
279 	All other CoreMIDI functions must only be called from the server's main thread, which is the
280 	thread on which the driver is created and from which all calls to the driver other than
281 	Send() are made.
282 }
283 
284 
285 {!
286 	@typedef		MIDIDriverRef
287 
288 	@discussion		Points to a pointer to a MIDIDriverInterface, a CFPlugIn
289 					structure (defined in MIDIDriver.h) containing function
290 					pointers for the driver's methods.  Only the MIDIServer
291 					may call a driver's methods.
292 }
293 type
294 	MIDIDriverRef = ^MIDIDriverInterfacePtr;
295 	MIDIDriverInterfacePtr = ^MIDIDriverInterface;
296 
297 {!
298 	@typedef		MIDIDeviceListRef
299 
300 	@discussion		A MIDIDeviceListRef is a list of MIDIDeviceRef's.  The devices are
301 					not owned by the list (i.e., disposing the list does not dispose
302 					the devices it references).
303 }
304 //#if __LP64__
305 {$ifc TARGET_CPU_64}
306 	MIDIDeviceListRef = MIDIObjectRef;
307 {$elsec}
308 	MIDIDeviceListRef = ^OpaqueMIDIDeviceList; { an opaque type }
309 	OpaqueMIDIDeviceList = record end;
310 {$endc}
311 
312 {!
313 	@interface		MIDIDriverInterface
314 
315 	@abstract		The COM-style interface to a MIDI driver.
316 
317 	@discussion
318 		This is the function table interface to a MIDI driver.  Both version 1 and 2 drivers use
319 		this same table of function pointers (except as noted).
320 
321 		Drivers which support both the version 1 and version 2 interfaces can tell which version
322 		of the server is running by checking to see whether kMIDIDriverInterface2ID or
323 		kMIDIDriverInterfaceID is passed to the factory function.  If the version 1 interface is
324 		requested, the driver should behave as if it is a version 1 driver.
325 }
326 
327 	MIDIDriverInterface = record
328 		IUNKNOWN_C_GUTS	: IUnknownVTbl;
329 
330 
331 	{!
332 		@function FindDevices
333 		@discussion
334 			This is only called for version 1 drivers.  The server is requesting that the driver
335 			detect the devices which are present.  For each device present, the driver should
336 			create a MIDIDeviceRef with entities, using MIDIDeviceCreate and
337 			MIDIDeviceAddEntity, and add the device to the supplied MIDIDeviceListRef, using
338 			MIDIDeviceListAddDevice.
339 
340 			The driver should not retain any references to the created devices and entities.
341 	}
342 {	OSStatus	(*FindDevices)(MIDIDriverRef self, MIDIDeviceListRef devList); }
selfnull343 		FindDevices : function(_self : MIDIDriverRef; devList : MIDIDeviceListRef) : OSStatus;
344 
345 	{!
346 		@function Start
347 		@discussion
348 			The server is telling the driver to begin MIDI I/O.
349 
350 			The provided device list contains the devices which were previously located by
351 			FindDevices (in the case of a version 1 driver), or the devices which are owned by
352 			this driver and are currently in the current MIDISetup (for version 2 drivers).
353 
354 			The provided devices may or may not still be present.  A version 1 driver should
355 			attempt to use as many of the devices as are actually present.
356 
357 			A version 2 driver may make calls such as MIDISetupAddDevice, MIDIDeviceAddEntity,
358 			MIDIDeviceRemoveEntity to dynamically modify the system's current state. For devices
359 			in the provided device list which are not present, the driver should set their
360 			kMIDIPropertyOffline property to 1.  A version 2 driver may also set up
361 			notifications when the IORegistry changes, to detect connection and disconnection of
362 			devices it wishes to control.  At these times also, the driver may change the
363 			devices' kMIDIPropertyOffline, and dynamically modify the system's current state to
364 			reflect the devices which are present.  When passing a CFRunLoopRef to IOKit for
365 			notification purposes, the driver must use the server's main runloop, which is
366 			obtained with CFRunLoopGetCurrent().
367 
368 			The driver will probably want to iterate through the destination endpoints and
369 			assign their driver refCons, so as to identify multiple destinations when Send() is
370 			called.
371 
372 			The provided device list remains owned by the system and can be assumed to contain
373 			only devices owned by this driver.  The driver may retain references to the devices
374 			in this list and any it creates while running.
375 	}
376 {	OSStatus	(*Start)(MIDIDriverRef self, MIDIDeviceListRef devList); }
377 		Start : function(_self : MIDIDriverRef; devList : MIDIDeviceListRef) : OSStatus;
378 
379 	{!
380 		@function Stop
381 		@discussion
382 			The server is telling the driver to terminate MIDI I/O.  All I/O operations that
383 			were begun in Start, or as a result of a subsequent IOKit notification, should be
384 			terminated.
385 	}
386 {	OSStatus	(*Stop)(MIDIDriverRef self); }
387 		Stop : function(_self : MIDIDriverRef) : OSStatus;
388 
389 	{!
390 		@function Configure
391 		@discussion
392 			not currently used
393 	}
394 {	OSStatus	(*Configure)(MIDIDriverRef self, MIDIDeviceRef device); }
395 		Configure : function(_self : MIDIDriverRef; device : MIDIDeviceRef) : OSStatus;
396 
397 	{!
398 		@function Send
399 		@discussion
400 			Send a MIDIPacketList to the destination endpoint whose refCons are being passed as
401 			arguments.
402 	}
403 {	OSStatus	(*Send)(MIDIDriverRef self, const MIDIPacketList *pktlist, void *destRefCon1, void *destRefCon2); }
404 		Send : function(_self : MIDIDriverRef; pktList : MIDIPacketListPtr; destRefCon : UnivPtr; destRefCon2 : UnivPtr) : OSStatus;
405 
406 	{!
407 		@function EnableSource
408 		@discussion
409 			A client has opened or closed a connection, and now the server is telling the driver
410 			that input from a particular source either does or does not have any listeners in
411 			the system.  The driver may use this information to decide whether to pass messages
412 			from the source to the server, and it may even be able to tell the source hardware
413 			not to generate incoming MIDI I/O for that source.
414 	}
415 {	OSStatus	(*EnableSource)(MIDIDriverRef self, MIDIEndpointRef src, Boolean enabled); }
416 		EnableSource : function(_self : MIDIDriverRef; src : MIDIEndpointRef; enabled : Boolean) : OSStatus;
417 
418 	{!
419 		@function Flush
420 		@discussion
421 			Only for version 2 drivers (new for CoreMIDI 1.1).
422 
423 			Drivers which support schedule-ahead, when receiving this message, should unschedule
424 			all pending output to the specified destination.  If the destination is null, the
425 			driver should unschedule all pending output to all destinations.
426 	}
427 {	OSStatus	(*Flush)(MIDIDriverRef self, MIDIEndpointRef dest, void *destRefCon1, void *destRefCon2); }
428 		flush : function(_self : MIDIDriverRef; dest : MIDIEndpointRef; destRefCon1 : UnivPtr; destRefCon2 : UnivPtr) : OSStatus;
429 
430 
431 	{!
432 		@function Monitor
433 		@discussion
434 			Only for version 2 drivers (new for CoreMIDI 1.1).
435 
436 			Some specialized drivers (e.g. a MIDI monitor display) may wish to intercept and
437 			look at all outgoing MIDI messages.  After a driver calls
438 			MIDIDriverEnableMonitoring(true) on itself, this function is called with the
439 			outgoing MIDI packets for all destinations in the system.  The Monitor function
440 			cannot rely on the MIDI events arriving in order, due to MIDIServer's schedule-ahead
441 			facilities.
442 	}
443 {	OSStatus	(*Monitor)(MIDIDriverRef self, MIDIEndpointRef dest, const MIDIPacketList *pktlist); }
444 		Monitor : function(_self : MIDIDriverRef; dest : MIDIEndpointRef; pktList : MIDIPacketListPtr) : OSStatus;
445 	end;
446 
447 
448 //  -----------------------------------------------------------------------------
449 {!
450 	@define			kMIDIDriverTypeID
451 
452 	@abstract		The UUID for MIDI driver plugins.
453 
454 	@discussion		kMIDIDriverTypeID should be entered into your driver's bundle settings
455 					as follows:
456 
457 <pre>
458 CFPlugInTypes                   Dictionary      1 key/value pair
459 	ECDE9574-0FE4-11D4-BB1A-0050E4CEA526        Array       1 object
460 		(this is kMIDIDriverTypeID)
461 		0                       String          [your new factory UUID]
462 </pre>
463 }
464 {
465 #define kMIDIDriverTypeID \
466 	CFUUIDGetConstantUUIDWithBytes(NULL, 0xEC, 0xDE, 0x95, 0x74, 0x0F, 0xE4, 0x11, 0xD4, 0xBB, 0x1A, 0x00, 0x50, 0xE4, 0xCE, 0xA5, 0x26)
467 ( ECDE9574-0FE4-11D4-BB1A-0050E4CEA526 )
468 }
469 function kMIDIDriverTypeID : CFUUIDRef; inline;
470 
471 
472 {!
473 	@define			kMIDIDriverInterfaceID
474 
475 	@abstract		The UUID for version 1 of the MIDI driver interface.
476 
477 	@discussion		See the description of the MIDIDriverInterface structure for
478 					information about different versions of the MIDI driver interface.
479 }
480 {
481 #define kMIDIDriverInterfaceID \
482 	CFUUIDGetConstantUUIDWithBytes(NULL, 0x49, 0xDF, 0xCA, 0x9E, 0x0F, 0xE5, 0x11, 0xD4, 0x95, 0x0D, 0x00, 0x50, 0xE4, 0xCE, 0xA5, 0x26)
483 ( 49DFCA9E-0FE5-11D4-950D-0050E4CEA526 )
484 }
485 function kMIDIDriverInterfaceID : CFUUIDRef; inline;
486 
487 {!
488 	@define			kMIDIDriverInterface2ID
489 
490 	@abstract		The UUID for version 2 of the MIDI driver interface.
491 
492 	@discussion		See the description of the MIDIDriverInterface structure for
493 					information about different versions of the MIDI driver interface.
494 
495 					The version 2 driver interface is available beginning with CoreMIDI 1.1.
496 }
497 {
498 #define kMIDIDriverInterface2ID \
499 	CFUUIDGetConstantUUIDWithBytes(NULL, 0x43, 0xC9, 0x8C, 0x3C, 0x30, 0x6C, 0x11, 0xD5, 0xAF, 0x73, 0x00, 0x30, 0x65, 0xA8, 0x30, 0x1E)
500 ( 43C98C3C-306C-11D5-AF73-003065A8301E )
501 }
502 function kMIDIDriverInterface2ID : CFUUIDRef; inline;
503 
504 {!
505 	@constant		kMIDIDriverPropertyUsesSerial
506 
507 	@discussion		This constant, "MIDIDriverUsesSerial", when defined to "YES" in a driver's
508 					bundle, tells MIDIServer that the driver uses serial ports and is eligible to
509 					have serial ports assigned to it.
510 
511 					When a serial driver's Start() method is called, it should use
512 					MIDIGetSerialPortOwner to discover which serial ports it has
513 					been assigned to use, and only use those ports.
514 
515 					New for CoreMIDI 1.1.
516 }
517 var kMIDIDriverPropertyUsesSerial: CFStringRef; external name '_kMIDIDriverPropertyUsesSerial'; (* attribute const *)
518 
519 
520 // ___________________________________________________________________________________________
521 //	MIDIDevice
522 // ___________________________________________________________________________________________
523 
524 //  -----------------------------------------------------------------------------
525 {!
526 	@function		MIDIDeviceCreate
527 
528 	@discussion		Drivers call this function to create new MIDIDevice objects
529 					corresponding to the hardware that is present.
530 
531 					Non-drivers may call this function as of CoreMIDI 1.1, to
532 					create external devices.
533 
534 	@param			owner
535 						The driver creating the device.  NULL if a non-driver.
536 	@param			name
537 						The name of the new device.
538 	@param			manufacturer
539 						The name of the device's manufacturer.
540 	@param			model
541 						The device's model name.
542 	@param			outDevice
543 						On successful return, points to the newly-created device.
544 	@result			An OSStatus result code.
545 }
546 function MIDIDeviceCreate( owner: MIDIDriverRef; name: CFStringRef; manufacturer: CFStringRef; model: CFStringRef; var outDevice: MIDIDeviceRef ): OSStatus; external name '_MIDIDeviceCreate';
547 (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
548 
549 
550 {!
551 	@function		MIDIDeviceDispose
552 
553 	@discussion		Drivers may call this function to dispose MIDIDevice objects
554 					which have not yet been added to the system via MIDISetupAddDevice.
555 					Once a device has been added to the system with MIDISetupAddDevice,
556 					the driver must not use this call to destroy it; it must
557 					use MIDISetupRemoveDevice to do so.
558 
559 					Non-drivers do not have access to this function; they must call
560 					MIDISetupAddDevice and MIDISetupRemoveDevice.
561 
562 	@param			device
563 						The device to be disposed.
564 	@result			An OSStatus result code.
565 }
566 function MIDIDeviceDispose( device: MIDIDeviceRef ): OSStatus; external name '_MIDIDeviceDispose';
567 (* __OSX_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_NA) *)
568 
569 // ___________________________________________________________________________________________
570 //	MIDIDeviceList
571 // ___________________________________________________________________________________________
572 
573 //  -----------------------------------------------------------------------------
574 {!
575 	@function		MIDIDeviceListGetNumberOfDevices
576 
577 	@discussion		Returns the number of devices in a device list.
578 
579 	@param			devList
580 						The device list.
581 	@result			The number of devices in the list, or 0 if an error occurred.
582 }
583 function MIDIDeviceListGetNumberOfDevices( devList: MIDIDeviceListRef ): ItemCount; external name '_MIDIDeviceListGetNumberOfDevices';
584 (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
585 
586 //  -----------------------------------------------------------------------------
587 {!
588 	@function		MIDIDeviceListGetDevice
589 
590 	@discussion		Return one of the devices in a device list.
591 
592 	@param			devList
593 						The device list.
594 	@param			deviceIndex0
595 						The index (0...MIDIDeviceListGetNumberOfDevices()-1) of the device
596 						to return.
597 	@result			A reference to a device, or NULL if an error occurred.
598 }
599 function MIDIDeviceListGetDevice( devList: MIDIDeviceListRef; index0: ItemCount ): MIDIDeviceRef; external name '_MIDIDeviceListGetDevice';
600 (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
601 
602 //  -----------------------------------------------------------------------------
603 {!
604 	@function		MIDIDeviceListAddDevice
605 
606 	@discussion		Add a device to a device list.
607 
608 	@param			devList
609 						The device list.
610 	@param			dev
611 						The device to add to the list.
612 	@result			An OSStatus result code.
613 }
614 function MIDIDeviceListAddDevice( devList: MIDIDeviceListRef; dev: MIDIDeviceRef ): OSStatus; external name '_MIDIDeviceListAddDevice';
615 (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
616 
617 //  -----------------------------------------------------------------------------
618 {!
619 	@function		MIDIDeviceListDispose
620 
621 	@discussion		Dispose a device list, but not the contained devices.
622 
623 	@param			devList
624 						The device list to be disposed.
625 	@result			An OSStatus result code.
626 }
627 function MIDIDeviceListDispose( devList: MIDIDeviceListRef ): OSStatus; external name '_MIDIDeviceListDispose';
628 (* __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_NA) *)
629 
630 
631 // ___________________________________________________________________________________________
632 //	MIDIEndpoint
633 // ___________________________________________________________________________________________
634 
635 //  -----------------------------------------------------------------------------
636 {!
637 	@function		MIDIEndpointSetRefCons
638 
639 	@discussion		Drivers need an efficient way to translate from a MIDIEndpoint (source or
640 					destination) to their own internal data structures corresponding to
641 					that endpoint.  This function provides a way for the driver to
642 					assign its own refCons to endpoints.
643 
644 					These refCons are passed back to the driver in its Send() and Flush()
645 					methods.
646 
647 					RefCons are not persistent (i.e. they are not saved as part of a
648 					MIDISetup).  They need to be re-initialized in each call to Start().
649 
650 					A typical use is to use one refCon to refer to a device, and a second
651 					to refer to a port on the device.
652 
653 	@param			endpt
654 						The endpoint whose refCons are to be set
655 	@param			ref1
656 						The first refCon.
657 	@param			ref2
658 						The second refCon.
659 	@result			An OSStatus result code.
660 }
661 function MIDIEndpointSetRefCons( endpt: MIDIEndpointRef; ref1: UnivPtr; ref2: UnivPtr ): OSStatus; external name '_MIDIEndpointSetRefCons';
662 (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
663 
664 //  -----------------------------------------------------------------------------
665 {!
666 	@function		MIDIEndpointGetRefCons
667 
668 	@discussion		Obtain the refCons assigned to the endpoints
669 
670 	@param			endpt
671 						The endpoint whose refCons are to be return
672 	@param			ref1
673 						On exit, the first refCon.
674 	@param			ref2
675 						On exit, the second refCon.
676 	@result			An OSStatus result code.
677 }
678 function MIDIEndpointGetRefCons( endpt: MIDIEndpointRef; ref1: UnivPtrPtr; ref2: UnivPtrPtr ): OSStatus; external name '_MIDIEndpointGetRefCons';
679 (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
680 
681 // ___________________________________________________________________________________________
682 
683 //  -----------------------------------------------------------------------------
684 {!
685 	@function		MIDIGetDriverIORunLoop
686 
687 	@discussion		Drivers typically need to receive asynchronous I/O completion callbacks
688 					on a high-priority thread.  To save drivers from the trouble of
689 					creating their own threads for this purpose, and to make efficient
690 					use of system resources, the MIDIServer provides a thread which
691 					drivers may use.
692 
693 					Drivers should do as little work as possible in this thread; typically,
694 					just dequeueing and encoding output packets, and decoding input packets
695 					into MIDIPacketLists to be passed to MIDIReceived.
696 
697 					This is a realtime-priority thread and shouldn't be used for anything other
698 					than I/O.  For lower-priority tasks, drivers can use the runloop which
699 					was current when they were constructed.
700 
701 	@result			The CFRunLoopRef of the server's driver I/O thread.
702 }
MIDIGetDriverIORunLoopnull703 function MIDIGetDriverIORunLoop: CFRunLoopRef; external name '_MIDIGetDriverIORunLoop';
704 (* __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA) *)
705 
706 //  -----------------------------------------------------------------------------
707 {!
708 	@function		MIDIGetDriverDeviceList
709 
710 	@discussion		Returns the list of devices which are in the current MIDISetup
711 					and which were created/owned by the specified driver.
712 
713 					The returned device list should be disposed (using MIDIDeviceListDispose)
714 					by the caller.
715 
716 	@param			driver
717 						The driver whose devices are to be returned.
718 
719 	@result			The requested device list.
720 }
MIDIGetDriverDeviceListnull721 function MIDIGetDriverDeviceList( driver: MIDIDriverRef ): MIDIDeviceListRef; external name '_MIDIGetDriverDeviceList';
722 (* __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_NA) *)
723 
724 //  -----------------------------------------------------------------------------
725 {!
726 	@function		MIDIDriverEnableMonitoring
727 
728 	@discussion		A driver may make this call to have MIDIServer pass it every outgoing MIDI
729 					packet, to all destinations in the system (not just those controlled by
730 					itself).
731 
732 	@param			driver
733 						The driver whose Monitor function is to be enabled.
734 	@param			enabled
735 						true to enable monitoring, false to disable it.
736 
737 	@result			An OSStatus result code.
738 }
MIDIDriverEnableMonitoringnull739 function MIDIDriverEnableMonitoring( driver: MIDIDriverRef; enabled: Boolean ): OSStatus; external name '_MIDIDriverEnableMonitoring';
740 (* __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_NA) *)
741 
742 {$endc} { TARGET_OS_MAC }
743 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
744 implementation
745 
746 {$ifc TARGET_OS_MAC}
747 
748 
kMIDIDriverTypeIDnull749 function kMIDIDriverTypeID : CFUUIDRef; inline;
750 begin
751 	kMIDIDriverTypeID := CFUUIDGetConstantUUIDWithBytes(nil, $EC, $DE, $95, $74, $0F, $E4, $11, $D4, $BB, $1A, $00, $50, $E4, $CE, $A5, $26)
752 end;
753 
kMIDIDriverInterfaceIDnull754 function kMIDIDriverInterfaceID : CFUUIDRef; inline;
755 begin
756 	kMIDIDriverInterfaceID := CFUUIDGetConstantUUIDWithBytes(nil, $49, $DF, $CA, $9E, $0F, $E5, $11, $D4, $95, $0D, $00, $50, $E4, $CE, $A5, $26)
757 end;
758 
kMIDIDriverInterface2IDnull759 function kMIDIDriverInterface2ID : CFUUIDRef; inline;
760 begin
761 	kMIDIDriverInterface2ID := CFUUIDGetConstantUUIDWithBytes(nil, $43, $C9, $8C, $3C, $30, $6C, $11, $D5, $AF, $73, $00, $30, $65, $A8, $30, $1E)
762 end;
763 {$endc}
764 end.
765 
766 {$endc} {not MACOSALLINCLUDE}
767