jack.pp 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519
  1. (*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004 Jack O'Quin
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. *)
  16. {$IFNDEF FPC_DOTTEDUNITS}
  17. unit jack;
  18. {$ENDIF FPC_DOTTEDUNITS}
  19. interface
  20. {$packrecords C}
  21. uses
  22. {$IFDEF FPC_DOTTEDUNITS}
  23. System.CTypes;
  24. {$ELSE FPC_DOTTEDUNITS}
  25. ctypes;
  26. {$ENDIF FPC_DOTTEDUNITS}
  27. const
  28. {$if defined(win32)}
  29. libjack = 'libjack';
  30. {$elseif defined(win64)}
  31. libjack = 'libjack64';
  32. {$else}
  33. libjack = 'jack';
  34. {$endif}
  35. type
  36. uint64_t = System.UInt64;
  37. uint32_t = System.UInt32;
  38. int32_t = System.Int32;
  39. {$ifndef __jack_h__}
  40. {$define __jack_h__}
  41. //#ifdef __cplusplus
  42. //extern "C"
  43. //{
  44. //#endif
  45. //#include <jack/systemdeps.h>
  46. {$I systemdeps.inc}
  47. //#include <jack/types.h>
  48. {$I types.inc}
  49. //#include <jack/transport.h>
  50. {$I transport.inc}
  51. (**
  52. * Note: More documentation can be found in jack/types.h.
  53. *)
  54. (*************************************************************
  55. * NOTE: JACK_WEAK_EXPORT ***MUST*** be used on every function
  56. * added to the JACK API after the 0.116.2 release.
  57. *
  58. * Functions that predate this release are marked with
  59. * JACK_WEAK_OPTIONAL_EXPORT which can be defined at compile
  60. * time in a variety of ways. The default definition is empty,
  61. * so that these symbols get normal linkage. If you wish to
  62. * use all JACK symbols with weak linkage, include
  63. * <jack/weakjack.h> before jack.h.
  64. *************************************************************)
  65. //#include <jack/weakmacros.h>
  66. {$I weakmacros.inc}
  67. (**
  68. * Call this function to get version of the JACK, in form of several numbers
  69. *
  70. * @param major_ptr pointer to variable receiving major version of JACK.
  71. *
  72. * @param minor_ptr pointer to variable receiving minor version of JACK.
  73. *
  74. * @param major_ptr pointer to variable receiving micro version of JACK.
  75. *
  76. * @param major_ptr pointer to variable receiving protocol version of JACK.
  77. *
  78. *)
  79. procedure
  80. jack_get_version(
  81. major_ptr: Pcint;
  82. minor_ptr: Pcint;
  83. micro_ptr: Pcint;
  84. proto_ptr: Pcint); cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  85. (**
  86. * Call this function to get version of the JACK, in form of a string
  87. *
  88. * @return Human readable string describing JACK version being used.
  89. *
  90. *)
  91. function
  92. jack_get_version_string: PChar; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  93. (**
  94. * @defgroup ClientFunctions Creating & manipulating clients
  95. * @{
  96. *)
  97. (**
  98. * Open an external client session with a JACK server. This interface
  99. * is more complex but more powerful than jack_client_new(). With it,
  100. * clients may choose which of several servers to connect, and control
  101. * whether and how to start the server automatically, if it was not
  102. * already running. There is also an option for JACK to generate a
  103. * unique client name, when necessary.
  104. *
  105. * @param client_name of at most jack_client_name_size() characters.
  106. * The name scope is local to each server. Unless forbidden by the
  107. * @ref JackUseExactName option, the server will modify this name to
  108. * create a unique variant, if needed.
  109. *
  110. * @param options formed by OR-ing together @ref JackOptions bits.
  111. * Only the @ref JackOpenOptions bits are allowed.
  112. *
  113. * @param status (if non-NULL) an address for JACK to return
  114. * information from the open operation. This status word is formed by
  115. * OR-ing together the relevant @ref JackStatus bits.
  116. *
  117. *
  118. * <b>Optional parameters:</b> depending on corresponding [@a options
  119. * bits] additional parameters may follow @a status (in this order).
  120. *
  121. * @arg [@ref JackServerName] <em>(char * ) server_name</em> selects
  122. * from among several possible concurrent server instances. Server
  123. * names are unique to each user. If unspecified, use "default"
  124. * unless \$JACK_DEFAULT_SERVER is defined in the process environment.
  125. *
  126. * @return Opaque client handle if successful. If this is NULL, the
  127. * open operation failed, @a *status includes @ref JackFailure and the
  128. * caller is not a JACK client.
  129. *)
  130. function jack_client_open (const client_name: PChar;
  131. options: jack_options_t;
  132. status: Pjack_status_t): Pjack_client_t; varargs; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  133. (**
  134. * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
  135. * NEW JACK CLIENTS
  136. *
  137. * @deprecated Please use jack_client_open().
  138. *)
  139. function jack_client_new (const client_name: PChar): Pjack_client_t; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  140. (**
  141. * Disconnects an external client from a JACK server.
  142. *
  143. * @return 0 on success, otherwise a non-zero error code
  144. *)
  145. function jack_client_close (client: Pjack_client_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  146. (**
  147. * @return the maximum number of characters in a JACK client name
  148. * including the final NULL character. This value is a constant.
  149. *)
  150. function jack_client_name_size: cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  151. (**
  152. * @return pointer to actual client name. This is useful when @ref
  153. * JackUseExactName is not specified on open and @ref
  154. * JackNameNotUnique status was returned. In that case, the actual
  155. * name will differ from the @a client_name requested.
  156. *)
  157. function jack_get_client_name (client: Pjack_client_t): PChar; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  158. (**
  159. * Get the session ID for a client name.
  160. *
  161. * The session manager needs this to reassociate a client name to the session_id.
  162. *
  163. * The caller is responsible for calling jack_free(3) on any non-NULL
  164. * returned value.
  165. *)
  166. function jack_get_uuid_for_client_name (client: Pjack_client_t;
  167. const client_name: PChar): PChar; cdecl; JACK_WEAK_EXPORT;
  168. (**
  169. * Get the client name for a session_id.
  170. *
  171. * In order to snapshot the graph connections, the session manager needs to map
  172. * session_ids to client names.
  173. *
  174. * The caller is responsible for calling jack_free(3) on any non-NULL
  175. * returned value.
  176. *)
  177. function jack_get_client_name_by_uuid (client: Pjack_client_t;
  178. const client_uuid: PChar): PChar; cdecl; JACK_WEAK_EXPORT;
  179. (**
  180. * Load an internal client into the Jack server.
  181. *
  182. * Internal clients run inside the JACK server process. They can use
  183. * most of the same functions as external clients. Each internal
  184. * client must declare jack_initialize() and jack_finish() entry
  185. * points, called at load and unload times. See inprocess.c for an
  186. * example of how to write an internal client.
  187. *
  188. * @deprecated Please use jack_internal_client_load().
  189. *
  190. * @param client_name of at most jack_client_name_size() characters.
  191. *
  192. * @param load_name of a shared object file containing the code for
  193. * the new client.
  194. *
  195. * @param load_init an arbitrary string passed to the jack_initialize()
  196. * routine of the new client (may be NULL).
  197. *
  198. * @return 0 if successful.
  199. *)
  200. function jack_internal_client_new (const client_name: PChar;
  201. const load_name: PChar;
  202. const load_init: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  203. (**
  204. * Remove an internal client from a JACK server.
  205. *
  206. * @deprecated Please use jack_internal_client_unload().
  207. *)
  208. procedure jack_internal_client_close (const client_name: PChar); cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  209. (**
  210. * Tell the Jack server that the program is ready to start processing
  211. * audio.
  212. *
  213. * @return 0 on success, otherwise a non-zero error code
  214. *)
  215. function jack_activate (client: Pjack_client_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  216. (**
  217. * Tell the Jack server to remove this @a client from the process
  218. * graph. Also, disconnect all ports belonging to it, since inactive
  219. * clients have no port connections.
  220. *
  221. * @return 0 on success, otherwise a non-zero error code
  222. *)
  223. function jack_deactivate (client: Pjack_client_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  224. (**
  225. * @return pid of client. If not available, 0 will be returned.
  226. *)
  227. function jack_get_client_pid (const name: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  228. (**
  229. * @return the pthread ID of the thread running the JACK client side
  230. * real-time code.
  231. *)
  232. function jack_client_thread_id (client: Pjack_client_t): jack_native_thread_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  233. ///**@}*/
  234. (**
  235. * @param client pointer to JACK client structure.
  236. *
  237. * Check if the JACK subsystem is running with -R (--realtime).
  238. *
  239. * @return 1 if JACK is running realtime, 0 otherwise
  240. *)
  241. function jack_is_realtime (client: Pjack_client_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  242. (**
  243. * @defgroup NonCallbackAPI The non-callback API
  244. * @{
  245. *)
  246. (**
  247. * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
  248. * NEW JACK CLIENTS.
  249. *
  250. * @deprecated Please use jack_cycle_wait() and jack_cycle_signal() functions.
  251. *)
  252. function jack_thread_wait (client: Pjack_client_t; status: cint): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  253. (**
  254. * Wait until this JACK client should process data.
  255. *
  256. * @param client - pointer to a JACK client structure
  257. *
  258. * @return the number of frames of data to process
  259. *)
  260. function jack_cycle_wait (client: Pjack_client_t): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  261. (**
  262. * Signal next clients in the graph.
  263. *
  264. * @param client - pointer to a JACK client structure
  265. * @param status - if non-zero, calling thread should exit
  266. *)
  267. procedure jack_cycle_signal (client: Pjack_client_t; status: cint); cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  268. (**
  269. * Tell the Jack server to call @a thread_callback in the RT thread.
  270. * Typical use are in conjunction with @a jack_cycle_wait and @a jack_cycle_signal functions.
  271. * The code in the supplied function must be suitable for real-time
  272. * execution. That means that it cannot call functions that might
  273. * block for a long time. This includes malloc, free, printf,
  274. * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
  275. * pthread_cond_wait, etc, etc. See
  276. * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
  277. * for more information.
  278. *
  279. * NOTE: this function cannot be called while the client is activated
  280. * (after jack_activate has been called.)
  281. *
  282. * @return 0 on success, otherwise a non-zero error code.
  283. *)
  284. function jack_set_process_thread(client: Pjack_client_t; thread_callback: TJackThreadCallback; arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  285. ///**@}*/
  286. (**
  287. * @defgroup ClientCallbacks Setting Client Callbacks
  288. * @{
  289. *)
  290. (**
  291. * Tell JACK to call @a thread_init_callback once just after
  292. * the creation of the thread in which all other callbacks
  293. * will be handled.
  294. *
  295. * The code in the supplied function does not need to be
  296. * suitable for real-time execution.
  297. *
  298. * NOTE: this function cannot be called while the client is activated
  299. * (after jack_activate has been called.)
  300. *
  301. * @return 0 on success, otherwise a non-zero error code, causing JACK
  302. * to remove that client from the process() graph.
  303. *)
  304. function jack_set_thread_init_callback (client: Pjack_client_t;
  305. thread_init_callback: TJackThreadInitCallback;
  306. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  307. (**
  308. * @param client pointer to JACK client structure.
  309. * @param function The jack_shutdown function pointer.
  310. * @param arg The arguments for the jack_shutdown function.
  311. *
  312. * Register a function (and argument) to be called if and when the
  313. * JACK server shuts down the client thread. The function must
  314. * be written as if it were an asynchonrous POSIX signal
  315. * handler --- use only async-safe functions, and remember that it
  316. * is executed from another thread. A typical function might
  317. * set a flag or write to a pipe so that the rest of the
  318. * application knows that the JACK client thread has shut
  319. * down.
  320. *
  321. * NOTE: clients do not need to call this. It exists only
  322. * to help more complex clients understand what is going
  323. * on. It should be called before jack_client_activate().
  324. *
  325. * NOTE: if a client calls this AND jack_on_info_shutdown(), then
  326. * in case of a client thread shutdown, the callback
  327. * passed to this function will not be called, and the one passed to
  328. * jack_on_info_shutdown() will.
  329. *
  330. * NOTE: application should typically signal another thread to correctly
  331. * finish cleanup, that is by calling "jack_client_close"
  332. * (since "jack_client_close" cannot be called directly in the context
  333. * of the thread that calls the shutdown callback).
  334. *)
  335. procedure jack_on_shutdown (client: Pjack_client_t;
  336. shutdown_callback: TJackShutdownCallback; arg: Pointer); cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  337. (**
  338. * @param client pointer to JACK client structure.
  339. * @param function The jack_info_shutdown function pointer.
  340. * @param arg The arguments for the jack_info_shutdown function.
  341. *
  342. * Register a function (and argument) to be called if and when the
  343. * JACK server shuts down the client thread. The function must
  344. * be written as if it were an asynchonrous POSIX signal
  345. * handler --- use only async-safe functions, and remember that it
  346. * is executed from another thread. A typical function might
  347. * set a flag or write to a pipe so that the rest of the
  348. * application knows that the JACK client thread has shut
  349. * down.
  350. *
  351. * NOTE: clients do not need to call this. It exists only
  352. * to help more complex clients understand what is going
  353. * on. It should be called before jack_client_activate().
  354. *
  355. * NOTE: if a client calls this AND jack_on_shutdown(), then
  356. * in case of a client thread shutdown, the callback passed to
  357. * jack_on_info_shutdown() will be called.
  358. *
  359. * NOTE: application should typically signal another thread to correctly
  360. * finish cleanup, that is by calling "jack_client_close"
  361. * (since "jack_client_close" cannot be called directly in the context
  362. * of the thread that calls the shutdown callback).
  363. *)
  364. procedure jack_on_info_shutdown (client: Pjack_client_t;
  365. shutdown_callback: TJackInfoShutdownCallback; arg: Pointer); cdecl; JACK_WEAK_EXPORT;
  366. (**
  367. * Tell the Jack server to call @a process_callback whenever there is
  368. * work be done, passing @a arg as the second argument.
  369. *
  370. * The code in the supplied function must be suitable for real-time
  371. * execution. That means that it cannot call functions that might
  372. * block for a long time. This includes malloc, free, printf,
  373. * pthread_mutex_lock, sleep, wait, poll, select, pthread_join,
  374. * pthread_cond_wait, etc, etc. See
  375. * http://jackit.sourceforge.net/docs/design/design.html#SECTION00411000000000000000
  376. * for more information.
  377. *
  378. * NOTE: this function cannot be called while the client is activated
  379. * (after jack_activate has been called.)
  380. *
  381. * @return 0 on success, otherwise a non-zero error code.
  382. *)
  383. function jack_set_process_callback (client: Pjack_client_t;
  384. process_callback: TJackProcessCallback;
  385. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  386. (**
  387. * Tell the Jack server to call @a freewheel_callback
  388. * whenever we enter or leave "freewheel" mode, passing @a
  389. * arg as the second argument. The first argument to the
  390. * callback will be non-zero if JACK is entering freewheel
  391. * mode, and zero otherwise.
  392. *
  393. * All "notification events" are received in a separated non RT thread,
  394. * the code in the supplied function does not need to be
  395. * suitable for real-time execution.
  396. *
  397. * NOTE: this function cannot be called while the client is activated
  398. * (after jack_activate has been called.)
  399. *
  400. * @return 0 on success, otherwise a non-zero error code.
  401. *)
  402. function jack_set_freewheel_callback (client: Pjack_client_t;
  403. freewheel_callback: TJackFreewheelCallback;
  404. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  405. (**
  406. * Tell JACK to call @a bufsize_callback whenever the size of the the
  407. * buffer that will be passed to the @a process_callback is about to
  408. * change. Clients that depend on knowing the buffer size must supply
  409. * a @a bufsize_callback before activating themselves.
  410. *
  411. * All "notification events" are received in a separated non RT thread,
  412. * the code in the supplied function does not need to be
  413. * suitable for real-time execution.
  414. *
  415. * NOTE: this function cannot be called while the client is activated
  416. * (after jack_activate has been called.)
  417. *
  418. * @param client pointer to JACK client structure.
  419. * @param bufsize_callback function to call when the buffer size changes.
  420. * @param arg argument for @a bufsize_callback.
  421. *
  422. * @return 0 on success, otherwise a non-zero error code
  423. *)
  424. function jack_set_buffer_size_callback (client: Pjack_client_t;
  425. bufsize_callback: TJackBufferSizeCallback;
  426. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  427. (**
  428. * Tell the Jack server to call @a srate_callback whenever the system
  429. * sample rate changes.
  430. *
  431. * All "notification events" are received in a separated non RT thread,
  432. * the code in the supplied function does not need to be
  433. * suitable for real-time execution.
  434. *
  435. * NOTE: this function cannot be called while the client is activated
  436. * (after jack_activate has been called.)
  437. *
  438. * @return 0 on success, otherwise a non-zero error code
  439. *)
  440. function jack_set_sample_rate_callback (client: Pjack_client_t;
  441. srate_callback: TJackSampleRateCallback;
  442. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  443. (**
  444. * Tell the JACK server to call @a client_registration_callback whenever a
  445. * client is registered or unregistered, passing @a arg as a parameter.
  446. *
  447. * All "notification events" are received in a separated non RT thread,
  448. * the code in the supplied function does not need to be
  449. * suitable for real-time execution.
  450. *
  451. * NOTE: this function cannot be called while the client is activated
  452. * (after jack_activate has been called.)
  453. *
  454. * @return 0 on success, otherwise a non-zero error code
  455. *)
  456. function jack_set_client_registration_callback (client: Pjack_client_t;
  457. registration_callback: TJackClientRegistrationCallback;
  458. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  459. (**
  460. * Tell the JACK server to call @a registration_callback whenever a
  461. * port is registered or unregistered, passing @a arg as a parameter.
  462. *
  463. * All "notification events" are received in a separated non RT thread,
  464. * the code in the supplied function does not need to be
  465. * suitable for real-time execution.
  466. *
  467. * NOTE: this function cannot be called while the client is activated
  468. * (after jack_activate has been called.)
  469. *
  470. * @return 0 on success, otherwise a non-zero error code
  471. *)
  472. function jack_set_port_registration_callback (client: Pjack_client_t;
  473. registration_callback: TJackPortRegistrationCallback;
  474. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  475. (**
  476. * Tell the JACK server to call @a connect_callback whenever a
  477. * port is connected or disconnected, passing @a arg as a parameter.
  478. *
  479. * All "notification events" are received in a separated non RT thread,
  480. * the code in the supplied function does not need to be
  481. * suitable for real-time execution.
  482. *
  483. * NOTE: this function cannot be called while the client is activated
  484. * (after jack_activate has been called.)
  485. *
  486. * @return 0 on success, otherwise a non-zero error code
  487. *)
  488. function jack_set_port_connect_callback (client: Pjack_client_t;
  489. connect_callback: TJackPortConnectCallback;
  490. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  491. (**
  492. * Tell the JACK server to call @a rename_callback whenever a
  493. * port is renamed, passing @a arg as a parameter.
  494. *
  495. * All "notification events" are received in a separated non RT thread,
  496. * the code in the supplied function does not need to be
  497. * suitable for real-time execution.
  498. *
  499. * NOTE: this function cannot be called while the client is activated
  500. * (after jack_activate has been called.)
  501. *
  502. * @return 0 on success, otherwise a non-zero error code
  503. *)
  504. function jack_set_port_rename_callback (client: Pjack_client_t;
  505. rename_callback: TJackPortRenameCallback;
  506. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  507. (**
  508. * Tell the JACK server to call @a graph_callback whenever the
  509. * processing graph is reordered, passing @a arg as a parameter.
  510. *
  511. * All "notification events" are received in a separated non RT thread,
  512. * the code in the supplied function does not need to be
  513. * suitable for real-time execution.
  514. *
  515. * NOTE: this function cannot be called while the client is activated
  516. * (after jack_activate has been called.)
  517. *
  518. * @return 0 on success, otherwise a non-zero error code
  519. *)
  520. function jack_set_graph_order_callback (client: Pjack_client_t;
  521. graph_callback: TJackGraphOrderCallback;
  522. arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  523. (**
  524. * Tell the JACK server to call @a xrun_callback whenever there is a
  525. * xrun, passing @a arg as a parameter.
  526. *
  527. * All "notification events" are received in a separated non RT thread,
  528. * the code in the supplied function does not need to be
  529. * suitable for real-time execution.
  530. *
  531. * NOTE: this function cannot be called while the client is activated
  532. * (after jack_activate has been called.)
  533. *
  534. * @return 0 on success, otherwise a non-zero error code
  535. *)
  536. function jack_set_xrun_callback (client: Pjack_client_t;
  537. xrun_callback: TJackXRunCallback; arg: Pointer): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  538. (**
  539. * Tell the Jack server to call @a latency_callback whenever it
  540. * is necessary to recompute the latencies for some or all
  541. * Jack ports.
  542. *
  543. * @a latency_callback will be called twice each time it is
  544. * needed, once being passed JackCaptureLatency and once
  545. * JackPlaybackLatency. See @ref LatencyFunctions for
  546. * the definition of each type of latency and related functions.
  547. *
  548. * <b>IMPORTANT: Most JACK clients do NOT need to register a latency
  549. * callback.</b>
  550. *
  551. * Clients that meet any of the following conditions do NOT
  552. * need to register a latency callback:
  553. *
  554. * - have only input ports
  555. * - have only output ports
  556. * - their output is totally unrelated to their input
  557. * - their output is not delayed relative to their input
  558. * (i.e. data that arrives in a given process()
  559. * callback is processed and output again in the
  560. * same callback)
  561. *
  562. * Clients NOT registering a latency callback MUST also
  563. * satisfy this condition:
  564. *
  565. * - have no multiple distinct internal signal pathways
  566. *
  567. * This means that if your client has more than 1 input and
  568. * output port, and considers them always "correlated"
  569. * (e.g. as a stereo pair), then there is only 1 (e.g. stereo)
  570. * signal pathway through the client. This would be true,
  571. * for example, of a stereo FX rack client that has a
  572. * left/right input pair and a left/right output pair.
  573. *
  574. * However, this is somewhat a matter of perspective. The
  575. * same FX rack client could be connected so that its
  576. * two input ports were connected to entirely separate
  577. * sources. Under these conditions, the fact that the client
  578. * does not register a latency callback MAY result
  579. * in port latency values being incorrect.
  580. *
  581. * Clients that do not meet any of those conditions SHOULD
  582. * register a latency callback.
  583. *
  584. * Another case is when a client wants to use
  585. * @ref jack_port_get_latency_range(), which only returns meaningful
  586. * values when ports get connected and latency values change.
  587. *
  588. * See the documentation for @ref jack_port_set_latency_range()
  589. * on how the callback should operate. Remember that the @a mode
  590. * argument given to the latency callback will need to be
  591. * passed into @ref jack_port_set_latency_range()
  592. *
  593. * @return 0 on success, otherwise a non-zero error code
  594. *)
  595. function jack_set_latency_callback (client: Pjack_client_t;
  596. latency_callback: TJackLatencyCallback;
  597. arg: Pointer): cint; cdecl; JACK_WEAK_EXPORT;
  598. ///**@}*/
  599. (**
  600. * @defgroup ServerClientControl Controlling & querying JACK server operation
  601. * @{
  602. *)
  603. (**
  604. * Start/Stop JACK's "freewheel" mode.
  605. *
  606. * When in "freewheel" mode, JACK no longer waits for
  607. * any external event to begin the start of the next process
  608. * cycle.
  609. *
  610. * As a result, freewheel mode causes "faster than realtime"
  611. * execution of a JACK graph. If possessed, real-time
  612. * scheduling is dropped when entering freewheel mode, and
  613. * if appropriate it is reacquired when stopping.
  614. *
  615. * IMPORTANT: on systems using capabilities to provide real-time
  616. * scheduling (i.e. Linux kernel 2.4), if onoff is zero, this function
  617. * must be called from the thread that originally called jack_activate().
  618. * This restriction does not apply to other systems (e.g. Linux kernel 2.6
  619. * or OS X).
  620. *
  621. * @param client pointer to JACK client structure
  622. * @param onoff if non-zero, freewheel mode starts. Otherwise
  623. * freewheel mode ends.
  624. *
  625. * @return 0 on success, otherwise a non-zero error code.
  626. *)
  627. function jack_set_freewheel(client: Pjack_client_t; onoff: cint): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  628. (**
  629. * Change the buffer size passed to the @a process_callback.
  630. *
  631. * This operation stops the JACK engine process cycle, then calls all
  632. * registered @a bufsize_callback functions before restarting the
  633. * process cycle. This will cause a gap in the audio flow, so it
  634. * should only be done at appropriate stopping points.
  635. *
  636. * @see jack_set_buffer_size_callback()
  637. *
  638. * @param client pointer to JACK client structure.
  639. * @param nframes new buffer size. Must be a power of two.
  640. *
  641. * @return 0 on success, otherwise a non-zero error code
  642. *)
  643. function jack_set_buffer_size (client: Pjack_client_t; nframes: jack_nframes_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  644. (**
  645. * @return the sample rate of the jack system, as set by the user when
  646. * jackd was started.
  647. *)
  648. function jack_get_sample_rate (client: Pjack_client_t): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  649. (**
  650. * @return the current maximum size that will ever be passed to the @a
  651. * process_callback. It should only be used *before* the client has
  652. * been activated. This size may change, clients that depend on it
  653. * must register a @a bufsize_callback so they will be notified if it
  654. * does.
  655. *
  656. * @see jack_set_buffer_size_callback()
  657. *)
  658. function jack_get_buffer_size (client: Pjack_client_t): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  659. (**
  660. * Old-style interface to become the timebase for the entire JACK
  661. * subsystem.
  662. *
  663. * @deprecated This function still exists for compatibility with the
  664. * earlier transport interface, but it does nothing. Instead, see
  665. * transport.h and use jack_set_timebase_callback().
  666. *
  667. * @return ENOSYS, function not implemented.
  668. *)
  669. function jack_engine_takeover_timebase (client: Pjack_client_t): cint; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  670. (**
  671. * @return the current CPU load estimated by JACK. This is a running
  672. * average of the time it takes to execute a full process cycle for
  673. * all clients as a percentage of the real time available per cycle
  674. * determined by the buffer size and sample rate.
  675. *)
  676. function jack_cpu_load (client: Pjack_client_t): cfloat; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  677. ///**@}*/
  678. (**
  679. * @defgroup PortFunctions Creating & manipulating ports
  680. * @{
  681. *)
  682. (**
  683. * Create a new port for the client. This is an object used for moving
  684. * data of any type in or out of the client. Ports may be connected
  685. * in various ways.
  686. *
  687. * Each port has a short name. The port's full name contains the name
  688. * of the client concatenated with a colon (:) followed by its short
  689. * name. The jack_port_name_size() is the maximum length of this full
  690. * name. Exceeding that will cause the port registration to fail and
  691. * return NULL.
  692. *
  693. * The @a port_name must be unique among all ports owned by this client.
  694. * If the name is not unique, the registration will fail.
  695. *
  696. * All ports have a type, which may be any non-NULL and non-zero
  697. * length string, passed as an argument. Some port types are built
  698. * into the JACK API, currently only JACK_DEFAULT_AUDIO_TYPE.
  699. *
  700. * @param client pointer to JACK client structure.
  701. * @param port_name non-empty short name for the new port (not
  702. * including the leading @a "client_name:"). Must be unique.
  703. * @param port_type port type name. If longer than
  704. * jack_port_type_size(), only that many characters are significant.
  705. * @param flags @ref JackPortFlags bit mask.
  706. * @param buffer_size must be non-zero if this is not a built-in @a
  707. * port_type. Otherwise, it is ignored.
  708. *
  709. * @return jack_port_t pointer on success, otherwise NULL.
  710. *)
  711. function jack_port_register (client: Pjack_client_t;
  712. const port_name: PChar;
  713. const port_type: PChar;
  714. flags: culong;
  715. buffer_size: culong): Pjack_port_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  716. (**
  717. * Remove the port from the client, disconnecting any existing
  718. * connections.
  719. *
  720. * @return 0 on success, otherwise a non-zero error code
  721. *)
  722. function jack_port_unregister (client: Pjack_client_t; port: Pjack_port_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  723. (**
  724. * This returns a pointer to the memory area associated with the
  725. * specified port. For an output port, it will be a memory area
  726. * that can be written to; for an input port, it will be an area
  727. * containing the data from the port's connection(s), or
  728. * zero-filled. if there are multiple inbound connections, the data
  729. * will be mixed appropriately.
  730. *
  731. * FOR OUTPUT PORTS ONLY : DEPRECATED in Jack 2.0 !!
  732. * ---------------------------------------------------
  733. * You may cache the value returned, but only between calls to
  734. * your "blocksize" callback. For this reason alone, you should
  735. * either never cache the return value or ensure you have
  736. * a "blocksize" callback and be sure to invalidate the cached
  737. * address from there.
  738. *
  739. * Caching output ports is DEPRECATED in Jack 2.0, due to some new optimization (like "pipelining").
  740. * Port buffers have to be retrieved in each callback for proper functioning.
  741. *)
  742. function jack_port_get_buffer (port: Pjack_port_t; nframes: jack_nframes_t): Pointer; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  743. (**
  744. * @return the UUID of the jack_port_t
  745. *
  746. * @see jack_uuid_to_string() to convert into a string representation
  747. *)
  748. function jack_port_uuid (const port: Pjack_port_t): jack_uuid_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  749. (**
  750. * @return the full name of the jack_port_t (including the @a
  751. * "client_name:" prefix).
  752. *
  753. * @see jack_port_name_size().
  754. *)
  755. function jack_port_name (const port: Pjack_port_t): PChar; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  756. (**
  757. * @return the short name of the jack_port_t (not including the @a
  758. * "client_name:" prefix).
  759. *
  760. * @see jack_port_name_size().
  761. *)
  762. function jack_port_short_name (const port: Pjack_port_t): PChar; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  763. (**
  764. * @return the @ref JackPortFlags of the jack_port_t.
  765. *)
  766. function jack_port_flags (const port: Pjack_port_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  767. (**
  768. * @return the @a port type, at most jack_port_type_size() characters
  769. * including a final NULL.
  770. *)
  771. function jack_port_type (const port: Pjack_port_t): PChar; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  772. (**
  773. * @return the @a port type id.
  774. *)
  775. function jack_port_type_id (const port: Pjack_port_t): jack_port_type_id_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  776. (**
  777. * @return TRUE if the jack_port_t belongs to the jack_client_t.
  778. *)
  779. function jack_port_is_mine (const client: Pjack_client_t; const port: Pjack_port_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  780. (**
  781. * @return number of connections to or from @a port.
  782. *
  783. * @pre The calling client must own @a port.
  784. *)
  785. function jack_port_connected (const port: Pjack_port_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  786. (**
  787. * @return TRUE if the locally-owned @a port is @b directly connected
  788. * to the @a port_name.
  789. *
  790. * @see jack_port_name_size()
  791. *)
  792. function jack_port_connected_to (const port: Pjack_port_t;
  793. const port_name: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  794. (**
  795. * @return a null-terminated array of full port names to which the @a
  796. * port is connected. If none, returns NULL.
  797. *
  798. * The caller is responsible for calling jack_free() on any non-NULL
  799. * returned value.
  800. *
  801. * @param port locally owned jack_port_t pointer.
  802. *
  803. * @see jack_port_name_size(), jack_port_get_all_connections()
  804. *)
  805. function jack_port_get_connections (const port: Pjack_port_t): PPChar; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  806. (**
  807. * @return a null-terminated array of full port names to which the @a
  808. * port is connected. If none, returns NULL.
  809. *
  810. * The caller is responsible for calling jack_free() on any non-NULL
  811. * returned value.
  812. *
  813. * This differs from jack_port_get_connections() in two important
  814. * respects:
  815. *
  816. * 1) You may not call this function from code that is
  817. * executed in response to a JACK event. For example,
  818. * you cannot use it in a GraphReordered handler.
  819. *
  820. * 2) You need not be the owner of the port to get information
  821. * about its connections.
  822. *
  823. * @see jack_port_name_size()
  824. *)
  825. function jack_port_get_all_connections (const client: Pjack_client_t;
  826. const port: Pjack_port_t): PPChar; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  827. (**
  828. *
  829. * @deprecated This function will be removed from a future version
  830. * of JACK. Do not use it. There is no replacement. It has
  831. * turned out to serve essentially no purpose in real-life
  832. * JACK clients.
  833. *)
  834. function jack_port_tie (src: Pjack_port_t; dst: Pjack_port_t): cint; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  835. (**
  836. *
  837. * @deprecated This function will be removed from a future version
  838. * of JACK. Do not use it. There is no replacement. It has
  839. * turned out to serve essentially no purpose in real-life
  840. * JACK clients.
  841. *)
  842. function jack_port_untie (port: Pjack_port_t): cint; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  843. (**
  844. * \bold THIS FUNCTION IS DEPRECATED AND SHOULD NOT BE USED IN
  845. * NEW JACK CLIENTS
  846. *
  847. * Modify a port's short name. May be called at any time. If the
  848. * resulting full name (including the @a "client_name:" prefix) is
  849. * longer than jack_port_name_size(), it will be truncated.
  850. *
  851. * @return 0 on success, otherwise a non-zero error code.
  852. *)
  853. function jack_port_set_name (port: Pjack_port_t; const port_name: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  854. (**
  855. * Modify a port's short name. May NOT be called from a callback handling a server event.
  856. * If the resulting full name (including the @a "client_name:" prefix) is
  857. * longer than jack_port_name_size(), it will be truncated.
  858. *
  859. * @return 0 on success, otherwise a non-zero error code.
  860. *
  861. * This differs from jack_port_set_name() by triggering PortRename notifications to
  862. * clients that have registered a port rename handler.
  863. *)
  864. function jack_port_rename (client: Pjack_client_t; port: Pjack_port_t; const port_name: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  865. (**
  866. * Set @a alias as an alias for @a port. May be called at any time.
  867. * If the alias is longer than jack_port_name_size(), it will be truncated.
  868. *
  869. * After a successful call, and until JACK exits or
  870. * @function jack_port_unset_alias() is called, @alias may be
  871. * used as a alternate name for the port.
  872. *
  873. * Ports can have up to two aliases - if both are already
  874. * set, this function will return an error.
  875. *
  876. * @return 0 on success, otherwise a non-zero error code.
  877. *)
  878. function jack_port_set_alias (port: Pjack_port_t; const alias: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  879. (**
  880. * Remove @a alias as an alias for @a port. May be called at any time.
  881. *
  882. * After a successful call, @a alias can no longer be
  883. * used as a alternate name for the port.
  884. *
  885. * @return 0 on success, otherwise a non-zero error code.
  886. *)
  887. function jack_port_unset_alias (port: jack_port_t; const alias: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  888. (**
  889. * Get any aliases known for @port.
  890. *
  891. * @return the number of aliases discovered for the port
  892. *)
  893. function jack_port_get_aliases (const port: Pjack_port_t; {char* const aliases[2]} aliases: PPChar): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  894. (**
  895. * If @ref JackPortCanMonitor is set for this @a port, turn input
  896. * monitoring on or off. Otherwise, do nothing.
  897. *)
  898. function jack_port_request_monitor (port: Pjack_port_t; onoff: cint): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  899. (**
  900. * If @ref JackPortCanMonitor is set for this @a port_name, turn input
  901. * monitoring on or off. Otherwise, do nothing.
  902. *
  903. * @return 0 on success, otherwise a non-zero error code.
  904. *
  905. * @see jack_port_name_size()
  906. *)
  907. function jack_port_request_monitor_by_name (client: Pjack_client_t;
  908. const port_name: PChar; onoff: cint): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  909. (**
  910. * If @ref JackPortCanMonitor is set for a port, this function turns
  911. * on input monitoring if it was off, and turns it off if only one
  912. * request has been made to turn it on. Otherwise it does nothing.
  913. *
  914. * @return 0 on success, otherwise a non-zero error code
  915. *)
  916. function jack_port_ensure_monitor (port: Pjack_port_t; onoff: cint): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  917. (**
  918. * @return TRUE if input monitoring has been requested for @a port.
  919. *)
  920. function jack_port_monitoring_input (port: Pjack_port_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  921. (**
  922. * Establish a connection between two ports.
  923. *
  924. * When a connection exists, data written to the source port will
  925. * be available to be read at the destination port.
  926. *
  927. * @pre The port types must be identical.
  928. *
  929. * @pre The @ref JackPortFlags of the @a source_port must include @ref
  930. * JackPortIsOutput.
  931. *
  932. * @pre The @ref JackPortFlags of the @a destination_port must include
  933. * @ref JackPortIsInput.
  934. *
  935. * @return 0 on success, EEXIST if the connection is already made,
  936. * otherwise a non-zero error code
  937. *)
  938. function jack_connect (client: Pjack_client_t;
  939. const source_port: PChar;
  940. const destination_port: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  941. (**
  942. * Remove a connection between two ports.
  943. *
  944. * @pre The port types must be identical.
  945. *
  946. * @pre The @ref JackPortFlags of the @a source_port must include @ref
  947. * JackPortIsOutput.
  948. *
  949. * @pre The @ref JackPortFlags of the @a destination_port must include
  950. * @ref JackPortIsInput.
  951. *
  952. * @return 0 on success, otherwise a non-zero error code
  953. *)
  954. function jack_disconnect (client: Pjack_client_t;
  955. const source_port: PChar;
  956. const destination_port: PChar): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  957. (**
  958. * Perform the same function as jack_disconnect() using port handles
  959. * rather than names. This avoids the name lookup inherent in the
  960. * name-based version.
  961. *
  962. * Clients connecting their own ports are likely to use this function,
  963. * while generic connection clients (e.g. patchbays) would use
  964. * jack_disconnect().
  965. *)
  966. function jack_port_disconnect (client: Pjack_client_t; port: Pjack_port_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  967. (**
  968. * @return the maximum number of characters in a full JACK port name
  969. * including the final NULL character. This value is a constant.
  970. *
  971. * A port's full name contains the owning client name concatenated
  972. * with a colon (:) followed by its short name and a NULL
  973. * character.
  974. *)
  975. function jack_port_name_size: cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  976. (**
  977. * @return the maximum number of characters in a JACK port type name
  978. * including the final NULL character. This value is a constant.
  979. *)
  980. function jack_port_type_size: cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  981. (**
  982. * @return the buffersize of a port of type @arg port_type.
  983. *
  984. * this function may only be called in a buffer_size callback.
  985. *)
  986. function jack_port_type_get_buffer_size (client: Pjack_client_t; const port_type: PChar): csize_t; cdecl; JACK_WEAK_EXPORT;
  987. ///**@}*/
  988. (**
  989. * @defgroup LatencyFunctions Managing and determining latency
  990. * @{
  991. *
  992. * The purpose of JACK's latency API is to allow clients to
  993. * easily answer two questions:
  994. *
  995. * - How long has it been since the data read from a port arrived
  996. * at the edge of the JACK graph (either via a physical port
  997. * or being synthesized from scratch)?
  998. *
  999. * - How long will it be before the data written to a port arrives
  1000. * at the edge of a JACK graph?
  1001. * To help answering these two questions, all JACK ports have two
  1002. * latency values associated with them, both measured in frames:
  1003. *
  1004. * <b>capture latency</b>: how long since the data read from
  1005. * the buffer of a port arrived at
  1006. * a port marked with JackPortIsTerminal.
  1007. * The data will have come from the "outside
  1008. * world" if the terminal port is also
  1009. * marked with JackPortIsPhysical, or
  1010. * will have been synthesized by the client
  1011. * that owns the terminal port.
  1012. *
  1013. * <b>playback latency</b>: how long until the data
  1014. * written to the buffer of port will reach a port
  1015. * marked with JackPortIsTerminal.
  1016. *
  1017. * Both latencies might potentially have more than one value
  1018. * because there may be multiple pathways to/from a given port
  1019. * and a terminal port. Latency is therefore generally
  1020. * expressed a min/max pair.
  1021. *
  1022. * In most common setups, the minimum and maximum latency
  1023. * are the same, but this design accommodates more complex
  1024. * routing, and allows applications (and thus users) to
  1025. * detect cases where routing is creating an anomalous
  1026. * situation that may either need fixing or more
  1027. * sophisticated handling by clients that care about
  1028. * latency.
  1029. *
  1030. * See also @ref jack_set_latency_callback for details on how
  1031. * clients that add latency to the signal path should interact
  1032. * with JACK to ensure that the correct latency figures are
  1033. * used.
  1034. *)
  1035. (**
  1036. * The port latency is zero by default. Clients that control
  1037. * physical hardware with non-zero latency should call this
  1038. * to set the latency to its correct value. Note that the value
  1039. * should include any systemic latency present "outside" the
  1040. * physical hardware controlled by the client. For example,
  1041. * for a client controlling a digital audio interface connected
  1042. * to an external digital converter, the latency setting should
  1043. * include both buffering by the audio interface *and* the converter.
  1044. *
  1045. * @deprecated This method will be removed in the next major
  1046. * release of JACK. It should not be used in new code, and should
  1047. * be replaced by a latency callback that calls @ref
  1048. * jack_port_set_latency_range().
  1049. *)
  1050. procedure jack_port_set_latency (port: Pjack_port_t; nframes: jack_nframes_t); cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1051. (**
  1052. * return the latency range defined by @a mode for
  1053. * @a port, in frames.
  1054. *
  1055. * See @ref LatencyFunctions for the definition of each latency value.
  1056. *
  1057. * This function is best used from callbacks, specifically the latency callback.
  1058. * Before a port is connected, this returns the default latency: zero.
  1059. * Therefore it only makes sense to call jack_port_get_latency_range() when
  1060. * the port is connected, and that gets signalled by the latency callback.
  1061. * See @ref jack_set_latency_callback() for details.
  1062. *)
  1063. procedure jack_port_get_latency_range (port: Pjack_port_t; mode: jack_latency_callback_mode_t; range: Pjack_latency_range_t); cdecl; JACK_WEAK_EXPORT;
  1064. (**
  1065. * set the minimum and maximum latencies defined by
  1066. * @a mode for @a port, in frames.
  1067. *
  1068. * See @ref LatencyFunctions for the definition of each latency value.
  1069. *
  1070. * This function should ONLY be used inside a latency
  1071. * callback. The client should determine the current
  1072. * value of the latency using @ref jack_port_get_latency_range()
  1073. * (called using the same mode as @a mode)
  1074. * and then add some number of frames to that reflects
  1075. * latency added by the client.
  1076. *
  1077. * How much latency a client adds will vary
  1078. * dramatically. For most clients, the answer is zero
  1079. * and there is no reason for them to register a latency
  1080. * callback and thus they should never call this
  1081. * function.
  1082. *
  1083. * More complex clients that take an input signal,
  1084. * transform it in some way and output the result but
  1085. * not during the same process() callback will
  1086. * generally know a single constant value to add
  1087. * to the value returned by @ref jack_port_get_latency_range().
  1088. *
  1089. * Such clients would register a latency callback (see
  1090. * @ref jack_set_latency_callback) and must know what input
  1091. * ports feed which output ports as part of their
  1092. * internal state. Their latency callback will update
  1093. * the ports' latency values appropriately.
  1094. *
  1095. * A pseudo-code example will help. The @a mode argument to the latency
  1096. * callback will determine whether playback or capture
  1097. * latency is being set. The callback will use
  1098. * @ref jack_port_set_latency_range() as follows:
  1099. *
  1100. * \code
  1101. * jack_latency_range_t range;
  1102. * if (mode == JackPlaybackLatency) {
  1103. * foreach input_port in (all self-registered port) {
  1104. * jack_port_get_latency_range (port_feeding_input_port, JackPlaybackLatency, &range);
  1105. * range.min += min_delay_added_as_signal_flows_from port_feeding to input_port;
  1106. * range.max += max_delay_added_as_signal_flows_from port_feeding to input_port;
  1107. * jack_port_set_latency_range (input_port, JackPlaybackLatency, &range);
  1108. * }
  1109. * } else if (mode == JackCaptureLatency) {
  1110. * foreach output_port in (all self-registered port) {
  1111. * jack_port_get_latency_range (port_fed_by_output_port, JackCaptureLatency, &range);
  1112. * range.min += min_delay_added_as_signal_flows_from_output_port_to_fed_by_port;
  1113. * range.max += max_delay_added_as_signal_flows_from_output_port_to_fed_by_port;
  1114. * jack_port_set_latency_range (output_port, JackCaptureLatency, &range);
  1115. * }
  1116. * }
  1117. * \endcode
  1118. *
  1119. * In this relatively simple pseudo-code example, it is assumed that
  1120. * each input port or output is connected to only 1 output or input
  1121. * port respectively.
  1122. *
  1123. * If a port is connected to more than 1 other port, then the
  1124. * range.min and range.max values passed to @ref
  1125. * jack_port_set_latency_range() should reflect the minimum and
  1126. * maximum values across all connected ports.
  1127. *
  1128. * See the description of @ref jack_set_latency_callback for more
  1129. * information.
  1130. *)
  1131. procedure jack_port_set_latency_range (port: Pjack_port_t; mode: jack_latency_callback_mode_t; range: Pjack_latency_range_t); cdecl; JACK_WEAK_EXPORT;
  1132. (**
  1133. * Request a complete recomputation of all port latencies. This
  1134. * can be called by a client that has just changed the internal
  1135. * latency of its port using jack_port_set_latency
  1136. * and wants to ensure that all signal pathways in the graph
  1137. * are updated with respect to the values that will be returned
  1138. * by jack_port_get_total_latency. It allows a client
  1139. * to change multiple port latencies without triggering a
  1140. * recompute for each change.
  1141. *
  1142. * @return zero for successful execution of the request. non-zero
  1143. * otherwise.
  1144. *)
  1145. function jack_recompute_total_latencies (client: Pjack_client_t): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1146. (**
  1147. * @return the time (in frames) between data being available or
  1148. * delivered at/to a port, and the time at which it arrived at or is
  1149. * delivered to the "other side" of the port. E.g. for a physical
  1150. * audio output port, this is the time between writing to the port and
  1151. * when the signal will leave the connector. For a physical audio
  1152. * input port, this is the time between the sound arriving at the
  1153. * connector and the corresponding frames being readable from the
  1154. * port.
  1155. *
  1156. * @deprecated This method will be removed in the next major
  1157. * release of JACK. It should not be used in new code, and should
  1158. * be replaced by jack_port_get_latency_range() in any existing
  1159. * use cases.
  1160. *)
  1161. function jack_port_get_latency (port: Pjack_port_t): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1162. (**
  1163. * The maximum of the sum of the latencies in every
  1164. * connection path that can be drawn between the port and other
  1165. * ports with the @ref JackPortIsTerminal flag set.
  1166. *
  1167. * @deprecated This method will be removed in the next major
  1168. * release of JACK. It should not be used in new code, and should
  1169. * be replaced by jack_port_get_latency_range() in any existing
  1170. * use cases.
  1171. *)
  1172. function jack_port_get_total_latency (client: Pjack_client_t;
  1173. port: Pjack_port_t): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1174. (**
  1175. * Request a complete recomputation of a port's total latency. This
  1176. * can be called by a client that has just changed the internal
  1177. * latency of its port using jack_port_set_latency
  1178. * and wants to ensure that all signal pathways in the graph
  1179. * are updated with respect to the values that will be returned
  1180. * by jack_port_get_total_latency.
  1181. *
  1182. * @return zero for successful execution of the request. non-zero
  1183. * otherwise.
  1184. *
  1185. * @deprecated This method will be removed in the next major
  1186. * release of JACK. It should not be used in new code, and should
  1187. * be replaced by jack_recompute_total_latencies() in any existing
  1188. * use cases.
  1189. *)
  1190. function jack_recompute_total_latency (client: Pjack_client_t; port: Pjack_port_t): cint; cdecl; JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  1191. ///**@}*/
  1192. (**
  1193. * @defgroup PortSearching Looking up ports
  1194. * @{
  1195. *)
  1196. (**
  1197. * @param port_name_pattern A regular expression used to select
  1198. * ports by name. If NULL or of zero length, no selection based
  1199. * on name will be carried out.
  1200. * @param type_name_pattern A regular expression used to select
  1201. * ports by type. If NULL or of zero length, no selection based
  1202. * on type will be carried out.
  1203. * @param flags A value used to select ports by their flags.
  1204. * If zero, no selection based on flags will be carried out.
  1205. *
  1206. * @return a NULL-terminated array of ports that match the specified
  1207. * arguments. The caller is responsible for calling jack_free() any
  1208. * non-NULL returned value.
  1209. *
  1210. * @see jack_port_name_size(), jack_port_type_size()
  1211. *)
  1212. function jack_get_ports (client: Pjack_client_t;
  1213. const port_name_pattern: PChar;
  1214. const type_name_pattern: PChar;
  1215. flags: culong): PPChar; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1216. (**
  1217. * @return address of the jack_port_t named @a port_name.
  1218. *
  1219. * @see jack_port_name_size()
  1220. *)
  1221. function jack_port_by_name (client: Pjack_client_t; const port_name: PChar): Pjack_port_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1222. (**
  1223. * @return address of the jack_port_t of a @a port_id.
  1224. *)
  1225. function jack_port_by_id (client: Pjack_client_t;
  1226. port_id: jack_port_id_t): Pjack_port_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1227. ///**@}*/
  1228. (**
  1229. * @defgroup TimeFunctions Handling time
  1230. * @{
  1231. *
  1232. * JACK time is in units of 'frames', according to the current sample rate.
  1233. * The absolute value of frame times is meaningless, frame times have meaning
  1234. * only relative to each other.
  1235. *)
  1236. (**
  1237. * @return the estimated time in frames that has passed since the JACK
  1238. * server began the current process cycle.
  1239. *)
  1240. function jack_frames_since_cycle_start (const client: Pjack_client_t): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1241. (**
  1242. * @return the estimated current time in frames.
  1243. * This function is intended for use in other threads (not the process
  1244. * callback). The return value can be compared with the value of
  1245. * jack_last_frame_time to relate time in other threads to JACK time.
  1246. *)
  1247. function jack_frame_time (const client: Pjack_client_t): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1248. (**
  1249. * @return the precise time at the start of the current process cycle.
  1250. * This function may only be used from the process callback, and can
  1251. * be used to interpret timestamps generated by jack_frame_time() in
  1252. * other threads with respect to the current process cycle.
  1253. *
  1254. * This is the only jack time function that returns exact time:
  1255. * when used during the process callback it always returns the same
  1256. * value (until the next process callback, where it will return
  1257. * that value + nframes, etc). The return value is guaranteed to be
  1258. * monotonic and linear in this fashion unless an xrun occurs.
  1259. * If an xrun occurs, clients must check this value again, as time
  1260. * may have advanced in a non-linear way (e.g. cycles may have been skipped).
  1261. *)
  1262. function jack_last_frame_time (const client: Pjack_client_t): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1263. (**
  1264. * This function may only be used from the process callback.
  1265. * It provides the internal cycle timing information as used by
  1266. * most of the other time related functions. This allows the
  1267. * caller to map between frame counts and microseconds with full
  1268. * precision (i.e. without rounding frame times to integers),
  1269. * and also provides e.g. the microseconds time of the start of
  1270. * the current cycle directly (it has to be computed otherwise).
  1271. *
  1272. * If the return value is zero, the following information is
  1273. * provided in the variables pointed to by the arguments:
  1274. *
  1275. * current_frames: the frame time counter at the start of the
  1276. * current cycle, same as jack_last_frame_time().
  1277. * current_usecs: the microseconds time at the start of the
  1278. * current cycle.
  1279. * next_usecs: the microseconds time of the start of the next
  1280. * next cycle as computed by the DLL.
  1281. * period_usecs: the current best estimate of the period time in
  1282. * microseconds.
  1283. *
  1284. * NOTES:
  1285. *
  1286. * Because of the types used, all the returned values except period_usecs
  1287. * are unsigned. In computations mapping between frames and microseconds
  1288. * *signed* differences are required. The easiest way is to compute those
  1289. * separately and assign them to the appropriate signed variables,
  1290. * int32_t for frames and int64_t for usecs. See the implementation of
  1291. * jack_frames_to_time() and Jack_time_to_frames() for an example.
  1292. *
  1293. * Unless there was an xrun, skipped cycles, or the current cycle is the
  1294. * first after freewheeling or starting Jack, the value of current_usecs
  1295. * will always be the value of next_usecs of the previous cycle.
  1296. *
  1297. * The value of period_usecs will in general NOT be exactly equal to
  1298. * the difference of next_usecs and current_usecs. This is because to
  1299. * ensure stability of the DLL and continuity of the mapping, a fraction
  1300. * of the loop error must be included in next_usecs. For an accurate
  1301. * mapping between frames and microseconds, the difference of next_usecs
  1302. * and current_usecs should be used, and not period_usecs.
  1303. *
  1304. * @return zero if OK, non-zero otherwise.
  1305. *)
  1306. function jack_get_cycle_times(const client: Pjack_client_t;
  1307. current_frames: Pjack_nframes_t;
  1308. current_usecs: Pjack_time_t;
  1309. next_usecs: Pjack_time_t;
  1310. period_usecs: Pcfloat): cint; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1311. (**
  1312. * @return the estimated time in microseconds of the specified frame time
  1313. *)
  1314. function jack_frames_to_time(const client: Pjack_client_t; nframes: jack_nframes_t): jack_time_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1315. (**
  1316. * @return the estimated time in frames for the specified system time.
  1317. *)
  1318. function jack_time_to_frames(const client: Pjack_client_t; time: jack_time_t): jack_nframes_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1319. (**
  1320. * @return return JACK's current system time in microseconds,
  1321. * using the JACK clock source.
  1322. *
  1323. * The value returned is guaranteed to be monotonic, but not linear.
  1324. *)
  1325. function jack_get_time: jack_time_t; cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1326. ///**@}*/
  1327. (**
  1328. * @defgroup ErrorOutput Controlling error/information output
  1329. * @{
  1330. *)
  1331. (**
  1332. * Display JACK error message.
  1333. *
  1334. * Set via jack_set_error_function(), otherwise a JACK-provided
  1335. * default will print @a msg (plus a newline) to stderr.
  1336. *
  1337. * @param msg error message text (no newline at end).
  1338. *)
  1339. type
  1340. TJackErrorFunction = procedure (const msg: PChar); cdecl;
  1341. var
  1342. jack_error_callback: TJackErrorFunction; JACK_OPTIONAL_WEAK_EXPORT;
  1343. (**
  1344. * Set the @ref jack_error_callback for error message display.
  1345. * Set it to NULL to restore default_jack_error_callback function.
  1346. *
  1347. * The JACK library provides two built-in callbacks for this purpose:
  1348. * default_jack_error_callback() and silent_jack_error_callback().
  1349. *)
  1350. procedure jack_set_error_function (func: TJackErrorFunction); cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1351. (**
  1352. * Display JACK info message.
  1353. *
  1354. * Set via jack_set_info_function(), otherwise a JACK-provided
  1355. * default will print @a msg (plus a newline) to stdout.
  1356. *
  1357. * @param msg info message text (no newline at end).
  1358. *)
  1359. type
  1360. TJackInfoFunction = procedure (const msg: PChar); cdecl;
  1361. var
  1362. jack_info_callback: TJackInfoFunction; JACK_OPTIONAL_WEAK_EXPORT;
  1363. (**
  1364. * Set the @ref jack_info_callback for info message display.
  1365. * Set it to NULL to restore default_jack_info_callback function.
  1366. *
  1367. * The JACK library provides two built-in callbacks for this purpose:
  1368. * default_jack_info_callback() and silent_jack_info_callback().
  1369. *)
  1370. procedure jack_set_info_function (func: TJackInfoFunction); cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1371. ///**@}*/
  1372. (**
  1373. * The free function to be used on memory returned by jack_port_get_connections,
  1374. * jack_port_get_all_connections, jack_get_ports and jack_get_internal_client_name functions.
  1375. * This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur.
  1376. * Developers are strongly encouraged to use this function instead of the standard "free" function in new code.
  1377. *
  1378. * @param ptr the memory pointer to be deallocated.
  1379. *)
  1380. procedure jack_free(ptr: Pointer); cdecl; JACK_OPTIONAL_WEAK_EXPORT;
  1381. //#ifdef __cplusplus
  1382. //}
  1383. //#endif
  1384. {$endif __jack_h__}
  1385. implementation
  1386. end.