sdlaudio.inc 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459
  1. //from sdl_audio.h
  2. {**
  3. * Audio format flags.
  4. *
  5. * These are what the 16 bits in SDL_AudioFormat currently mean...
  6. * (Unspecified bits are always zero).
  7. *
  8. *
  9. ++-----------------------sample is signed if set
  10. ||
  11. || ++-----------sample is bigendian if set
  12. || ||
  13. || || ++---sample is float if set
  14. || || ||
  15. || || || +---sample bit size---+
  16. || || || | |
  17. 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
  18. *
  19. * There are macros in SDL 2.0 and later to query these bits.
  20. *}
  21. type
  22. PPSDL_AudioFormat = ^PSDL_AudioFormat;
  23. PSDL_AudioFormat = ^TSDL_AudioFormat;
  24. TSDL_AudioFormat = cuint16;
  25. {**
  26. * Audio flags
  27. *}
  28. const
  29. SDL_AUDIO_MASK_BITSIZE = ($FF);
  30. SDL_AUDIO_MASK_DATATYPE = (1 shl 8);
  31. SDL_AUDIO_MASK_ENDIAN = (1 shl 12);
  32. SDL_AUDIO_MASK_SIGNED = (1 shl 15);
  33. function SDL_AUDIO_BITSIZE(x: Cardinal): Cardinal;
  34. function SDL_AUDIO_ISFLOAT(x: Cardinal): Cardinal;
  35. function SDL_AUDIO_ISBIGENDIAN(x: Cardinal): Cardinal;
  36. function SDL_AUDIO_ISSIGNED(x: Cardinal): Cardinal;
  37. function SDL_AUDIO_ISINT(x: Cardinal): Cardinal;
  38. function SDL_AUDIO_ISLITTLEENDIAN(x: Cardinal): Cardinal;
  39. function SDL_AUDIO_ISUNSIGNED(x: Cardinal): Cardinal;
  40. {**
  41. * Audio format flags
  42. *
  43. * Defaults to LSB byte order.
  44. *}
  45. const
  46. AUDIO_U8 = $0008; {**< Unsigned 8-bit samples *}
  47. AUDIO_S8 = $8008; {**< Signed 8-bit samples *}
  48. AUDIO_U16LSB = $0010; {**< Unsigned 16-bit samples *}
  49. AUDIO_S16LSB = $8010; {**< Signed 16-bit samples *}
  50. AUDIO_U16MSB = $1010; {**< As above, but big-endian byte order *}
  51. AUDIO_S16MSB = $9010; {**< As above, but big-endian byte order *}
  52. AUDIO_U16 = AUDIO_U16LSB;
  53. AUDIO_S16 = AUDIO_S16LSB;
  54. {**
  55. * int32 support
  56. *}
  57. const
  58. AUDIO_S32LSB = $8020; {**< 32-bit integer samples *}
  59. AUDIO_S32MSB = $9020; {**< As above, but big-endian byte order *}
  60. AUDIO_S32 = AUDIO_S32LSB;
  61. {**
  62. * float32 support
  63. *}
  64. const
  65. AUDIO_F32LSB = $8120; {**< 32-bit floating point samples *}
  66. AUDIO_F32MSB = $9120; {**< As above, but big-endian byte order *}
  67. AUDIO_F32 = AUDIO_F32LSB;
  68. {**
  69. * Native audio byte ordering
  70. *}
  71. {$IFDEF FPC}
  72. {$IF DEFINED(ENDIAN_LITTLE)}
  73. AUDIO_U16SYS = AUDIO_U16LSB;
  74. AUDIO_S16SYS = AUDIO_S16LSB;
  75. AUDIO_S32SYS = AUDIO_S32LSB;
  76. AUDIO_F32SYS = AUDIO_F32LSB;
  77. {$ELSEIF DEFINED(ENDIAN_BIG)}
  78. AUDIO_U16SYS = AUDIO_U16MSB;
  79. AUDIO_S16SYS = AUDIO_S16MSB;
  80. AUDIO_S32SYS = AUDIO_S32MSB;
  81. AUDIO_F32SYS = AUDIO_F32MSB;
  82. {$ELSE}
  83. {$FATAL Cannot determine endianness.}
  84. {$IFEND}
  85. {$ENDIF}
  86. {**
  87. * Allow change flags
  88. *
  89. * Which audio format changes are allowed when opening a device.
  90. *}
  91. const
  92. SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = $00000001;
  93. SDL_AUDIO_ALLOW_FORMAT_CHANGE = $00000002;
  94. SDL_AUDIO_ALLOW_CHANNELS_CHANGE = $00000004;
  95. SDL_AUDIO_ALLOW_ANY_CHANGE = (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE or
  96. SDL_AUDIO_ALLOW_FORMAT_CHANGE or
  97. SDL_AUDIO_ALLOW_CHANNELS_CHANGE);
  98. {*Audio flags*}
  99. {**
  100. * This function is called when the audio device needs more data.
  101. *
  102. * \param userdata An application-specific parameter saved in
  103. * the SDL_AudioSpec structure
  104. * \param stream A pointer to the audio data buffer.
  105. * \param len The length of that buffer in bytes.
  106. *
  107. * Once the callback returns, the buffer will no longer be valid.
  108. * Stereo samples are stored in a LRLRLR ordering.
  109. *
  110. * You can choose to avoid callbacks and use SDL_QueueAudio() instead, if
  111. * you like. Just open your audio device with a NULL callback.
  112. *}
  113. type
  114. PPSDL_AudioCallback = ^PSDL_AudioCallback;
  115. PSDL_AudioCallback = ^TSDL_AudioCallback;
  116. TSDL_AudioCallback = procedure(userdata: Pointer; stream: pcuint8; len: cint); cdecl;
  117. {**
  118. * The calculated values in this structure are calculated by SDL_OpenAudio().
  119. *
  120. * For multi-channel audio, the default SDL channel mapping is:
  121. * 2: FL FR (stereo)
  122. * 3: FL FR LFE (2.1 surround)
  123. * 4: FL FR BL BR (quad)
  124. * 5: FL FR LFE BL BR (4.1 surround)
  125. * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
  126. * 7: FL FR FC LFE BC SL SR (6.1 surround)
  127. * 8: FL FR FC LFE BL BR SL SR (7.1 surround)
  128. *}
  129. type
  130. PPSDL_AudioSpec = ^PSDL_AudioSpec;
  131. PSDL_AudioSpec = ^TSDL_AudioSpec;
  132. TSDL_AudioSpec = record
  133. freq: cint; {**< DSP frequency -- samples per second *}
  134. format: TSDL_AudioFormat; {**< Audio data format *}
  135. channels: cuint8; {**< Number of channels: 1 mono, 2 stereo *}
  136. silence: cuint8; {**< Audio buffer silence value (calculated) *}
  137. samples: cuint16; {**< Audio buffer size in sample FRAMES (total samples divided by channel count) *}
  138. padding: cuint16; {**< Necessary for some compile environments *}
  139. size: cuint32; {**< Audio buffer size in bytes (calculated) *}
  140. callback: TSDL_AudioCallback; {**< Callback that feeds the audio device (NULL to use SDL_QueueAudio()). *}
  141. userdata: Pointer; {**< Userdata passed to callback (ignored for NULL callbacks). *}
  142. end;
  143. {**
  144. * \brief Upper limit of filters in SDL_AudioCVT
  145. *
  146. * The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is
  147. * currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers,
  148. * one of which is the terminating NULL pointer.
  149. *}
  150. const
  151. SDL_AUDIOCVT_MAX_FILTERS = 9;
  152. type
  153. PPSDL_AudioCVT = ^PSDL_AudioCVT;
  154. PSDL_AudioCVT = ^TSDL_AudioCVT;
  155. TSDL_AudioFilter = procedure(cvt: PSDL_AudioCVT; format: TSDL_AudioFormat); cdecl;
  156. {**
  157. * \struct SDL_AudioCVT
  158. * \brief A structure to hold a set of audio conversion filters and buffers.
  159. *
  160. * Note that various parts of the conversion pipeline can take advantage
  161. * of SIMD operations (like SSE2, for example). SDL_AudioCVT doesn't require
  162. * you to pass it aligned data, but can possibly run much faster if you
  163. * set both its (buf) field to a pointer that is aligned to 16 bytes, and its
  164. * (len) field to something that's a multiple of 16, if possible.
  165. *}
  166. TSDL_AudioCVT = record
  167. needed: cint; {**< Set to 1 if conversion possible *}
  168. src_format: TSDL_AudioFormat; {**< Source audio format *}
  169. dst_format: TSDL_AudioFormat; {**< Target audio format *}
  170. rate_incr: cdouble; {**< Rate conversion increment *}
  171. buf: pcuint8; {**< Buffer to hold entire audio data *}
  172. len: cint; {**< Length of original audio buffer *}
  173. len_cvt: cint; {**< Length of converted audio buffer *}
  174. len_mult: cint; {**< buffer must be len*len_mult big *}
  175. len_ratio: cdouble; {**< Given len, final size is len*len_ratio *}
  176. filters: array[0..SDL_AUDIOCVT_MAX_FILTERS] of TSDL_AudioFilter; {**< NULL-terminated list of filter functions *}
  177. filter_index: cint; {**< Current audio conversion function *}
  178. end;
  179. {* Function prototypes *}
  180. {**
  181. * Driver discovery functions
  182. *
  183. * These functions return the list of built in audio drivers, in the
  184. * order that they are normally initialized by default.
  185. *}
  186. {**
  187. * Use this function to get the number of built-in audio drivers.
  188. *
  189. * This function returns a hardcoded number. This never returns a negative
  190. * value; if there are no drivers compiled into this build of SDL, this
  191. * function returns zero. The presence of a driver in this list does not mean
  192. * it will function, it just means SDL is capable of interacting with that
  193. * interface. For example, a build of SDL might have esound support, but if
  194. * there's no esound server available, SDL's esound driver would fail if used.
  195. *
  196. * By default, SDL tries all drivers, in its preferred order, until one is
  197. * found to be usable.
  198. *
  199. * \returns the number of built-in audio drivers.
  200. *
  201. * \since This function is available since SDL 2.0.0.
  202. *
  203. * \sa SDL_GetAudioDriver
  204. *}
  205. function SDL_GetNumAudioDrivers: cint; cdecl;
  206. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetNumAudioDrivers' {$ENDIF} {$ENDIF};
  207. {**
  208. * Use this function to get the name of a built in audio driver.
  209. *
  210. * The list of audio drivers is given in the order that they are normally
  211. * initialized by default; the drivers that seem more reasonable to choose
  212. * first (as far as the SDL developers believe) are earlier in the list.
  213. *
  214. * The names of drivers are all simple, low-ASCII identifiers, like "alsa",
  215. * "coreaudio" or "xaudio2". These never have Unicode characters, and are not
  216. * meant to be proper names.
  217. *
  218. * \param index the index of the audio driver; the value ranges from 0 to
  219. * SDL_GetNumAudioDrivers() - 1
  220. * \returns the name of the audio driver at the requested index, or NULL if an
  221. * invalid index was specified.
  222. *
  223. * \since This function is available since SDL 2.0.0.
  224. *
  225. * \sa SDL_GetNumAudioDrivers
  226. *}
  227. function SDL_GetAudioDriver(index: cint): PAnsiChar; cdecl;
  228. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetAudioDriver' {$ENDIF} {$ENDIF};
  229. {**
  230. * Initialization and cleanup
  231. *
  232. * These functions are used internally, and should not be used unless
  233. * you have a specific need to specify the audio driver you want to
  234. * use. You should normally use SDL_Init() or SDL_InitSubSystem().
  235. *}
  236. {**
  237. * Use this function to initialize a particular audio driver.
  238. *
  239. * This function is used internally, and should not be used unless you have a
  240. * specific need to designate the audio driver you want to use. You should
  241. * normally use SDL_Init() or SDL_InitSubSystem().
  242. *
  243. * \param driver_name the name of the desired audio driver
  244. * \returns 0 on success or a negative error code on failure; call
  245. * SDL_GetError() for more information.
  246. *
  247. * \since This function is available since SDL 2.0.0.
  248. *
  249. * \sa SDL_AudioQuit
  250. *}
  251. function SDL_AudioInit(driver_name: PAnsiChar): cint; cdecl;
  252. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AudioInit' {$ENDIF} {$ENDIF};
  253. {**
  254. * Use this function to shut down audio if you initialized it with
  255. * SDL_AudioInit().
  256. *
  257. * This function is used internally, and should not be used unless you have a
  258. * specific need to specify the audio driver you want to use. You should
  259. * normally use SDL_Quit() or SDL_QuitSubSystem().
  260. *
  261. * \since This function is available since SDL 2.0.0.
  262. *
  263. * \sa SDL_AudioInit
  264. *}
  265. procedure SDL_AudioQuit; cdecl;
  266. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AudioQuit' {$ENDIF} {$ENDIF};
  267. {**
  268. * Get the name of the current audio driver.
  269. *
  270. * The returned string points to internal static memory and thus never becomes
  271. * invalid, even if you quit the audio subsystem and initialize a new driver
  272. * (although such a case would return a different static string from another
  273. * call to this function, of course). As such, you should not modify or free
  274. * the returned string.
  275. *
  276. * \returns the name of the current audio driver or NULL if no driver has been
  277. * initialized.
  278. *
  279. * \since This function is available since SDL 2.0.0.
  280. *
  281. * \sa SDL_AudioInit
  282. *}
  283. function SDL_GetCurrentAudioDriver: PAnsiChar; cdecl;
  284. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetCurrentAudioDriver' {$ENDIF} {$ENDIF};
  285. {**
  286. * This function is a legacy means of opening the audio device.
  287. *
  288. * This function remains for compatibility with SDL 1.2, but also because it's
  289. * slightly easier to use than the new functions in SDL 2.0. The new, more
  290. * powerful, and preferred way to do this is SDL_OpenAudioDevice().
  291. *
  292. * This function is roughly equivalent to:
  293. *
  294. * ```c
  295. * SDL_OpenAudioDevice(NULL, 0, desired, obtained, SDL_AUDIO_ALLOW_ANY_CHANGE);
  296. * ```
  297. *
  298. * With two notable exceptions:
  299. *
  300. * - If `obtained` is NULL, we use `desired` (and allow no changes), which
  301. * means desired will be modified to have the correct values for silence,
  302. * etc, and SDL will convert any differences between your app's specific
  303. * request and the hardware behind the scenes.
  304. * - The return value is always success or failure, and not a device ID, which
  305. * means you can only have one device open at a time with this function.
  306. *
  307. * \param desired an SDL_AudioSpec structure representing the desired output
  308. * format. Please refer to the SDL_OpenAudioDevice
  309. * documentation for details on how to prepare this structure.
  310. * \param obtained an SDL_AudioSpec structure filled in with the actual
  311. * parameters, or NULL.
  312. * \returns 0 if successful, placing the actual hardware parameters in the
  313. * structure pointed to by `obtained`.
  314. *
  315. * If `obtained` is NULL, the audio data passed to the callback
  316. * function will be guaranteed to be in the requested format, and
  317. * will be automatically converted to the actual hardware audio
  318. * format if necessary. If `obtained` is NULL, `desired` will have
  319. * fields modified.
  320. *
  321. * This function returns a negative error code on failure to open the
  322. * audio device or failure to set up the audio thread; call
  323. * SDL_GetError() for more information.
  324. *
  325. * \since This function is available since SDL 2.0.0.
  326. *
  327. * \sa SDL_CloseAudio
  328. * \sa SDL_LockAudio
  329. * \sa SDL_PauseAudio
  330. * \sa SDL_UnlockAudio
  331. *}
  332. function SDL_OpenAudio(desired: PSDL_AudioSpec; obtained: PSDL_AudioSpec): cint; cdecl;
  333. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_OpenAudio' {$ENDIF} {$ENDIF};
  334. {**
  335. * SDL Audio Device IDs.
  336. *
  337. * A successful call to SDL_OpenAudio() is always device id 1, and legacy
  338. * SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
  339. * always returns devices >= 2 on success. The legacy calls are good both
  340. * for backwards compatibility and when you don't care about multiple,
  341. * specific, or capture devices.
  342. *}
  343. type
  344. PPSDL_AudioDeviceID = ^PSDL_AudioDeviceID;
  345. PSDL_AudioDeviceID = ^TSDL_AudioDeviceID;
  346. TSDL_AudioDeviceID = cuint32;
  347. {**
  348. * Get the number of built-in audio devices.
  349. *
  350. * This function is only valid after successfully initializing the audio
  351. * subsystem.
  352. *
  353. * Note that audio capture support is not implemented as of SDL 2.0.4, so the
  354. * `iscapture` parameter is for future expansion and should always be zero for
  355. * now.
  356. *
  357. * This function will return -1 if an explicit list of devices can't be
  358. * determined. Returning -1 is not an error. For example, if SDL is set up to
  359. * talk to a remote audio server, it can't list every one available on the
  360. * Internet, but it will still allow a specific host to be specified in
  361. * SDL_OpenAudioDevice().
  362. *
  363. * In many common cases, when this function returns a value <= 0, it can still
  364. * successfully open the default device (NULL for first argument of
  365. * SDL_OpenAudioDevice()).
  366. *
  367. * This function may trigger a complete redetect of available hardware. It
  368. * should not be called for each iteration of a loop, but rather once at the
  369. * start of a loop:
  370. *
  371. * ```c
  372. * // Don't do this:
  373. * for (int i = 0; i < SDL_GetNumAudioDevices(0); i++)
  374. *
  375. * // do this instead:
  376. * const int count = SDL_GetNumAudioDevices(0);
  377. * for (int i = 0; i < count; ++i) do_something_here();
  378. * ```
  379. *
  380. * \param iscapture zero to request playback devices, non-zero to request
  381. * recording devices
  382. * \returns the number of available devices exposed by the current driver or
  383. * -1 if an explicit list of devices can't be determined. A return
  384. * value of -1 does not necessarily mean an error condition.
  385. *
  386. * \since This function is available since SDL 2.0.0.
  387. *
  388. * \sa SDL_GetAudioDeviceName
  389. * \sa SDL_OpenAudioDevice
  390. *}
  391. function SDL_GetNumAudioDevices(iscapture: cint): cint; cdecl;
  392. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetNumAudioDevices' {$ENDIF} {$ENDIF};
  393. {**
  394. * Get the human-readable name of a specific audio device.
  395. *
  396. * This function is only valid after successfully initializing the audio
  397. * subsystem. The values returned by this function reflect the latest call to
  398. * SDL_GetNumAudioDevices(); re-call that function to redetect available
  399. * hardware.
  400. *
  401. * The string returned by this function is UTF-8 encoded, read-only, and
  402. * managed internally. You are not to free it. If you need to keep the string
  403. * for any length of time, you should make your own copy of it, as it will be
  404. * invalid next time any of several other SDL functions are called.
  405. *
  406. * \param index the index of the audio device; valid values range from 0 to
  407. * SDL_GetNumAudioDevices() - 1
  408. * \param iscapture non-zero to query the list of recording devices, zero to
  409. * query the list of output devices.
  410. * \returns the name of the audio device at the requested index, or NULL on
  411. * error.
  412. *
  413. * \since This function is available since SDL 2.0.0.
  414. *
  415. * \sa SDL_GetNumAudioDevices
  416. * \sa SDL_GetDefaultAudioInfo
  417. *}
  418. function SDL_GetAudioDeviceName(index: cint; iscapture: cint): PAnsiChar; cdecl;
  419. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetAudioDeviceName' {$ENDIF} {$ENDIF};
  420. {*
  421. * Get the preferred audio format of a specific audio device.
  422. *
  423. * This function is only valid after a successfully initializing the audio
  424. * subsystem. The values returned by this function reflect the latest call to
  425. * SDL_GetNumAudioDevices(); re-call that function to redetect available
  426. * hardware.
  427. *
  428. * `spec` will be filled with the sample rate, sample format, and channel
  429. * count.
  430. *
  431. * \param index the index of the audio device; valid values range from 0 to
  432. * SDL_GetNumAudioDevices() - 1
  433. * \param iscapture non-zero to query the list of recording devices, zero to
  434. * query the list of output devices.
  435. * \param spec The SDL_AudioSpec to be initialized by this function.
  436. * \returns 0 on success, nonzero on error
  437. *
  438. * \since This function is available since SDL 2.0.16.
  439. *
  440. * \sa SDL_GetNumAudioDevices
  441. * \sa SDL_GetDefaultAudioInfo
  442. }
  443. function SDL_GetAudioDeviceSpec(index: cint; iscapture: cint; spec: PSDL_AudioSpec): cint; cdecl;
  444. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetAudioDeviceSpec' {$ENDIF} {$ENDIF};
  445. {*
  446. * Get the name and preferred format of the default audio device.
  447. *
  448. * Some (but not all!) platforms have an isolated mechanism to get information
  449. * about the "default" device. This can actually be a completely different
  450. * device that's not in the list you get from SDL_GetAudioDeviceSpec(). It can
  451. * even be a network address! (This is discussed in SDL_OpenAudioDevice().)
  452. *
  453. * As a result, this call is not guaranteed to be performant, as it can query
  454. * the sound server directly every time, unlike the other query functions. You
  455. * should call this function sparingly!
  456. *
  457. * `spec` will be filled with the sample rate, sample format, and channel
  458. * count, if a default device exists on the system. If `name` is provided,
  459. * will be filled with either a dynamically-allocated UTF-8 string or nil.
  460. *
  461. * \param name A pointer to be filled with the name of the default device (can
  462. * be nil). Please call SDL_free() when you are done with this
  463. * pointer!
  464. * \param spec The SDL_AudioSpec to be initialized by this function.
  465. * \param iscapture non-zero to query the default recording device, zero to
  466. * query the default output device.
  467. * \returns 0 on success, nonzero on error
  468. *
  469. * \since This function is available since SDL 2.24.0.
  470. *
  471. * \sa SDL_GetAudioDeviceName
  472. * \sa SDL_GetAudioDeviceSpec
  473. * \sa SDL_OpenAudioDevice
  474. }
  475. function SDL_GetDefaultAudioInfo(name: PPAnsiChar; spec: PSDL_AudioSpec; iscapture: cint): cint; cdecl;
  476. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetDefaultAudioInfo' {$ENDIF} {$ENDIF};
  477. {**
  478. * Open a specific audio device.
  479. *
  480. * SDL_OpenAudio(), unlike this function, always acts on device ID 1. As such,
  481. * this function will never return a 1 so as not to conflict with the legacy
  482. * function.
  483. *
  484. * Please note that SDL 2.0 before 2.0.5 did not support recording; as such,
  485. * this function would fail if `iscapture` was not zero. Starting with SDL
  486. * 2.0.5, recording is implemented and this value can be non-zero.
  487. *
  488. * Passing in a `device` name of NULL requests the most reasonable default
  489. * (and is equivalent to what SDL_OpenAudio() does to choose a device). The
  490. * `device` name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but
  491. * some drivers allow arbitrary and driver-specific strings, such as a
  492. * hostname/IP address for a remote audio server, or a filename in the
  493. * diskaudio driver.
  494. *
  495. * An opened audio device starts out paused, and should be enabled for playing
  496. * by calling SDL_PauseAudioDevice(devid, 0) when you are ready for your audio
  497. * callback function to be called. Since the audio driver may modify the
  498. * requested size of the audio buffer, you should allocate any local mixing
  499. * buffers after you open the audio device.
  500. *
  501. * The audio callback runs in a separate thread in most cases; you can prevent
  502. * race conditions between your callback and other threads without fully
  503. * pausing playback with SDL_LockAudioDevice(). For more information about the
  504. * callback, see SDL_AudioSpec.
  505. *
  506. * Managing the audio spec via 'desired' and 'obtained':
  507. *
  508. * When filling in the desired audio spec structure:
  509. *
  510. * - `desired->freq` should be the frequency in sample-frames-per-second (Hz).
  511. * - `desired->format` should be the audio format (`AUDIO_S16SYS`, etc).
  512. * - `desired->samples` is the desired size of the audio buffer, in _sample
  513. * frames_ (with stereo output, two samples--left and right--would make a
  514. * single sample frame). This number should be a power of two, and may be
  515. * adjusted by the audio driver to a value more suitable for the hardware.
  516. * Good values seem to range between 512 and 8096 inclusive, depending on
  517. * the application and CPU speed. Smaller values reduce latency, but can
  518. * lead to underflow if the application is doing heavy processing and cannot
  519. * fill the audio buffer in time. Note that the number of sample frames is
  520. * directly related to time by the following formula: `ms =
  521. * (sampleframes*1000)/freq`
  522. * - `desired->size` is the size in _bytes_ of the audio buffer, and is
  523. * calculated by SDL_OpenAudioDevice(). You don't initialize this.
  524. * - `desired->silence` is the value used to set the buffer to silence, and is
  525. * calculated by SDL_OpenAudioDevice(). You don't initialize this.
  526. * - `desired->callback` should be set to a function that will be called when
  527. * the audio device is ready for more data. It is passed a pointer to the
  528. * audio buffer, and the length in bytes of the audio buffer. This function
  529. * usually runs in a separate thread, and so you should protect data
  530. * structures that it accesses by calling SDL_LockAudioDevice() and
  531. * SDL_UnlockAudioDevice() in your code. Alternately, you may pass a NULL
  532. * pointer here, and call SDL_QueueAudio() with some frequency, to queue
  533. * more audio samples to be played (or for capture devices, call
  534. * SDL_DequeueAudio() with some frequency, to obtain audio samples).
  535. * - `desired->userdata` is passed as the first parameter to your callback
  536. * function. If you passed a NULL callback, this value is ignored.
  537. *
  538. * `allowed_changes` can have the following flags OR'd together:
  539. *
  540. * - `SDL_AUDIO_ALLOW_FREQUENCY_CHANGE`
  541. * - `SDL_AUDIO_ALLOW_FORMAT_CHANGE`
  542. * - `SDL_AUDIO_ALLOW_CHANNELS_CHANGE`
  543. * - `SDL_AUDIO_ALLOW_SAMPLES_CHANGE`
  544. * - `SDL_AUDIO_ALLOW_ANY_CHANGE`
  545. *
  546. * These flags specify how SDL should behave when a device cannot offer a
  547. * specific feature. If the application requests a feature that the hardware
  548. * doesn't offer, SDL will always try to get the closest equivalent.
  549. *
  550. * For example, if you ask for float32 audio format, but the sound card only
  551. * supports int16, SDL will set the hardware to int16. If you had set
  552. * SDL_AUDIO_ALLOW_FORMAT_CHANGE, SDL will change the format in the `obtained`
  553. * structure. If that flag was *not* set, SDL will prepare to convert your
  554. * callback's float32 audio to int16 before feeding it to the hardware and
  555. * will keep the originally requested format in the `obtained` structure.
  556. *
  557. * The resulting audio specs, varying depending on hardware and on what
  558. * changes were allowed, will then be written back to `obtained`.
  559. *
  560. * If your application can only handle one specific data format, pass a zero
  561. * for `allowed_changes` and let SDL transparently handle any differences.
  562. *
  563. * \param device a UTF-8 string reported by SDL_GetAudioDeviceName() or a
  564. * driver-specific name as appropriate. NULL requests the most
  565. * reasonable default device.
  566. * \param iscapture non-zero to specify a device should be opened for
  567. * recording, not playback
  568. * \param desired an SDL_AudioSpec structure representing the desired output
  569. * format; see SDL_OpenAudio() for more information
  570. * \param obtained an SDL_AudioSpec structure filled in with the actual output
  571. * format; see SDL_OpenAudio() for more information
  572. * \param allowed_changes 0, or one or more flags OR'd together
  573. * \returns a valid device ID that is > 0 on success or 0 on failure; call
  574. * SDL_GetError() for more information.
  575. *
  576. * For compatibility with SDL 1.2, this will never return 1, since
  577. * SDL reserves that ID for the legacy SDL_OpenAudio() function.
  578. *
  579. * \since This function is available since SDL 2.0.0.
  580. *
  581. * \sa SDL_CloseAudioDevice
  582. * \sa SDL_GetAudioDeviceName
  583. * \sa SDL_LockAudioDevice
  584. * \sa SDL_OpenAudio
  585. * \sa SDL_PauseAudioDevice
  586. * \sa SDL_UnlockAudioDevice
  587. *}
  588. function SDL_OpenAudioDevice(device: PAnsiChar;
  589. iscapture: cint;
  590. desired: PSDL_AudioSpec;
  591. obtained: PSDL_AudioSpec;
  592. allowed_changes: cint): TSDL_AudioDeviceID; cdecl;
  593. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_OpenAudioDevice' {$ENDIF} {$ENDIF};
  594. {**
  595. * Audio state
  596. *
  597. * Get the current audio state.
  598. *}
  599. type
  600. PPSDL_AudioStatus = ^PSDL_AudioStatus;
  601. PSDL_AudioStatus = ^TSDL_AudioStatus;
  602. TSDL_AudioStatus = type cint;
  603. const
  604. SDL_AUDIO_STOPPED = TSDL_AudioStatus(0);
  605. SDL_AUDIO_PLAYING = TSDL_AudioStatus(1);
  606. SDL_AUDIO_PAUSED = TSDL_AudioStatus(2);
  607. {**
  608. * This function is a legacy means of querying the audio device.
  609. *
  610. * New programs might want to use SDL_GetAudioDeviceStatus() instead. This
  611. * function is equivalent to calling...
  612. *
  613. * ```c
  614. * SDL_GetAudioDeviceStatus(1);
  615. * ```
  616. *
  617. * ...and is only useful if you used the legacy SDL_OpenAudio() function.
  618. *
  619. * \returns the SDL_AudioStatus of the audio device opened by SDL_OpenAudio().
  620. *
  621. * \since This function is available since SDL 2.0.0.
  622. *
  623. * \sa SDL_GetAudioDeviceStatus
  624. *}
  625. function SDL_GetAudioStatus: TSDL_AudioStatus; cdecl;
  626. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetAudioStatus' {$ENDIF} {$ENDIF};
  627. {**
  628. * Use this function to get the current audio state of an audio device.
  629. *
  630. * \param dev the ID of an audio device previously opened with
  631. * SDL_OpenAudioDevice()
  632. * \returns the SDL_AudioStatus of the specified audio device.
  633. *
  634. * \since This function is available since SDL 2.0.0.
  635. *
  636. * \sa SDL_PauseAudioDevice
  637. *}
  638. function SDL_GetAudioDeviceStatus(dev: TSDL_AudioDeviceID): TSDL_AudioStatus; cdecl;
  639. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetAudioDeviceStatus' {$ENDIF} {$ENDIF};
  640. {*Audio State*}
  641. {**
  642. * Pause audio functions
  643. *
  644. * These functions pause and unpause the audio callback processing.
  645. * They should be called with a parameter of 0 after opening the audio
  646. * device to start playing sound. This is so you can safely initialize
  647. * data for your callback function after opening the audio device.
  648. * Silence will be written to the audio device during the pause.
  649. *}
  650. {**
  651. * This function is a legacy means of pausing the audio device.
  652. *
  653. * New programs might want to use SDL_PauseAudioDevice() instead. This
  654. * function is equivalent to calling...
  655. *
  656. * ```c
  657. * SDL_PauseAudioDevice(1, pause_on);
  658. * ```
  659. *
  660. * ...and is only useful if you used the legacy SDL_OpenAudio() function.
  661. *
  662. * \param pause_on non-zero to pause, 0 to unpause
  663. *
  664. * \since This function is available since SDL 2.0.0.
  665. *
  666. * \sa SDL_GetAudioStatus
  667. * \sa SDL_PauseAudioDevice
  668. *}
  669. procedure SDL_PauseAudio(pause_on: cint); cdecl;
  670. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PauseAudio' {$ENDIF} {$ENDIF};
  671. {**
  672. * Use this function to pause and unpause audio playback on a specified
  673. * device.
  674. *
  675. * This function pauses and unpauses the audio callback processing for a given
  676. * device. Newly-opened audio devices start in the paused state, so you must
  677. * call this function with **pause_on**=0 after opening the specified audio
  678. * device to start playing sound. This allows you to safely initialize data
  679. * for your callback function after opening the audio device. Silence will be
  680. * written to the audio device while paused, and the audio callback is
  681. * guaranteed to not be called. Pausing one device does not prevent other
  682. * unpaused devices from running their callbacks.
  683. *
  684. * Pausing state does not stack; even if you pause a device several times, a
  685. * single unpause will start the device playing again, and vice versa. This is
  686. * different from how SDL_LockAudioDevice() works.
  687. *
  688. * If you just need to protect a few variables from race conditions vs your
  689. * callback, you shouldn't pause the audio device, as it will lead to dropouts
  690. * in the audio playback. Instead, you should use SDL_LockAudioDevice().
  691. *
  692. * \param dev a device opened by SDL_OpenAudioDevice()
  693. * \param pause_on non-zero to pause, 0 to unpause
  694. *
  695. * \since This function is available since SDL 2.0.0.
  696. *
  697. * \sa SDL_LockAudioDevice
  698. *}
  699. procedure SDL_PauseAudioDevice(dev: TSDL_AudioDeviceID; pause_on: cint); cdecl;
  700. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PauseAudioDevice' {$ENDIF} {$ENDIF};
  701. {*Pause audio functions*}
  702. {**
  703. * Load the audio data of a WAVE file into memory.
  704. *
  705. * Loading a WAVE file requires `src`, `spec`, `audio_buf` and `audio_len` to
  706. * be valid pointers. The entire data portion of the file is then loaded into
  707. * memory and decoded if necessary.
  708. *
  709. * If `freesrc` is non-zero, the data source gets automatically closed and
  710. * freed before the function returns.
  711. *
  712. * Supported formats are RIFF WAVE files with the formats PCM (8, 16, 24, and
  713. * 32 bits), IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and
  714. * A-law and mu-law (8 bits). Other formats are currently unsupported and
  715. * cause an error.
  716. *
  717. * If this function succeeds, the pointer returned by it is equal to `spec`
  718. * and the pointer to the audio data allocated by the function is written to
  719. * `audio_buf` and its length in bytes to `audio_len`. The SDL_AudioSpec
  720. * members `freq`, `channels`, and `format` are set to the values of the audio
  721. * data in the buffer. The `samples` member is set to a sane default and all
  722. * others are set to zero.
  723. *
  724. * It's necessary to use SDL_FreeWAV() to free the audio data returned in
  725. * `audio_buf` when it is no longer used.
  726. *
  727. * Because of the underspecification of the .WAV format, there are many
  728. * problematic files in the wild that cause issues with strict decoders. To
  729. * provide compatibility with these files, this decoder is lenient in regards
  730. * to the truncation of the file, the fact chunk, and the size of the RIFF
  731. * chunk. The hints `SDL_HINT_WAVE_RIFF_CHUNK_SIZE`,
  732. * `SDL_HINT_WAVE_TRUNCATION`, and `SDL_HINT_WAVE_FACT_CHUNK` can be used to
  733. * tune the behavior of the loading process.
  734. *
  735. * Any file that is invalid (due to truncation, corruption, or wrong values in
  736. * the headers), too big, or unsupported causes an error. Additionally, any
  737. * critical I/O error from the data source will terminate the loading process
  738. * with an error. The function returns NULL on error and in all cases (with
  739. * the exception of `src` being NULL), an appropriate error message will be
  740. * set.
  741. *
  742. * It is required that the data source supports seeking.
  743. *
  744. * Example:
  745. *
  746. * ```c
  747. * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, &spec, &buf, &len);
  748. * ```
  749. *
  750. * Note that the SDL_LoadWAV macro does this same thing for you, but in a less
  751. * messy way:
  752. *
  753. * ```c
  754. * SDL_LoadWAV("sample.wav", &spec, &buf, &len);
  755. * ```
  756. *
  757. * \param src The data source for the WAVE data
  758. * \param freesrc If non-zero, SDL will _always_ free the data source
  759. * \param spec An SDL_AudioSpec that will be filled in with the wave file's
  760. * format details
  761. * \param audio_buf A pointer filled with the audio data, allocated by the
  762. * function.
  763. * \param audio_len A pointer filled with the length of the audio data buffer
  764. * in bytes
  765. * \returns This function, if successfully called, returns `spec`, which will
  766. * be filled with the audio data format of the wave source data.
  767. * `audio_buf` will be filled with a pointer to an allocated buffer
  768. * containing the audio data, and `audio_len` is filled with the
  769. * length of that audio buffer in bytes.
  770. *
  771. * This function returns NULL if the .WAV file cannot be opened, uses
  772. * an unknown data format, or is corrupt; call SDL_GetError() for
  773. * more information.
  774. *
  775. * When the application is done with the data returned in
  776. * `audio_buf`, it should call SDL_FreeWAV() to dispose of it.
  777. *
  778. * \since This function is available since SDL 2.0.0.
  779. *
  780. * \sa SDL_FreeWAV
  781. * \sa SDL_LoadWAV
  782. *}
  783. function SDL_LoadWAV_RW(src: PSDL_RWops;
  784. freesrc: cint;
  785. spec: PSDL_AudioSpec;
  786. audio_buf: ppcuint8;
  787. audio_len: pcuint32): PSDL_AudioSpec; cdecl;
  788. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LoadWAV_RW' {$ENDIF} {$ENDIF};
  789. {**
  790. * Loads a WAV from a file.
  791. * Compatibility convenience function.
  792. *}
  793. function SDL_LoadWAV(file_: PAnsiChar; spec: PSDL_AudioSpec; audio_buf: ppcuint8; audio_len: pcuint32): PSDL_AudioSpec;
  794. {**
  795. * Free data previously allocated with SDL_LoadWAV() or SDL_LoadWAV_RW().
  796. *
  797. * After a WAVE file has been opened with SDL_LoadWAV() or SDL_LoadWAV_RW()
  798. * its data can eventually be freed with SDL_FreeWAV(). It is safe to call
  799. * this function with a NULL pointer.
  800. *
  801. * \param audio_buf a pointer to the buffer created by SDL_LoadWAV() or
  802. * SDL_LoadWAV_RW()
  803. *
  804. * \since This function is available since SDL 2.0.0.
  805. *
  806. * \sa SDL_LoadWAV
  807. * \sa SDL_LoadWAV_RW
  808. *}
  809. procedure SDL_FreeWAV(audio_buf: pcuint8); cdecl;
  810. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FreeWAV' {$ENDIF} {$ENDIF};
  811. {**
  812. * Initialize an SDL_AudioCVT structure for conversion.
  813. *
  814. * Before an SDL_AudioCVT structure can be used to convert audio data it must
  815. * be initialized with source and destination information.
  816. *
  817. * This function will zero out every field of the SDL_AudioCVT, so it must be
  818. * called before the application fills in the final buffer information.
  819. *
  820. * Once this function has returned successfully, and reported that a
  821. * conversion is necessary, the application fills in the rest of the fields in
  822. * SDL_AudioCVT, now that it knows how large a buffer it needs to allocate,
  823. * and then can call SDL_ConvertAudio() to complete the conversion.
  824. *
  825. * \param cvt an SDL_AudioCVT structure filled in with audio conversion
  826. * information
  827. * \param src_format the source format of the audio data; for more info see
  828. * SDL_AudioFormat
  829. * \param src_channels the number of channels in the source
  830. * \param src_rate the frequency (sample-frames-per-second) of the source
  831. * \param dst_format the destination format of the audio data; for more info
  832. * see SDL_AudioFormat
  833. * \param dst_channels the number of channels in the destination
  834. * \param dst_rate the frequency (sample-frames-per-second) of the destination
  835. * \returns 1 if the audio filter is prepared, 0 if no conversion is needed,
  836. * or a negative error code on failure; call SDL_GetError() for more
  837. * information.
  838. *
  839. * \since This function is available since SDL 2.0.0.
  840. *
  841. * \sa SDL_ConvertAudio
  842. *}
  843. function SDL_BuildAudioCVT(cvt: PSDL_AudioCVT;
  844. src_format: TSDL_AudioFormat;
  845. src_channels: cuint8;
  846. src_rate: cint;
  847. dst_format: TSDL_AudioFormat;
  848. dst_channels: cuint8;
  849. dst_rate: cint): cint; cdecl;
  850. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_BuildAudioCVT' {$ENDIF} {$ENDIF};
  851. {**
  852. * Convert audio data to a desired audio format.
  853. *
  854. * This function does the actual audio data conversion, after the application
  855. * has called SDL_BuildAudioCVT() to prepare the conversion information and
  856. * then filled in the buffer details.
  857. *
  858. * Once the application has initialized the `cvt` structure using
  859. * SDL_BuildAudioCVT(), allocated an audio buffer and filled it with audio
  860. * data in the source format, this function will convert the buffer, in-place,
  861. * to the desired format.
  862. *
  863. * The data conversion may go through several passes; any given pass may
  864. * possibly temporarily increase the size of the data. For example, SDL might
  865. * expand 16-bit data to 32 bits before resampling to a lower frequency,
  866. * shrinking the data size after having grown it briefly. Since the supplied
  867. * buffer will be both the source and destination, converting as necessary
  868. * in-place, the application must allocate a buffer that will fully contain
  869. * the data during its largest conversion pass. After SDL_BuildAudioCVT()
  870. * returns, the application should set the `cvt->len` field to the size, in
  871. * bytes, of the source data, and allocate a buffer that is `cvt->len *
  872. * cvt->len_mult` bytes long for the `buf` field.
  873. *
  874. * The source data should be copied into this buffer before the call to
  875. * SDL_ConvertAudio(). Upon successful return, this buffer will contain the
  876. * converted audio, and `cvt->len_cvt` will be the size of the converted data,
  877. * in bytes. Any bytes in the buffer past `cvt->len_cvt` are undefined once
  878. * this function returns.
  879. *
  880. * \param cvt an SDL_AudioCVT structure that was previously set up by
  881. * SDL_BuildAudioCVT().
  882. * \returns 0 if the conversion was completed successfully or a negative error
  883. * code on failure; call SDL_GetError() for more information.
  884. *
  885. * \since This function is available since SDL 2.0.0.
  886. *
  887. * \sa SDL_BuildAudioCVT
  888. *}
  889. function SDL_ConvertAudio(cvt: PSDL_AudioCVT): cint; cdecl;
  890. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ConvertAudio' {$ENDIF} {$ENDIF};
  891. { SDL_AudioStream is a new audio conversion interface.
  892. The benefits vs SDL_AudioCVT:
  893. - it can handle resampling data in chunks without generating
  894. artifacts, when it doesn't have the complete buffer available.
  895. - it can handle incoming data in any variable size.
  896. - You push data as you have it, and pull it when you need it
  897. }
  898. { this is opaque to the outside world. }
  899. type
  900. PSDL_AudioStream = ^TSDL_AudioStream;
  901. TSDL_AudioStream = record end;
  902. {*
  903. * Create a new audio stream.
  904. *
  905. * \param src_format The format of the source audio
  906. * \param src_channels The number of channels of the source audio
  907. * \param src_rate The sampling rate of the source audio
  908. * \param dst_format The format of the desired audio output
  909. * \param dst_channels The number of channels of the desired audio output
  910. * \param dst_rate The sampling rate of the desired audio output
  911. * \returns 0 on success, or -1 on error.
  912. *
  913. * \since This function is available since SDL 2.0.7.
  914. *
  915. * \sa SDL_AudioStreamPut
  916. * \sa SDL_AudioStreamGet
  917. * \sa SDL_AudioStreamAvailable
  918. * \sa SDL_AudioStreamFlush
  919. * \sa SDL_AudioStreamClear
  920. * \sa SDL_FreeAudioStream
  921. }
  922. function SDL_NewAudioStream(src_format: TSDL_AudioFormat; src_channels: cuint8; src_rate: cint; dst_format: TSDL_AudioFormat; dst_channels: cuint8;
  923. dst_rate: cint): PSDL_AudioStream; cdecl;
  924. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_NewAudioStream' {$ENDIF} {$ENDIF};
  925. {*
  926. * Add data to be converted/resampled to the stream.
  927. *
  928. * \param stream The stream the audio data is being added to
  929. * \param buf A pointer to the audio data to add
  930. * \param len The number of bytes to write to the stream
  931. * \returns 0 on success, or -1 on error.
  932. *
  933. * \since This function is available since SDL 2.0.7.
  934. *
  935. * \sa SDL_NewAudioStream
  936. * \sa SDL_AudioStreamGet
  937. * \sa SDL_AudioStreamAvailable
  938. * \sa SDL_AudioStreamFlush
  939. * \sa SDL_AudioStreamClear
  940. * \sa SDL_FreeAudioStream
  941. }
  942. function SDL_AudioStreamPut(stream: PSDL_AudioStream; buf: pointer; len: cint): cint; cdecl;
  943. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AudioStreamPut' {$ENDIF} {$ENDIF};
  944. {*
  945. * Get converted/resampled data from the stream
  946. *
  947. * \param stream The stream the audio is being requested from
  948. * \param buf A buffer to fill with audio data
  949. * \param len The maximum number of bytes to fill
  950. * \returns the number of bytes read from the stream, or -1 on error
  951. *
  952. * \since This function is available since SDL 2.0.7.
  953. *
  954. * \sa SDL_NewAudioStream
  955. * \sa SDL_AudioStreamPut
  956. * \sa SDL_AudioStreamAvailable
  957. * \sa SDL_AudioStreamFlush
  958. * \sa SDL_AudioStreamClear
  959. * \sa SDL_FreeAudioStream
  960. }
  961. function SDL_AudioStreamGet(stream: PSDL_AudioStream; buf: pointer; len: cint): cint; cdecl;
  962. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AudioStreamGet' {$ENDIF} {$ENDIF};
  963. {*
  964. * Get the number of converted/resampled bytes available.
  965. *
  966. * The stream may be buffering data behind the scenes until it has enough to
  967. * resample correctly, so this number might be lower than what you expect, or
  968. * even be zero. Add more data or flush the stream if you need the data now.
  969. *
  970. * \since This function is available since SDL 2.0.7.
  971. *
  972. * \sa SDL_NewAudioStream
  973. * \sa SDL_AudioStreamPut
  974. * \sa SDL_AudioStreamGet
  975. * \sa SDL_AudioStreamFlush
  976. * \sa SDL_AudioStreamClear
  977. * \sa SDL_FreeAudioStream
  978. }
  979. function SDL_AudioStreamAvailable(stream: PSDL_AudioStream): cint; cdecl;
  980. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AudioStreamAvailable' {$ENDIF} {$ENDIF};
  981. {*
  982. * Tell the stream that you're done sending data, and anything being buffered
  983. * should be converted/resampled and made available immediately.
  984. *
  985. * It is legal to add more data to a stream after flushing, but there will be
  986. * audio gaps in the output. Generally this is intended to signal the end of
  987. * input, so the complete output becomes available.
  988. *
  989. * \since This function is available since SDL 2.0.7.
  990. *
  991. * \sa SDL_NewAudioStream
  992. * \sa SDL_AudioStreamPut
  993. * \sa SDL_AudioStreamGet
  994. * \sa SDL_AudioStreamAvailable
  995. * \sa SDL_AudioStreamClear
  996. * \sa SDL_FreeAudioStream
  997. }
  998. function SDL_AudioStreamFlush(stream: PSDL_AudioStream): cint; cdecl;
  999. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AudioStreamFlush' {$ENDIF} {$ENDIF};
  1000. {*
  1001. * Clear any pending data in the stream without converting it
  1002. *
  1003. * \since This function is available since SDL 2.0.7.
  1004. *
  1005. * \sa SDL_NewAudioStream
  1006. * \sa SDL_AudioStreamPut
  1007. * \sa SDL_AudioStreamGet
  1008. * \sa SDL_AudioStreamAvailable
  1009. * \sa SDL_AudioStreamFlush
  1010. * \sa SDL_FreeAudioStream
  1011. }
  1012. procedure SDL_AudioStreamClear(stream: PSDL_AudioStream); cdecl;
  1013. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AudioStreamClear' {$ENDIF} {$ENDIF};
  1014. {*
  1015. * Free an audio stream
  1016. *
  1017. * \since This function is available since SDL 2.0.7.
  1018. *
  1019. * \sa SDL_NewAudioStream
  1020. * \sa SDL_AudioStreamPut
  1021. * \sa SDL_AudioStreamGet
  1022. * \sa SDL_AudioStreamAvailable
  1023. * \sa SDL_AudioStreamFlush
  1024. * \sa SDL_AudioStreamClear
  1025. }
  1026. procedure SDL_FreeAudioStream(stream: PSDL_AudioStream); cdecl;
  1027. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FreeAudioStream' {$ENDIF} {$ENDIF};
  1028. const
  1029. SDL_MIX_MAXVOLUME = 128;
  1030. {**
  1031. * This function is a legacy means of mixing audio.
  1032. *
  1033. * This function is equivalent to calling...
  1034. *
  1035. * ```c
  1036. * SDL_MixAudioFormat(dst, src, format, len, volume);
  1037. * ```
  1038. *
  1039. * ...where `format` is the obtained format of the audio device from the
  1040. * legacy SDL_OpenAudio() function.
  1041. *
  1042. * \param dst the destination for the mixed audio
  1043. * \param src the source audio buffer to be mixed
  1044. * \param len the length of the audio buffer in bytes
  1045. * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
  1046. * for full audio volume
  1047. *
  1048. * \since This function is available since SDL 2.0.0.
  1049. *
  1050. * \sa SDL_MixAudioFormat
  1051. *}
  1052. procedure SDL_MixAudio(dst: pcuint8; src: pcuint8; len: cuint32; volume: cint); cdecl;
  1053. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_MixAudio' {$ENDIF} {$ENDIF};
  1054. {**
  1055. * Mix audio data in a specified format.
  1056. *
  1057. * This takes an audio buffer `src` of `len` bytes of `format` data and mixes
  1058. * it into `dst`, performing addition, volume adjustment, and overflow
  1059. * clipping. The buffer pointed to by `dst` must also be `len` bytes of
  1060. * `format` data.
  1061. *
  1062. * This is provided for convenience -- you can mix your own audio data.
  1063. *
  1064. * Do not use this function for mixing together more than two streams of
  1065. * sample data. The output from repeated application of this function may be
  1066. * distorted by clipping, because there is no accumulator with greater range
  1067. * than the input (not to mention this being an inefficient way of doing it).
  1068. *
  1069. * It is a common misconception that this function is required to write audio
  1070. * data to an output stream in an audio callback. While you can do that,
  1071. * SDL_MixAudioFormat() is really only needed when you're mixing a single
  1072. * audio stream with a volume adjustment.
  1073. *
  1074. * \param dst the destination for the mixed audio
  1075. * \param src the source audio buffer to be mixed
  1076. * \param format the SDL_AudioFormat structure representing the desired audio
  1077. * format
  1078. * \param len the length of the audio buffer in bytes
  1079. * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
  1080. * for full audio volume
  1081. *
  1082. * \since This function is available since SDL 2.0.0.
  1083. *}
  1084. procedure SDL_MixAudioFormat(dst: pcuint8; src: pcuint8; format: TSDL_AudioFormat; len: cuint32; volume: cint); cdecl;
  1085. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_MixAudioFormat' {$ENDIF} {$ENDIF};
  1086. {**
  1087. * Queue more audio on non-callback devices.
  1088. *
  1089. * If you are looking to retrieve queued audio from a non-callback capture
  1090. * device, you want SDL_DequeueAudio() instead. SDL_QueueAudio() will return
  1091. * -1 to signify an error if you use it with capture devices.
  1092. *
  1093. * SDL offers two ways to feed audio to the device: you can either supply a
  1094. * callback that SDL triggers with some frequency to obtain more audio (pull
  1095. * method), or you can supply no callback, and then SDL will expect you to
  1096. * supply data at regular intervals (push method) with this function.
  1097. *
  1098. * There are no limits on the amount of data you can queue, short of
  1099. * exhaustion of address space. Queued data will drain to the device as
  1100. * necessary without further intervention from you. If the device needs audio
  1101. * but there is not enough queued, it will play silence to make up the
  1102. * difference. This means you will have skips in your audio playback if you
  1103. * aren't routinely queueing sufficient data.
  1104. *
  1105. * This function copies the supplied data, so you are safe to free it when the
  1106. * function returns. This function is thread-safe, but queueing to the same
  1107. * device from two threads at once does not promise which buffer will be
  1108. * queued first.
  1109. *
  1110. * You may not queue audio on a device that is using an application-supplied
  1111. * callback; doing so returns an error. You have to use the audio callback or
  1112. * queue audio with this function, but not both.
  1113. *
  1114. * You should not call SDL_LockAudio() on the device before queueing; SDL
  1115. * handles locking internally for this function.
  1116. *
  1117. * Note that SDL2 does not support planar audio. You will need to resample
  1118. * from planar audio formats into a non-planar one (see SDL_AudioFormat)
  1119. * before queuing audio.
  1120. *
  1121. * \param dev the device ID to which we will queue audio
  1122. * \param data the data to queue to the device for later playback
  1123. * \param len the number of bytes (not samples!) to which `data` points
  1124. * \returns 0 on success or a negative error code on failure; call
  1125. * SDL_GetError() for more information.
  1126. *
  1127. * \since This function is available since SDL 2.0.4.
  1128. *
  1129. * \sa SDL_ClearQueuedAudio
  1130. * \sa SDL_GetQueuedAudioSize
  1131. *}
  1132. function SDL_QueueAudio(dev: TSDL_AudioDeviceID; data: Pointer; len: cuint32): cint; cdecl;
  1133. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_QueueAudio' {$ENDIF} {$ENDIF};
  1134. {**
  1135. * Dequeue more audio on non-callback devices.
  1136. *
  1137. * If you are looking to queue audio for output on a non-callback playback
  1138. * device, you want SDL_QueueAudio() instead. SDL_DequeueAudio() will always
  1139. * return 0 if you use it with playback devices.
  1140. *
  1141. * SDL offers two ways to retrieve audio from a capture device: you can either
  1142. * supply a callback that SDL triggers with some frequency as the device
  1143. * records more audio data, (push method), or you can supply no callback, and
  1144. * then SDL will expect you to retrieve data at regular intervals (pull
  1145. * method) with this function.
  1146. *
  1147. * There are no limits on the amount of data you can queue, short of
  1148. * exhaustion of address space. Data from the device will keep queuing as
  1149. * necessary without further intervention from you. This means you will
  1150. * eventually run out of memory if you aren't routinely dequeueing data.
  1151. *
  1152. * Capture devices will not queue data when paused; if you are expecting to
  1153. * not need captured audio for some length of time, use SDL_PauseAudioDevice()
  1154. * to stop the capture device from queueing more data. This can be useful
  1155. * during, say, level loading times. When unpaused, capture devices will start
  1156. * queueing data from that point, having flushed any capturable data available
  1157. * while paused.
  1158. *
  1159. * This function is thread-safe, but dequeueing from the same device from two
  1160. * threads at once does not promise which thread will dequeue data first.
  1161. *
  1162. * You may not dequeue audio from a device that is using an
  1163. * application-supplied callback; doing so returns an error. You have to use
  1164. * the audio callback, or dequeue audio with this function, but not both.
  1165. *
  1166. * You should not call SDL_LockAudio() on the device before dequeueing; SDL
  1167. * handles locking internally for this function.
  1168. *
  1169. * \param dev the device ID from which we will dequeue audio
  1170. * \param data a pointer into where audio data should be copied
  1171. * \param len the number of bytes (not samples!) to which (data) points
  1172. * \returns the number of bytes dequeued, which could be less than requested;
  1173. * call SDL_GetError() for more information.
  1174. *
  1175. * \since This function is available since SDL 2.0.5.
  1176. *
  1177. * \sa SDL_ClearQueuedAudio
  1178. * \sa SDL_GetQueuedAudioSize
  1179. *}
  1180. function SDL_DequeueAudio(dev: TSDL_AudioDeviceID; data: Pointer; len: cuint32): cuint32; cdecl;
  1181. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_DequeueAudio' {$ENDIF} {$ENDIF};
  1182. {**
  1183. * Get the number of bytes of still-queued audio.
  1184. *
  1185. * For playback devices: this is the number of bytes that have been queued for
  1186. * playback with SDL_QueueAudio(), but have not yet been sent to the hardware.
  1187. *
  1188. * Once we've sent it to the hardware, this function can not decide the exact
  1189. * byte boundary of what has been played. It's possible that we just gave the
  1190. * hardware several kilobytes right before you called this function, but it
  1191. * hasn't played any of it yet, or maybe half of it, etc.
  1192. *
  1193. * For capture devices, this is the number of bytes that have been captured by
  1194. * the device and are waiting for you to dequeue. This number may grow at any
  1195. * time, so this only informs of the lower-bound of available data.
  1196. *
  1197. * You may not queue or dequeue audio on a device that is using an
  1198. * application-supplied callback; calling this function on such a device
  1199. * always returns 0. You have to use the audio callback or queue audio, but
  1200. * not both.
  1201. *
  1202. * You should not call SDL_LockAudio() on the device before querying; SDL
  1203. * handles locking internally for this function.
  1204. *
  1205. * \param dev the device ID of which we will query queued audio size
  1206. * \returns the number of bytes (not samples!) of queued audio.
  1207. *
  1208. * \since This function is available since SDL 2.0.4.
  1209. *
  1210. * \sa SDL_ClearQueuedAudio
  1211. * \sa SDL_QueueAudio
  1212. * \sa SDL_DequeueAudio
  1213. *}
  1214. function SDL_GetQueuedAudioSize(dev: TSDL_AudioDeviceID): cuint32; cdecl;
  1215. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetQueuedAudioSize' {$ENDIF} {$ENDIF};
  1216. {**
  1217. * Drop any queued audio data waiting to be sent to the hardware.
  1218. *
  1219. * Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For
  1220. * output devices, the hardware will start playing silence if more audio isn't
  1221. * queued. For capture devices, the hardware will start filling the empty
  1222. * queue with new data if the capture device isn't paused.
  1223. *
  1224. * This will not prevent playback of queued audio that's already been sent to
  1225. * the hardware, as we can not undo that, so expect there to be some fraction
  1226. * of a second of audio that might still be heard. This can be useful if you
  1227. * want to, say, drop any pending music or any unprocessed microphone input
  1228. * during a level change in your game.
  1229. *
  1230. * You may not queue or dequeue audio on a device that is using an
  1231. * application-supplied callback; calling this function on such a device
  1232. * always returns 0. You have to use the audio callback or queue audio, but
  1233. * not both.
  1234. *
  1235. * You should not call SDL_LockAudio() on the device before clearing the
  1236. * queue; SDL handles locking internally for this function.
  1237. *
  1238. * This function always succeeds and thus returns void.
  1239. *
  1240. * \param dev the device ID of which to clear the audio queue
  1241. *
  1242. * \since This function is available since SDL 2.0.4.
  1243. *
  1244. * \sa SDL_GetQueuedAudioSize
  1245. * \sa SDL_QueueAudio
  1246. * \sa SDL_DequeueAudio
  1247. *}
  1248. procedure SDL_ClearQueuedAudio(dev: TSDL_AudioDeviceID); cdecl;
  1249. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ClearQueuedAudio' {$ENDIF} {$ENDIF};
  1250. {**
  1251. * Audio lock functions
  1252. *
  1253. * The lock manipulated by these functions protects the callback function.
  1254. * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that
  1255. * the callback function is not running. Do not call these from the callback
  1256. * function or you will cause deadlock.
  1257. *}
  1258. {**
  1259. * This function is a legacy means of locking the audio device.
  1260. *
  1261. * New programs might want to use SDL_LockAudioDevice() instead. This function
  1262. * is equivalent to calling...
  1263. *
  1264. * ```c
  1265. * SDL_LockAudioDevice(1);
  1266. * ```
  1267. *
  1268. * ...and is only useful if you used the legacy SDL_OpenAudio() function.
  1269. *
  1270. * \since This function is available since SDL 2.0.0.
  1271. *
  1272. * \sa SDL_LockAudioDevice
  1273. * \sa SDL_UnlockAudio
  1274. * \sa SDL_UnlockAudioDevice
  1275. *}
  1276. procedure SDL_LockAudio; cdecl;
  1277. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LockAudio' {$ENDIF} {$ENDIF};
  1278. {**
  1279. * Use this function to lock out the audio callback function for a specified
  1280. * device.
  1281. *
  1282. * The lock manipulated by these functions protects the audio callback
  1283. * function specified in SDL_OpenAudioDevice(). During a
  1284. * SDL_LockAudioDevice()/SDL_UnlockAudioDevice() pair, you can be guaranteed
  1285. * that the callback function for that device is not running, even if the
  1286. * device is not paused. While a device is locked, any other unpaused,
  1287. * unlocked devices may still run their callbacks.
  1288. *
  1289. * Calling this function from inside your audio callback is unnecessary. SDL
  1290. * obtains this lock before calling your function, and releases it when the
  1291. * function returns.
  1292. *
  1293. * You should not hold the lock longer than absolutely necessary. If you hold
  1294. * it too long, you'll experience dropouts in your audio playback. Ideally,
  1295. * your application locks the device, sets a few variables and unlocks again.
  1296. * Do not do heavy work while holding the lock for a device.
  1297. *
  1298. * It is safe to lock the audio device multiple times, as long as you unlock
  1299. * it an equivalent number of times. The callback will not run until the
  1300. * device has been unlocked completely in this way. If your application fails
  1301. * to unlock the device appropriately, your callback will never run, you might
  1302. * hear repeating bursts of audio, and SDL_CloseAudioDevice() will probably
  1303. * deadlock.
  1304. *
  1305. * Internally, the audio device lock is a mutex; if you lock from two threads
  1306. * at once, not only will you block the audio callback, you'll block the other
  1307. * thread.
  1308. *
  1309. * \param dev the ID of the device to be locked
  1310. *
  1311. * \since This function is available since SDL 2.0.0.
  1312. *
  1313. * \sa SDL_UnlockAudioDevice
  1314. *}
  1315. procedure SDL_LockAudioDevice(dev: TSDL_AudioDeviceID); cdecl;
  1316. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LockAudioDevice' {$ENDIF} {$ENDIF};
  1317. {**
  1318. * This function is a legacy means of unlocking the audio device.
  1319. *
  1320. * New programs might want to use SDL_UnlockAudioDevice() instead. This
  1321. * function is equivalent to calling...
  1322. *
  1323. * ```c
  1324. * SDL_UnlockAudioDevice(1);
  1325. * ```
  1326. *
  1327. * ...and is only useful if you used the legacy SDL_OpenAudio() function.
  1328. *
  1329. * \since This function is available since SDL 2.0.0.
  1330. *
  1331. * \sa SDL_LockAudio
  1332. * \sa SDL_UnlockAudioDevice
  1333. *}
  1334. procedure SDL_UnlockAudio; cdecl;
  1335. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_Unlock' {$ENDIF} {$ENDIF};
  1336. {**
  1337. * Use this function to unlock the audio callback function for a specified
  1338. * device.
  1339. *
  1340. * This function should be paired with a previous SDL_LockAudioDevice() call.
  1341. *
  1342. * \param dev the ID of the device to be unlocked
  1343. *
  1344. * \since This function is available since SDL 2.0.0.
  1345. *
  1346. * \sa SDL_LockAudioDevice
  1347. *}
  1348. procedure SDL_UnlockAudioDevice(dev: TSDL_AudioDeviceID); cdecl;
  1349. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UnlockAudioDevice' {$ENDIF} {$ENDIF};
  1350. {*Audio lock functions*}
  1351. {**
  1352. * This function is a legacy means of closing the audio device.
  1353. *
  1354. * This function is equivalent to calling...
  1355. *
  1356. * ```c
  1357. * SDL_CloseAudioDevice(1);
  1358. * ```
  1359. *
  1360. * ...and is only useful if you used the legacy SDL_OpenAudio() function.
  1361. *
  1362. * \since This function is available since SDL 2.0.0.
  1363. *
  1364. * \sa SDL_OpenAudio
  1365. *}
  1366. procedure SDL_CloseAudio; cdecl;
  1367. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_CloseAudio' {$ENDIF} {$ENDIF};
  1368. {**
  1369. * Use this function to shut down audio processing and close the audio device.
  1370. *
  1371. * The application should close open audio devices once they are no longer
  1372. * needed. Calling this function will wait until the device's audio callback
  1373. * is not running, release the audio hardware and then clean up internal
  1374. * state. No further audio will play from this device once this function
  1375. * returns.
  1376. *
  1377. * This function may block briefly while pending audio data is played by the
  1378. * hardware, so that applications don't drop the last buffer of data they
  1379. * supplied.
  1380. *
  1381. * The device ID is invalid as soon as the device is closed, and is eligible
  1382. * for reuse in a new SDL_OpenAudioDevice() call immediately.
  1383. *
  1384. * \param dev an audio device previously opened with SDL_OpenAudioDevice()
  1385. *
  1386. * \since This function is available since SDL 2.0.0.
  1387. *
  1388. * \sa SDL_OpenAudioDevice
  1389. *}
  1390. procedure SDL_CloseAudioDevice(dev: TSDL_AudioDeviceID); cdecl;
  1391. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_CloseAudioDevice' {$ENDIF} {$ENDIF};