MIDIDriver.pas 27 KB

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