pcm.h 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. /**
  2. * \file include/pcm.h
  3. * \brief Application interface library for the ALSA driver
  4. * \author Jaroslav Kysela <perex@perex.cz>
  5. * \author Abramo Bagnara <abramo@alsa-project.org>
  6. * \author Takashi Iwai <tiwai@suse.de>
  7. * \date 1998-2001
  8. *
  9. * Application interface library for the ALSA driver.
  10. * See the \ref pcm page for more details.
  11. */
  12. /*
  13. * This library is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU Lesser General Public License as
  15. * published by the Free Software Foundation; either version 2.1 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Lesser General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Lesser General Public
  24. * License along with this library; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. *
  27. */
  28. #ifndef __ALSA_PCM_H
  29. #define __ALSA_PCM_H
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /**
  34. * \defgroup PCM PCM Interface
  35. * See the \ref pcm page for more details.
  36. * \{
  37. */
  38. /** dlsym version for interface entry callback */
  39. #define SND_PCM_DLSYM_VERSION _dlsym_pcm_001
  40. /** PCM generic info container */
  41. typedef struct _snd_pcm_info snd_pcm_info_t;
  42. /** PCM hardware configuration space container
  43. *
  44. * snd_pcm_hw_params_t is an opaque structure which contains a set of possible
  45. * PCM hardware configurations. For example, a given instance might include a
  46. * range of buffer sizes, a range of period sizes, and a set of several sample
  47. * formats. Some subset of all possible combinations these sets may be valid,
  48. * but not necessarily any combination will be valid.
  49. *
  50. * When a parameter is set or restricted using a snd_pcm_hw_params_set*
  51. * function, all of the other ranges will be updated to exclude as many
  52. * impossible configurations as possible. Attempting to set a parameter
  53. * outside of its acceptable range will result in the function failing
  54. * and an error code being returned.
  55. */
  56. typedef struct _snd_pcm_hw_params snd_pcm_hw_params_t;
  57. /** PCM software configuration container */
  58. typedef struct _snd_pcm_sw_params snd_pcm_sw_params_t;
  59. /** PCM status container */
  60. typedef struct _snd_pcm_status snd_pcm_status_t;
  61. /** PCM access types mask */
  62. typedef struct _snd_pcm_access_mask snd_pcm_access_mask_t;
  63. /** PCM formats mask */
  64. typedef struct _snd_pcm_format_mask snd_pcm_format_mask_t;
  65. /** PCM subformats mask */
  66. typedef struct _snd_pcm_subformat_mask snd_pcm_subformat_mask_t;
  67. /** PCM class */
  68. typedef enum _snd_pcm_class {
  69. /** standard device */
  70. SND_PCM_CLASS_GENERIC = 0,
  71. /** multichannel device */
  72. SND_PCM_CLASS_MULTI,
  73. /** software modem device */
  74. SND_PCM_CLASS_MODEM,
  75. /** digitizer device */
  76. SND_PCM_CLASS_DIGITIZER,
  77. SND_PCM_CLASS_LAST = SND_PCM_CLASS_DIGITIZER
  78. } snd_pcm_class_t;
  79. /** PCM subclass */
  80. typedef enum _snd_pcm_subclass {
  81. /** subdevices are mixed together */
  82. SND_PCM_SUBCLASS_GENERIC_MIX = 0,
  83. /** multichannel subdevices are mixed together */
  84. SND_PCM_SUBCLASS_MULTI_MIX,
  85. SND_PCM_SUBCLASS_LAST = SND_PCM_SUBCLASS_MULTI_MIX
  86. } snd_pcm_subclass_t;
  87. /** PCM stream (direction) */
  88. typedef enum _snd_pcm_stream {
  89. /** Playback stream */
  90. SND_PCM_STREAM_PLAYBACK = 0,
  91. /** Capture stream */
  92. SND_PCM_STREAM_CAPTURE,
  93. SND_PCM_STREAM_LAST = SND_PCM_STREAM_CAPTURE
  94. } snd_pcm_stream_t;
  95. /** PCM access type */
  96. typedef enum _snd_pcm_access {
  97. /** mmap access with simple interleaved channels */
  98. SND_PCM_ACCESS_MMAP_INTERLEAVED = 0,
  99. /** mmap access with simple non interleaved channels */
  100. SND_PCM_ACCESS_MMAP_NONINTERLEAVED,
  101. /** mmap access with complex placement */
  102. SND_PCM_ACCESS_MMAP_COMPLEX,
  103. /** snd_pcm_readi/snd_pcm_writei access */
  104. SND_PCM_ACCESS_RW_INTERLEAVED,
  105. /** snd_pcm_readn/snd_pcm_writen access */
  106. SND_PCM_ACCESS_RW_NONINTERLEAVED,
  107. SND_PCM_ACCESS_LAST = SND_PCM_ACCESS_RW_NONINTERLEAVED
  108. } snd_pcm_access_t;
  109. /** PCM sample format */
  110. typedef enum _snd_pcm_format {
  111. /** Unknown */
  112. SND_PCM_FORMAT_UNKNOWN = -1,
  113. /** Signed 8 bit */
  114. SND_PCM_FORMAT_S8 = 0,
  115. /** Unsigned 8 bit */
  116. SND_PCM_FORMAT_U8,
  117. /** Signed 16 bit Little Endian */
  118. SND_PCM_FORMAT_S16_LE,
  119. /** Signed 16 bit Big Endian */
  120. SND_PCM_FORMAT_S16_BE,
  121. /** Unsigned 16 bit Little Endian */
  122. SND_PCM_FORMAT_U16_LE,
  123. /** Unsigned 16 bit Big Endian */
  124. SND_PCM_FORMAT_U16_BE,
  125. /** Signed 24 bit Little Endian using low three bytes in 32-bit word */
  126. SND_PCM_FORMAT_S24_LE,
  127. /** Signed 24 bit Big Endian using low three bytes in 32-bit word */
  128. SND_PCM_FORMAT_S24_BE,
  129. /** Unsigned 24 bit Little Endian using low three bytes in 32-bit word */
  130. SND_PCM_FORMAT_U24_LE,
  131. /** Unsigned 24 bit Big Endian using low three bytes in 32-bit word */
  132. SND_PCM_FORMAT_U24_BE,
  133. /** Signed 32 bit Little Endian */
  134. SND_PCM_FORMAT_S32_LE,
  135. /** Signed 32 bit Big Endian */
  136. SND_PCM_FORMAT_S32_BE,
  137. /** Unsigned 32 bit Little Endian */
  138. SND_PCM_FORMAT_U32_LE,
  139. /** Unsigned 32 bit Big Endian */
  140. SND_PCM_FORMAT_U32_BE,
  141. /** Float 32 bit Little Endian, Range -1.0 to 1.0 */
  142. SND_PCM_FORMAT_FLOAT_LE,
  143. /** Float 32 bit Big Endian, Range -1.0 to 1.0 */
  144. SND_PCM_FORMAT_FLOAT_BE,
  145. /** Float 64 bit Little Endian, Range -1.0 to 1.0 */
  146. SND_PCM_FORMAT_FLOAT64_LE,
  147. /** Float 64 bit Big Endian, Range -1.0 to 1.0 */
  148. SND_PCM_FORMAT_FLOAT64_BE,
  149. /** IEC-958 Little Endian */
  150. SND_PCM_FORMAT_IEC958_SUBFRAME_LE,
  151. /** IEC-958 Big Endian */
  152. SND_PCM_FORMAT_IEC958_SUBFRAME_BE,
  153. /** Mu-Law */
  154. SND_PCM_FORMAT_MU_LAW,
  155. /** A-Law */
  156. SND_PCM_FORMAT_A_LAW,
  157. /** Ima-ADPCM */
  158. SND_PCM_FORMAT_IMA_ADPCM,
  159. /** MPEG */
  160. SND_PCM_FORMAT_MPEG,
  161. /** GSM */
  162. SND_PCM_FORMAT_GSM,
  163. /** Special */
  164. SND_PCM_FORMAT_SPECIAL = 31,
  165. /** Signed 24bit Little Endian in 3bytes format */
  166. SND_PCM_FORMAT_S24_3LE = 32,
  167. /** Signed 24bit Big Endian in 3bytes format */
  168. SND_PCM_FORMAT_S24_3BE,
  169. /** Unsigned 24bit Little Endian in 3bytes format */
  170. SND_PCM_FORMAT_U24_3LE,
  171. /** Unsigned 24bit Big Endian in 3bytes format */
  172. SND_PCM_FORMAT_U24_3BE,
  173. /** Signed 20bit Little Endian in 3bytes format */
  174. SND_PCM_FORMAT_S20_3LE,
  175. /** Signed 20bit Big Endian in 3bytes format */
  176. SND_PCM_FORMAT_S20_3BE,
  177. /** Unsigned 20bit Little Endian in 3bytes format */
  178. SND_PCM_FORMAT_U20_3LE,
  179. /** Unsigned 20bit Big Endian in 3bytes format */
  180. SND_PCM_FORMAT_U20_3BE,
  181. /** Signed 18bit Little Endian in 3bytes format */
  182. SND_PCM_FORMAT_S18_3LE,
  183. /** Signed 18bit Big Endian in 3bytes format */
  184. SND_PCM_FORMAT_S18_3BE,
  185. /** Unsigned 18bit Little Endian in 3bytes format */
  186. SND_PCM_FORMAT_U18_3LE,
  187. /** Unsigned 18bit Big Endian in 3bytes format */
  188. SND_PCM_FORMAT_U18_3BE,
  189. /* G.723 (ADPCM) 24 kbit/s, 8 samples in 3 bytes */
  190. SND_PCM_FORMAT_G723_24,
  191. /* G.723 (ADPCM) 24 kbit/s, 1 sample in 1 byte */
  192. SND_PCM_FORMAT_G723_24_1B,
  193. /* G.723 (ADPCM) 40 kbit/s, 8 samples in 3 bytes */
  194. SND_PCM_FORMAT_G723_40,
  195. /* G.723 (ADPCM) 40 kbit/s, 1 sample in 1 byte */
  196. SND_PCM_FORMAT_G723_40_1B,
  197. /* Direct Stream Digital (DSD) in 1-byte samples (x8) */
  198. SND_PCM_FORMAT_DSD_U8,
  199. /* Direct Stream Digital (DSD) in 2-byte samples (x16) */
  200. SND_PCM_FORMAT_DSD_U16_LE,
  201. /* Direct Stream Digital (DSD) in 4-byte samples (x32) */
  202. SND_PCM_FORMAT_DSD_U32_LE,
  203. /* Direct Stream Digital (DSD) in 2-byte samples (x16) */
  204. SND_PCM_FORMAT_DSD_U16_BE,
  205. /* Direct Stream Digital (DSD) in 4-byte samples (x32) */
  206. SND_PCM_FORMAT_DSD_U32_BE,
  207. SND_PCM_FORMAT_LAST = SND_PCM_FORMAT_DSD_U32_BE,
  208. #if __BYTE_ORDER == __LITTLE_ENDIAN
  209. /** Signed 16 bit CPU endian */
  210. SND_PCM_FORMAT_S16 = SND_PCM_FORMAT_S16_LE,
  211. /** Unsigned 16 bit CPU endian */
  212. SND_PCM_FORMAT_U16 = SND_PCM_FORMAT_U16_LE,
  213. /** Signed 24 bit CPU endian */
  214. SND_PCM_FORMAT_S24 = SND_PCM_FORMAT_S24_LE,
  215. /** Unsigned 24 bit CPU endian */
  216. SND_PCM_FORMAT_U24 = SND_PCM_FORMAT_U24_LE,
  217. /** Signed 32 bit CPU endian */
  218. SND_PCM_FORMAT_S32 = SND_PCM_FORMAT_S32_LE,
  219. /** Unsigned 32 bit CPU endian */
  220. SND_PCM_FORMAT_U32 = SND_PCM_FORMAT_U32_LE,
  221. /** Float 32 bit CPU endian */
  222. SND_PCM_FORMAT_FLOAT = SND_PCM_FORMAT_FLOAT_LE,
  223. /** Float 64 bit CPU endian */
  224. SND_PCM_FORMAT_FLOAT64 = SND_PCM_FORMAT_FLOAT64_LE,
  225. /** IEC-958 CPU Endian */
  226. SND_PCM_FORMAT_IEC958_SUBFRAME = SND_PCM_FORMAT_IEC958_SUBFRAME_LE
  227. #elif __BYTE_ORDER == __BIG_ENDIAN
  228. /** Signed 16 bit CPU endian */
  229. SND_PCM_FORMAT_S16 = SND_PCM_FORMAT_S16_BE,
  230. /** Unsigned 16 bit CPU endian */
  231. SND_PCM_FORMAT_U16 = SND_PCM_FORMAT_U16_BE,
  232. /** Signed 24 bit CPU endian */
  233. SND_PCM_FORMAT_S24 = SND_PCM_FORMAT_S24_BE,
  234. /** Unsigned 24 bit CPU endian */
  235. SND_PCM_FORMAT_U24 = SND_PCM_FORMAT_U24_BE,
  236. /** Signed 32 bit CPU endian */
  237. SND_PCM_FORMAT_S32 = SND_PCM_FORMAT_S32_BE,
  238. /** Unsigned 32 bit CPU endian */
  239. SND_PCM_FORMAT_U32 = SND_PCM_FORMAT_U32_BE,
  240. /** Float 32 bit CPU endian */
  241. SND_PCM_FORMAT_FLOAT = SND_PCM_FORMAT_FLOAT_BE,
  242. /** Float 64 bit CPU endian */
  243. SND_PCM_FORMAT_FLOAT64 = SND_PCM_FORMAT_FLOAT64_BE,
  244. /** IEC-958 CPU Endian */
  245. SND_PCM_FORMAT_IEC958_SUBFRAME = SND_PCM_FORMAT_IEC958_SUBFRAME_BE
  246. #else
  247. #error "Unknown endian"
  248. #endif
  249. } snd_pcm_format_t;
  250. /** PCM sample subformat */
  251. typedef enum _snd_pcm_subformat {
  252. /** Standard */
  253. SND_PCM_SUBFORMAT_STD = 0,
  254. SND_PCM_SUBFORMAT_LAST = SND_PCM_SUBFORMAT_STD
  255. } snd_pcm_subformat_t;
  256. /** PCM state */
  257. typedef enum _snd_pcm_state {
  258. /** Open */
  259. SND_PCM_STATE_OPEN = 0,
  260. /** Setup installed */
  261. SND_PCM_STATE_SETUP,
  262. /** Ready to start */
  263. SND_PCM_STATE_PREPARED,
  264. /** Running */
  265. SND_PCM_STATE_RUNNING,
  266. /** Stopped: underrun (playback) or overrun (capture) detected */
  267. SND_PCM_STATE_XRUN,
  268. /** Draining: running (playback) or stopped (capture) */
  269. SND_PCM_STATE_DRAINING,
  270. /** Paused */
  271. SND_PCM_STATE_PAUSED,
  272. /** Hardware is suspended */
  273. SND_PCM_STATE_SUSPENDED,
  274. /** Hardware is disconnected */
  275. SND_PCM_STATE_DISCONNECTED,
  276. SND_PCM_STATE_LAST = SND_PCM_STATE_DISCONNECTED
  277. } snd_pcm_state_t;
  278. /** PCM start mode */
  279. typedef enum _snd_pcm_start {
  280. /** Automatic start on data read/write */
  281. SND_PCM_START_DATA = 0,
  282. /** Explicit start */
  283. SND_PCM_START_EXPLICIT,
  284. SND_PCM_START_LAST = SND_PCM_START_EXPLICIT
  285. } snd_pcm_start_t;
  286. /** PCM xrun mode */
  287. typedef enum _snd_pcm_xrun {
  288. /** Xrun detection disabled */
  289. SND_PCM_XRUN_NONE = 0,
  290. /** Stop on xrun detection */
  291. SND_PCM_XRUN_STOP,
  292. SND_PCM_XRUN_LAST = SND_PCM_XRUN_STOP
  293. } snd_pcm_xrun_t;
  294. /** PCM timestamp mode */
  295. typedef enum _snd_pcm_tstamp {
  296. /** No timestamp */
  297. SND_PCM_TSTAMP_NONE = 0,
  298. /** Update timestamp at every hardware position update */
  299. SND_PCM_TSTAMP_ENABLE,
  300. /** Equivalent with #SND_PCM_TSTAMP_ENABLE,
  301. * just for compatibility with older versions
  302. */
  303. SND_PCM_TSTAMP_MMAP = SND_PCM_TSTAMP_ENABLE,
  304. SND_PCM_TSTAMP_LAST = SND_PCM_TSTAMP_ENABLE
  305. } snd_pcm_tstamp_t;
  306. typedef enum _snd_pcm_tstamp_type {
  307. SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, /**< gettimeofday equivalent */
  308. SND_PCM_TSTAMP_TYPE_MONOTONIC, /**< posix_clock_monotonic equivalent */
  309. SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW, /**< monotonic_raw (no NTP) */
  310. SND_PCM_TSTAMP_TYPE_LAST = SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW,
  311. } snd_pcm_tstamp_type_t;
  312. typedef struct _snd_pcm_audio_tstamp_config {
  313. /* 5 of max 16 bits used */
  314. unsigned int type_requested:4;
  315. unsigned int report_delay:1; /* add total delay to A/D or D/A */
  316. } snd_pcm_audio_tstamp_config_t;
  317. typedef struct _snd_pcm_audio_tstamp_report {
  318. /* 6 of max 16 bits used for bit-fields */
  319. /* for backwards compatibility */
  320. unsigned int valid:1;
  321. /* actual type if hardware could not support requested timestamp */
  322. unsigned int actual_type:4;
  323. /* accuracy represented in ns units */
  324. unsigned int accuracy_report:1; /* 0 if accuracy unknown, 1 if accuracy field is valid */
  325. unsigned int accuracy; /* up to 4.29s, will be packed in separate field */
  326. } snd_pcm_audio_tstamp_report_t;
  327. /** Unsigned frames quantity */
  328. typedef unsigned long snd_pcm_uframes_t;
  329. /** Signed frames quantity */
  330. typedef long snd_pcm_sframes_t;
  331. /** Non blocking mode (flag for open mode) \hideinitializer */
  332. #define SND_PCM_NONBLOCK 0x00000001
  333. /** Async notification (flag for open mode) \hideinitializer */
  334. #define SND_PCM_ASYNC 0x00000002
  335. /** In an abort state (internal, not allowed for open) */
  336. #define SND_PCM_ABORT 0x00008000
  337. /** Disable automatic (but not forced!) rate resamplinig */
  338. #define SND_PCM_NO_AUTO_RESAMPLE 0x00010000
  339. /** Disable automatic (but not forced!) channel conversion */
  340. #define SND_PCM_NO_AUTO_CHANNELS 0x00020000
  341. /** Disable automatic (but not forced!) format conversion */
  342. #define SND_PCM_NO_AUTO_FORMAT 0x00040000
  343. /** Disable soft volume control */
  344. #define SND_PCM_NO_SOFTVOL 0x00080000
  345. /** PCM handle */
  346. typedef struct _snd_pcm snd_pcm_t;
  347. /** PCM type */
  348. enum _snd_pcm_type {
  349. /** Kernel level PCM */
  350. SND_PCM_TYPE_HW = 0,
  351. /** Hooked PCM */
  352. SND_PCM_TYPE_HOOKS,
  353. /** One or more linked PCM with exclusive access to selected
  354. channels */
  355. SND_PCM_TYPE_MULTI,
  356. /** File writing plugin */
  357. SND_PCM_TYPE_FILE,
  358. /** Null endpoint PCM */
  359. SND_PCM_TYPE_NULL,
  360. /** Shared memory client PCM */
  361. SND_PCM_TYPE_SHM,
  362. /** INET client PCM (not yet implemented) */
  363. SND_PCM_TYPE_INET,
  364. /** Copying plugin */
  365. SND_PCM_TYPE_COPY,
  366. /** Linear format conversion PCM */
  367. SND_PCM_TYPE_LINEAR,
  368. /** A-Law format conversion PCM */
  369. SND_PCM_TYPE_ALAW,
  370. /** Mu-Law format conversion PCM */
  371. SND_PCM_TYPE_MULAW,
  372. /** IMA-ADPCM format conversion PCM */
  373. SND_PCM_TYPE_ADPCM,
  374. /** Rate conversion PCM */
  375. SND_PCM_TYPE_RATE,
  376. /** Attenuated static route PCM */
  377. SND_PCM_TYPE_ROUTE,
  378. /** Format adjusted PCM */
  379. SND_PCM_TYPE_PLUG,
  380. /** Sharing PCM */
  381. SND_PCM_TYPE_SHARE,
  382. /** Meter plugin */
  383. SND_PCM_TYPE_METER,
  384. /** Mixing PCM */
  385. SND_PCM_TYPE_MIX,
  386. /** Attenuated dynamic route PCM (not yet implemented) */
  387. SND_PCM_TYPE_DROUTE,
  388. /** Loopback server plugin (not yet implemented) */
  389. SND_PCM_TYPE_LBSERVER,
  390. /** Linear Integer <-> Linear Float format conversion PCM */
  391. SND_PCM_TYPE_LINEAR_FLOAT,
  392. /** LADSPA integration plugin */
  393. SND_PCM_TYPE_LADSPA,
  394. /** Direct Mixing plugin */
  395. SND_PCM_TYPE_DMIX,
  396. /** Jack Audio Connection Kit plugin */
  397. SND_PCM_TYPE_JACK,
  398. /** Direct Snooping plugin */
  399. SND_PCM_TYPE_DSNOOP,
  400. /** Direct Sharing plugin */
  401. SND_PCM_TYPE_DSHARE,
  402. /** IEC958 subframe plugin */
  403. SND_PCM_TYPE_IEC958,
  404. /** Soft volume plugin */
  405. SND_PCM_TYPE_SOFTVOL,
  406. /** External I/O plugin */
  407. SND_PCM_TYPE_IOPLUG,
  408. /** External filter plugin */
  409. SND_PCM_TYPE_EXTPLUG,
  410. /** Mmap-emulation plugin */
  411. SND_PCM_TYPE_MMAP_EMUL,
  412. SND_PCM_TYPE_LAST = SND_PCM_TYPE_MMAP_EMUL
  413. };
  414. /** PCM type */
  415. typedef enum _snd_pcm_type snd_pcm_type_t;
  416. /** PCM area specification */
  417. typedef struct _snd_pcm_channel_area {
  418. /** base address of channel samples */
  419. void *addr;
  420. /** offset to first sample in bits */
  421. unsigned int first;
  422. /** samples distance in bits */
  423. unsigned int step;
  424. } snd_pcm_channel_area_t;
  425. /** PCM synchronization ID */
  426. typedef union _snd_pcm_sync_id {
  427. /** 8-bit ID */
  428. unsigned char id[16];
  429. /** 16-bit ID */
  430. unsigned short id16[8];
  431. /** 32-bit ID */
  432. unsigned int id32[4];
  433. } snd_pcm_sync_id_t;
  434. /** #SND_PCM_TYPE_METER scope handle */
  435. typedef struct _snd_pcm_scope snd_pcm_scope_t;
  436. int snd_pcm_open(snd_pcm_t **pcm, const char *name,
  437. snd_pcm_stream_t stream, int mode);
  438. int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name,
  439. snd_pcm_stream_t stream, int mode,
  440. snd_config_t *lconf);
  441. int snd_pcm_open_fallback(snd_pcm_t **pcm, snd_config_t *root,
  442. const char *name, const char *orig_name,
  443. snd_pcm_stream_t stream, int mode);
  444. int snd_pcm_close(snd_pcm_t *pcm);
  445. const char *snd_pcm_name(snd_pcm_t *pcm);
  446. snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm);
  447. snd_pcm_stream_t snd_pcm_stream(snd_pcm_t *pcm);
  448. int snd_pcm_poll_descriptors_count(snd_pcm_t *pcm);
  449. int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
  450. int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
  451. int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
  452. static __inline__ int snd_pcm_abort(snd_pcm_t *pcm) { return snd_pcm_nonblock(pcm, 2); }
  453. int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm,
  454. snd_async_callback_t callback, void *private_data);
  455. snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler);
  456. int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
  457. int snd_pcm_hw_params_current(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
  458. int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
  459. int snd_pcm_hw_free(snd_pcm_t *pcm);
  460. int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
  461. int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
  462. int snd_pcm_prepare(snd_pcm_t *pcm);
  463. int snd_pcm_reset(snd_pcm_t *pcm);
  464. int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status);
  465. int snd_pcm_start(snd_pcm_t *pcm);
  466. int snd_pcm_drop(snd_pcm_t *pcm);
  467. int snd_pcm_drain(snd_pcm_t *pcm);
  468. int snd_pcm_pause(snd_pcm_t *pcm, int enable);
  469. snd_pcm_state_t snd_pcm_state(snd_pcm_t *pcm);
  470. int snd_pcm_hwsync(snd_pcm_t *pcm);
  471. int snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
  472. int snd_pcm_resume(snd_pcm_t *pcm);
  473. int snd_pcm_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail, snd_htimestamp_t *tstamp);
  474. snd_pcm_sframes_t snd_pcm_avail(snd_pcm_t *pcm);
  475. snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm);
  476. int snd_pcm_avail_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *availp, snd_pcm_sframes_t *delayp);
  477. snd_pcm_sframes_t snd_pcm_rewindable(snd_pcm_t *pcm);
  478. snd_pcm_sframes_t snd_pcm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
  479. snd_pcm_sframes_t snd_pcm_forwardable(snd_pcm_t *pcm);
  480. snd_pcm_sframes_t snd_pcm_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
  481. snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
  482. snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
  483. snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
  484. snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
  485. int snd_pcm_wait(snd_pcm_t *pcm, int timeout);
  486. int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2);
  487. int snd_pcm_unlink(snd_pcm_t *pcm);
  488. /** channel mapping API version number */
  489. #define SND_CHMAP_API_VERSION ((1 << 16) | (0 << 8) | 1)
  490. /** channel map list type */
  491. enum snd_pcm_chmap_type {
  492. SND_CHMAP_TYPE_NONE = 0,/**< unspecified channel position */
  493. SND_CHMAP_TYPE_FIXED, /**< fixed channel position */
  494. SND_CHMAP_TYPE_VAR, /**< freely swappable channel position */
  495. SND_CHMAP_TYPE_PAIRED, /**< pair-wise swappable channel position */
  496. SND_CHMAP_TYPE_LAST = SND_CHMAP_TYPE_PAIRED, /**< last entry */
  497. };
  498. /** channel positions */
  499. enum snd_pcm_chmap_position {
  500. SND_CHMAP_UNKNOWN = 0, /**< unspecified */
  501. SND_CHMAP_NA, /**< N/A, silent */
  502. SND_CHMAP_MONO, /**< mono stream */
  503. SND_CHMAP_FL, /**< front left */
  504. SND_CHMAP_FR, /**< front right */
  505. SND_CHMAP_RL, /**< rear left */
  506. SND_CHMAP_RR, /**< rear right */
  507. SND_CHMAP_FC, /**< front center */
  508. SND_CHMAP_LFE, /**< LFE */
  509. SND_CHMAP_SL, /**< side left */
  510. SND_CHMAP_SR, /**< side right */
  511. SND_CHMAP_RC, /**< rear center */
  512. SND_CHMAP_FLC, /**< front left center */
  513. SND_CHMAP_FRC, /**< front right center */
  514. SND_CHMAP_RLC, /**< rear left center */
  515. SND_CHMAP_RRC, /**< rear right center */
  516. SND_CHMAP_FLW, /**< front left wide */
  517. SND_CHMAP_FRW, /**< front right wide */
  518. SND_CHMAP_FLH, /**< front left high */
  519. SND_CHMAP_FCH, /**< front center high */
  520. SND_CHMAP_FRH, /**< front right high */
  521. SND_CHMAP_TC, /**< top center */
  522. SND_CHMAP_TFL, /**< top front left */
  523. SND_CHMAP_TFR, /**< top front right */
  524. SND_CHMAP_TFC, /**< top front center */
  525. SND_CHMAP_TRL, /**< top rear left */
  526. SND_CHMAP_TRR, /**< top rear right */
  527. SND_CHMAP_TRC, /**< top rear center */
  528. SND_CHMAP_TFLC, /**< top front left center */
  529. SND_CHMAP_TFRC, /**< top front right center */
  530. SND_CHMAP_TSL, /**< top side left */
  531. SND_CHMAP_TSR, /**< top side right */
  532. SND_CHMAP_LLFE, /**< left LFE */
  533. SND_CHMAP_RLFE, /**< right LFE */
  534. SND_CHMAP_BC, /**< bottom center */
  535. SND_CHMAP_BLC, /**< bottom left center */
  536. SND_CHMAP_BRC, /**< bottom right center */
  537. SND_CHMAP_LAST = SND_CHMAP_BRC,
  538. };
  539. /** bitmask for channel position */
  540. #define SND_CHMAP_POSITION_MASK 0xffff
  541. /** bit flag indicating the channel is phase inverted */
  542. #define SND_CHMAP_PHASE_INVERSE (0x01 << 16)
  543. /** bit flag indicating the non-standard channel value */
  544. #define SND_CHMAP_DRIVER_SPEC (0x02 << 16)
  545. /** the channel map header */
  546. typedef struct snd_pcm_chmap {
  547. unsigned int channels; /**< number of channels */
  548. unsigned int pos[0]; /**< channel position array */
  549. } snd_pcm_chmap_t;
  550. /** the header of array items returned from snd_pcm_query_chmaps() */
  551. typedef struct snd_pcm_chmap_query {
  552. enum snd_pcm_chmap_type type; /**< channel map type */
  553. snd_pcm_chmap_t map; /**< available channel map */
  554. } snd_pcm_chmap_query_t;
  555. snd_pcm_chmap_query_t **snd_pcm_query_chmaps(snd_pcm_t *pcm);
  556. snd_pcm_chmap_query_t **snd_pcm_query_chmaps_from_hw(int card, int dev,
  557. int subdev,
  558. snd_pcm_stream_t stream);
  559. void snd_pcm_free_chmaps(snd_pcm_chmap_query_t **maps);
  560. snd_pcm_chmap_t *snd_pcm_get_chmap(snd_pcm_t *pcm);
  561. int snd_pcm_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map);
  562. const char *snd_pcm_chmap_type_name(enum snd_pcm_chmap_type val);
  563. const char *snd_pcm_chmap_name(enum snd_pcm_chmap_position val);
  564. const char *snd_pcm_chmap_long_name(enum snd_pcm_chmap_position val);
  565. int snd_pcm_chmap_print(const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
  566. unsigned int snd_pcm_chmap_from_string(const char *str);
  567. snd_pcm_chmap_t *snd_pcm_chmap_parse_string(const char *str);
  568. //int snd_pcm_mixer_element(snd_pcm_t *pcm, snd_mixer_t *mixer, snd_mixer_elem_t **elem);
  569. /*
  570. * application helpers - these functions are implemented on top
  571. * of the basic API
  572. */
  573. int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent);
  574. int snd_pcm_set_params(snd_pcm_t *pcm,
  575. snd_pcm_format_t format,
  576. snd_pcm_access_t access,
  577. unsigned int channels,
  578. unsigned int rate,
  579. int soft_resample,
  580. unsigned int latency);
  581. int snd_pcm_get_params(snd_pcm_t *pcm,
  582. snd_pcm_uframes_t *buffer_size,
  583. snd_pcm_uframes_t *period_size);
  584. /** \} */
  585. /**
  586. * \defgroup PCM_Info Stream Information
  587. * \ingroup PCM
  588. * See the \ref pcm page for more details.
  589. * \{
  590. */
  591. size_t snd_pcm_info_sizeof(void);
  592. /** \hideinitializer
  593. * \brief allocate an invalid #snd_pcm_info_t using standard alloca
  594. * \param ptr returned pointer
  595. */
  596. #define snd_pcm_info_alloca(ptr) __snd_alloca(ptr, snd_pcm_info)
  597. int snd_pcm_info_malloc(snd_pcm_info_t **ptr);
  598. void snd_pcm_info_free(snd_pcm_info_t *obj);
  599. void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src);
  600. unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj);
  601. unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj);
  602. snd_pcm_stream_t snd_pcm_info_get_stream(const snd_pcm_info_t *obj);
  603. int snd_pcm_info_get_card(const snd_pcm_info_t *obj);
  604. const char *snd_pcm_info_get_id(const snd_pcm_info_t *obj);
  605. const char *snd_pcm_info_get_name(const snd_pcm_info_t *obj);
  606. const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj);
  607. snd_pcm_class_t snd_pcm_info_get_class(const snd_pcm_info_t *obj);
  608. snd_pcm_subclass_t snd_pcm_info_get_subclass(const snd_pcm_info_t *obj);
  609. unsigned int snd_pcm_info_get_subdevices_count(const snd_pcm_info_t *obj);
  610. unsigned int snd_pcm_info_get_subdevices_avail(const snd_pcm_info_t *obj);
  611. snd_pcm_sync_id_t snd_pcm_info_get_sync(const snd_pcm_info_t *obj);
  612. void snd_pcm_info_set_device(snd_pcm_info_t *obj, unsigned int val);
  613. void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val);
  614. void snd_pcm_info_set_stream(snd_pcm_info_t *obj, snd_pcm_stream_t val);
  615. /** \} */
  616. /**
  617. * \defgroup PCM_HW_Params Hardware Parameters
  618. * \ingroup PCM
  619. * See the \ref pcm page for more details.
  620. * \{
  621. */
  622. int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
  623. int snd_pcm_hw_params_can_mmap_sample_resolution(const snd_pcm_hw_params_t *params);
  624. int snd_pcm_hw_params_is_double(const snd_pcm_hw_params_t *params);
  625. int snd_pcm_hw_params_is_batch(const snd_pcm_hw_params_t *params);
  626. int snd_pcm_hw_params_is_block_transfer(const snd_pcm_hw_params_t *params);
  627. int snd_pcm_hw_params_is_monotonic(const snd_pcm_hw_params_t *params);
  628. int snd_pcm_hw_params_can_overrange(const snd_pcm_hw_params_t *params);
  629. int snd_pcm_hw_params_can_pause(const snd_pcm_hw_params_t *params);
  630. int snd_pcm_hw_params_can_resume(const snd_pcm_hw_params_t *params);
  631. int snd_pcm_hw_params_is_half_duplex(const snd_pcm_hw_params_t *params);
  632. int snd_pcm_hw_params_is_joint_duplex(const snd_pcm_hw_params_t *params);
  633. int snd_pcm_hw_params_can_sync_start(const snd_pcm_hw_params_t *params);
  634. int snd_pcm_hw_params_can_disable_period_wakeup(const snd_pcm_hw_params_t *params);
  635. int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params); /* deprecated, use audio_ts_type */
  636. int snd_pcm_hw_params_supports_audio_ts_type(const snd_pcm_hw_params_t *params, int type);
  637. int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params,
  638. unsigned int *rate_num,
  639. unsigned int *rate_den);
  640. int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params);
  641. int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params);
  642. #if 0
  643. typedef struct _snd_pcm_hw_strategy snd_pcm_hw_strategy_t;
  644. /* choices need to be sorted on ascending badness */
  645. typedef struct _snd_pcm_hw_strategy_simple_choices_list {
  646. unsigned int value;
  647. unsigned int badness;
  648. } snd_pcm_hw_strategy_simple_choices_list_t;
  649. int snd_pcm_hw_params_strategy(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
  650. const snd_pcm_hw_strategy_t *strategy,
  651. unsigned int badness_min,
  652. unsigned int badness_max);
  653. void snd_pcm_hw_strategy_free(snd_pcm_hw_strategy_t *strategy);
  654. int snd_pcm_hw_strategy_simple(snd_pcm_hw_strategy_t **strategyp,
  655. unsigned int badness_min,
  656. unsigned int badness_max);
  657. int snd_pcm_hw_params_try_explain_failure(snd_pcm_t *pcm,
  658. snd_pcm_hw_params_t *fail,
  659. snd_pcm_hw_params_t *success,
  660. unsigned int depth,
  661. snd_output_t *out);
  662. #endif
  663. size_t snd_pcm_hw_params_sizeof(void);
  664. /** \hideinitializer
  665. * \brief allocate an invalid #snd_pcm_hw_params_t using standard alloca
  666. * \param ptr returned pointer
  667. */
  668. #define snd_pcm_hw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_hw_params)
  669. int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr);
  670. void snd_pcm_hw_params_free(snd_pcm_hw_params_t *obj);
  671. void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t *src);
  672. #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
  673. int snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params, snd_pcm_access_t *_access);
  674. int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t _access);
  675. int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t _access);
  676. int snd_pcm_hw_params_set_access_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *_access);
  677. int snd_pcm_hw_params_set_access_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *_access);
  678. int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask);
  679. int snd_pcm_hw_params_get_access_mask(snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask);
  680. int snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params, snd_pcm_format_t *val);
  681. int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
  682. int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
  683. int snd_pcm_hw_params_set_format_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format);
  684. int snd_pcm_hw_params_set_format_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format);
  685. int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask);
  686. void snd_pcm_hw_params_get_format_mask(snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask);
  687. int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat);
  688. int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t subformat);
  689. int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t subformat);
  690. int snd_pcm_hw_params_set_subformat_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat);
  691. int snd_pcm_hw_params_set_subformat_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat);
  692. int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask);
  693. void snd_pcm_hw_params_get_subformat_mask(snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask);
  694. int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params, unsigned int *val);
  695. int snd_pcm_hw_params_get_channels_min(const snd_pcm_hw_params_t *params, unsigned int *val);
  696. int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *params, unsigned int *val);
  697. int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
  698. int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
  699. int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
  700. int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
  701. int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max);
  702. int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
  703. int snd_pcm_hw_params_set_channels_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
  704. int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
  705. int snd_pcm_hw_params_get_rate(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  706. int snd_pcm_hw_params_get_rate_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  707. int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  708. int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
  709. int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
  710. int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  711. int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  712. int snd_pcm_hw_params_set_rate_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir);
  713. int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  714. int snd_pcm_hw_params_set_rate_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  715. int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  716. int snd_pcm_hw_params_set_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
  717. int snd_pcm_hw_params_get_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
  718. int snd_pcm_hw_params_set_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
  719. int snd_pcm_hw_params_get_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
  720. int snd_pcm_hw_params_set_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
  721. int snd_pcm_hw_params_get_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
  722. int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  723. int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  724. int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  725. int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
  726. int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
  727. int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  728. int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  729. int snd_pcm_hw_params_set_period_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir);
  730. int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  731. int snd_pcm_hw_params_set_period_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  732. int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  733. int snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
  734. int snd_pcm_hw_params_get_period_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
  735. int snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
  736. int snd_pcm_hw_params_test_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir);
  737. int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir);
  738. int snd_pcm_hw_params_set_period_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
  739. int snd_pcm_hw_params_set_period_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
  740. int snd_pcm_hw_params_set_period_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *min, int *mindir, snd_pcm_uframes_t *max, int *maxdir);
  741. int snd_pcm_hw_params_set_period_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
  742. int snd_pcm_hw_params_set_period_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
  743. int snd_pcm_hw_params_set_period_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
  744. int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
  745. int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  746. int snd_pcm_hw_params_get_periods_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  747. int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  748. int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
  749. int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
  750. int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  751. int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  752. int snd_pcm_hw_params_set_periods_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir);
  753. int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  754. int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  755. int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  756. int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
  757. int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  758. int snd_pcm_hw_params_get_buffer_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  759. int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  760. int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
  761. int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
  762. int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  763. int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  764. int snd_pcm_hw_params_set_buffer_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir);
  765. int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  766. int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  767. int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
  768. int snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
  769. int snd_pcm_hw_params_get_buffer_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
  770. int snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
  771. int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
  772. int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
  773. int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
  774. int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
  775. int snd_pcm_hw_params_set_buffer_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *min, snd_pcm_uframes_t *max);
  776. int snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
  777. int snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
  778. int snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
  779. #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
  780. int snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
  781. /** \} */
  782. /**
  783. * \defgroup PCM_SW_Params Software Parameters
  784. * \ingroup PCM
  785. * See the \ref pcm page for more details.
  786. * \{
  787. */
  788. size_t snd_pcm_sw_params_sizeof(void);
  789. /** \hideinitializer
  790. * \brief allocate an invalid #snd_pcm_sw_params_t using standard alloca
  791. * \param ptr returned pointer
  792. */
  793. #define snd_pcm_sw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_sw_params)
  794. int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr);
  795. void snd_pcm_sw_params_free(snd_pcm_sw_params_t *obj);
  796. void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src);
  797. int snd_pcm_sw_params_get_boundary(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
  798. #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_SW_PARAMS_API)
  799. int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val);
  800. int snd_pcm_sw_params_get_tstamp_mode(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_t *val);
  801. int snd_pcm_sw_params_set_tstamp_type(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t val);
  802. int snd_pcm_sw_params_get_tstamp_type(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t *val);
  803. int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
  804. int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
  805. int snd_pcm_sw_params_set_period_event(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, int val);
  806. int snd_pcm_sw_params_get_period_event(const snd_pcm_sw_params_t *params, int *val);
  807. int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
  808. int snd_pcm_sw_params_get_start_threshold(const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val);
  809. int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
  810. int snd_pcm_sw_params_get_stop_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
  811. int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
  812. int snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
  813. int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
  814. int snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
  815. #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
  816. /** \} */
  817. /* include old API */
  818. #ifndef ALSA_LIBRARY_BUILD
  819. #if defined(ALSA_PCM_OLD_HW_PARAMS_API) || defined(ALSA_PCM_OLD_SW_PARAMS_API)
  820. #include "pcm_old.h"
  821. #endif
  822. #endif
  823. /**
  824. * \defgroup PCM_Access Access Mask Functions
  825. * \ingroup PCM
  826. * See the \ref pcm page for more details.
  827. * \{
  828. */
  829. size_t snd_pcm_access_mask_sizeof(void);
  830. /** \hideinitializer
  831. * \brief allocate an empty #snd_pcm_access_mask_t using standard alloca
  832. * \param ptr returned pointer
  833. */
  834. #define snd_pcm_access_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_access_mask)
  835. int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr);
  836. void snd_pcm_access_mask_free(snd_pcm_access_mask_t *obj);
  837. void snd_pcm_access_mask_copy(snd_pcm_access_mask_t *dst, const snd_pcm_access_mask_t *src);
  838. void snd_pcm_access_mask_none(snd_pcm_access_mask_t *mask);
  839. void snd_pcm_access_mask_any(snd_pcm_access_mask_t *mask);
  840. int snd_pcm_access_mask_test(const snd_pcm_access_mask_t *mask, snd_pcm_access_t val);
  841. int snd_pcm_access_mask_empty(const snd_pcm_access_mask_t *mask);
  842. void snd_pcm_access_mask_set(snd_pcm_access_mask_t *mask, snd_pcm_access_t val);
  843. void snd_pcm_access_mask_reset(snd_pcm_access_mask_t *mask, snd_pcm_access_t val);
  844. /** \} */
  845. /**
  846. * \defgroup PCM_Format Format Mask Functions
  847. * \ingroup PCM
  848. * See the \ref pcm page for more details.
  849. * \{
  850. */
  851. size_t snd_pcm_format_mask_sizeof(void);
  852. /** \hideinitializer
  853. * \brief allocate an empty #snd_pcm_format_mask_t using standard alloca
  854. * \param ptr returned pointer
  855. */
  856. #define snd_pcm_format_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_format_mask)
  857. int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr);
  858. void snd_pcm_format_mask_free(snd_pcm_format_mask_t *obj);
  859. void snd_pcm_format_mask_copy(snd_pcm_format_mask_t *dst, const snd_pcm_format_mask_t *src);
  860. void snd_pcm_format_mask_none(snd_pcm_format_mask_t *mask);
  861. void snd_pcm_format_mask_any(snd_pcm_format_mask_t *mask);
  862. int snd_pcm_format_mask_test(const snd_pcm_format_mask_t *mask, snd_pcm_format_t val);
  863. int snd_pcm_format_mask_empty(const snd_pcm_format_mask_t *mask);
  864. void snd_pcm_format_mask_set(snd_pcm_format_mask_t *mask, snd_pcm_format_t val);
  865. void snd_pcm_format_mask_reset(snd_pcm_format_mask_t *mask, snd_pcm_format_t val);
  866. /** \} */
  867. /**
  868. * \defgroup PCM_SubFormat Subformat Mask Functions
  869. * \ingroup PCM
  870. * See the \ref pcm page for more details.
  871. * \{
  872. */
  873. size_t snd_pcm_subformat_mask_sizeof(void);
  874. /** \hideinitializer
  875. * \brief allocate an empty #snd_pcm_subformat_mask_t using standard alloca
  876. * \param ptr returned pointer
  877. */
  878. #define snd_pcm_subformat_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_subformat_mask)
  879. int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr);
  880. void snd_pcm_subformat_mask_free(snd_pcm_subformat_mask_t *obj);
  881. void snd_pcm_subformat_mask_copy(snd_pcm_subformat_mask_t *dst, const snd_pcm_subformat_mask_t *src);
  882. void snd_pcm_subformat_mask_none(snd_pcm_subformat_mask_t *mask);
  883. void snd_pcm_subformat_mask_any(snd_pcm_subformat_mask_t *mask);
  884. int snd_pcm_subformat_mask_test(const snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val);
  885. int snd_pcm_subformat_mask_empty(const snd_pcm_subformat_mask_t *mask);
  886. void snd_pcm_subformat_mask_set(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val);
  887. void snd_pcm_subformat_mask_reset(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val);
  888. /** \} */
  889. /**
  890. * \defgroup PCM_Status Status Functions
  891. * \ingroup PCM
  892. * See the \ref pcm page for more details.
  893. * \{
  894. */
  895. size_t snd_pcm_status_sizeof(void);
  896. /** \hideinitializer
  897. * \brief allocate an invalid #snd_pcm_status_t using standard alloca
  898. * \param ptr returned pointer
  899. */
  900. #define snd_pcm_status_alloca(ptr) __snd_alloca(ptr, snd_pcm_status)
  901. int snd_pcm_status_malloc(snd_pcm_status_t **ptr);
  902. void snd_pcm_status_free(snd_pcm_status_t *obj);
  903. void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src);
  904. snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj);
  905. void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr);
  906. void snd_pcm_status_get_trigger_htstamp(const snd_pcm_status_t *obj, snd_htimestamp_t *ptr);
  907. void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr);
  908. void snd_pcm_status_get_htstamp(const snd_pcm_status_t *obj, snd_htimestamp_t *ptr);
  909. void snd_pcm_status_get_audio_htstamp(const snd_pcm_status_t *obj, snd_htimestamp_t *ptr);
  910. void snd_pcm_status_get_driver_htstamp(const snd_pcm_status_t *obj, snd_htimestamp_t *ptr);
  911. void snd_pcm_status_get_audio_htstamp_report(const snd_pcm_status_t *obj,
  912. snd_pcm_audio_tstamp_report_t *audio_tstamp_report);
  913. void snd_pcm_status_set_audio_htstamp_config(snd_pcm_status_t *obj,
  914. snd_pcm_audio_tstamp_config_t *audio_tstamp_config);
  915. static inline void snd_pcm_pack_audio_tstamp_config(unsigned int *data,
  916. snd_pcm_audio_tstamp_config_t *config)
  917. {
  918. *data = config->report_delay;
  919. *data <<= 4;
  920. *data |= config->type_requested;
  921. }
  922. static inline void snd_pcm_unpack_audio_tstamp_report(unsigned int data, unsigned int accuracy,
  923. snd_pcm_audio_tstamp_report_t *report)
  924. {
  925. data >>= 16;
  926. report->valid = data & 1;
  927. report->actual_type = (data >> 1) & 0xF;
  928. report->accuracy_report = (data >> 5) & 1;
  929. report->accuracy = accuracy;
  930. }
  931. snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj);
  932. snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj);
  933. snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj);
  934. snd_pcm_uframes_t snd_pcm_status_get_overrange(const snd_pcm_status_t *obj);
  935. /** \} */
  936. /**
  937. * \defgroup PCM_Description Description Functions
  938. * \ingroup PCM
  939. * See the \ref pcm page for more details.
  940. * \{
  941. */
  942. const char *snd_pcm_type_name(snd_pcm_type_t type);
  943. const char *snd_pcm_stream_name(const snd_pcm_stream_t stream);
  944. const char *snd_pcm_access_name(const snd_pcm_access_t _access);
  945. const char *snd_pcm_format_name(const snd_pcm_format_t format);
  946. const char *snd_pcm_format_description(const snd_pcm_format_t format);
  947. const char *snd_pcm_subformat_name(const snd_pcm_subformat_t subformat);
  948. const char *snd_pcm_subformat_description(const snd_pcm_subformat_t subformat);
  949. snd_pcm_format_t snd_pcm_format_value(const char* name);
  950. const char *snd_pcm_tstamp_mode_name(const snd_pcm_tstamp_t mode);
  951. const char *snd_pcm_state_name(const snd_pcm_state_t state);
  952. /** \} */
  953. /**
  954. * \defgroup PCM_Dump Debug Functions
  955. * \ingroup PCM
  956. * See the \ref pcm page for more details.
  957. * \{
  958. */
  959. int snd_pcm_dump(snd_pcm_t *pcm, snd_output_t *out);
  960. int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, snd_output_t *out);
  961. int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out);
  962. int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out);
  963. int snd_pcm_hw_params_dump(snd_pcm_hw_params_t *params, snd_output_t *out);
  964. int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out);
  965. int snd_pcm_status_dump(snd_pcm_status_t *status, snd_output_t *out);
  966. /** \} */
  967. /**
  968. * \defgroup PCM_Direct Direct Access (MMAP) Functions
  969. * \ingroup PCM
  970. * See the \ref pcm page for more details.
  971. * \{
  972. */
  973. int snd_pcm_mmap_begin(snd_pcm_t *pcm,
  974. const snd_pcm_channel_area_t **areas,
  975. snd_pcm_uframes_t *offset,
  976. snd_pcm_uframes_t *frames);
  977. snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm,
  978. snd_pcm_uframes_t offset,
  979. snd_pcm_uframes_t frames);
  980. snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
  981. snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
  982. snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
  983. snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
  984. /** \} */
  985. /**
  986. * \defgroup PCM_Helpers Helper Functions
  987. * \ingroup PCM
  988. * See the \ref pcm page for more details.
  989. * \{
  990. */
  991. int snd_pcm_format_signed(snd_pcm_format_t format);
  992. int snd_pcm_format_unsigned(snd_pcm_format_t format);
  993. int snd_pcm_format_linear(snd_pcm_format_t format);
  994. int snd_pcm_format_float(snd_pcm_format_t format);
  995. int snd_pcm_format_little_endian(snd_pcm_format_t format);
  996. int snd_pcm_format_big_endian(snd_pcm_format_t format);
  997. int snd_pcm_format_cpu_endian(snd_pcm_format_t format);
  998. int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */
  999. int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */
  1000. snd_pcm_format_t snd_pcm_build_linear_format(int width, int pwidth, int unsignd, int big_endian);
  1001. ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
  1002. u_int8_t snd_pcm_format_silence(snd_pcm_format_t format);
  1003. u_int16_t snd_pcm_format_silence_16(snd_pcm_format_t format);
  1004. u_int32_t snd_pcm_format_silence_32(snd_pcm_format_t format);
  1005. u_int64_t snd_pcm_format_silence_64(snd_pcm_format_t format);
  1006. int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int samples);
  1007. snd_pcm_sframes_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes);
  1008. ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *pcm, snd_pcm_sframes_t frames);
  1009. long snd_pcm_bytes_to_samples(snd_pcm_t *pcm, ssize_t bytes);
  1010. ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, long samples);
  1011. int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset,
  1012. unsigned int samples, snd_pcm_format_t format);
  1013. int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset,
  1014. unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format);
  1015. int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset,
  1016. const snd_pcm_channel_area_t *src_channel, snd_pcm_uframes_t src_offset,
  1017. unsigned int samples, snd_pcm_format_t format);
  1018. int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset,
  1019. const snd_pcm_channel_area_t *src_channels, snd_pcm_uframes_t src_offset,
  1020. unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format);
  1021. /** \} */
  1022. /**
  1023. * \defgroup PCM_Hook Hook Extension
  1024. * \ingroup PCM
  1025. * See the \ref pcm page for more details.
  1026. * \{
  1027. */
  1028. /** type of pcm hook */
  1029. typedef enum _snd_pcm_hook_type {
  1030. SND_PCM_HOOK_TYPE_HW_PARAMS = 0,
  1031. SND_PCM_HOOK_TYPE_HW_FREE,
  1032. SND_PCM_HOOK_TYPE_CLOSE,
  1033. SND_PCM_HOOK_TYPE_LAST = SND_PCM_HOOK_TYPE_CLOSE
  1034. } snd_pcm_hook_type_t;
  1035. /** PCM hook container */
  1036. typedef struct _snd_pcm_hook snd_pcm_hook_t;
  1037. /** PCM hook callback function */
  1038. typedef int (*snd_pcm_hook_func_t)(snd_pcm_hook_t *hook);
  1039. snd_pcm_t *snd_pcm_hook_get_pcm(snd_pcm_hook_t *hook);
  1040. void *snd_pcm_hook_get_private(snd_pcm_hook_t *hook);
  1041. void snd_pcm_hook_set_private(snd_pcm_hook_t *hook, void *private_data);
  1042. int snd_pcm_hook_add(snd_pcm_hook_t **hookp, snd_pcm_t *pcm,
  1043. snd_pcm_hook_type_t type,
  1044. snd_pcm_hook_func_t func, void *private_data);
  1045. int snd_pcm_hook_remove(snd_pcm_hook_t *hook);
  1046. /** \} */
  1047. /**
  1048. * \defgroup PCM_Scope Scope Plugin Extension
  1049. * \ingroup PCM
  1050. * See the \ref pcm page for more details.
  1051. * \{
  1052. */
  1053. /** #SND_PCM_TYPE_METER scope functions */
  1054. typedef struct _snd_pcm_scope_ops {
  1055. /** \brief Enable and prepare it using current params
  1056. * \param scope scope handle
  1057. */
  1058. int (*enable)(snd_pcm_scope_t *scope);
  1059. /** \brief Disable
  1060. * \param scope scope handle
  1061. */
  1062. void (*disable)(snd_pcm_scope_t *scope);
  1063. /** \brief PCM has been started
  1064. * \param scope scope handle
  1065. */
  1066. void (*start)(snd_pcm_scope_t *scope);
  1067. /** \brief PCM has been stopped
  1068. * \param scope scope handle
  1069. */
  1070. void (*stop)(snd_pcm_scope_t *scope);
  1071. /** \brief New frames are present
  1072. * \param scope scope handle
  1073. */
  1074. void (*update)(snd_pcm_scope_t *scope);
  1075. /** \brief Reset status
  1076. * \param scope scope handle
  1077. */
  1078. void (*reset)(snd_pcm_scope_t *scope);
  1079. /** \brief PCM is closing
  1080. * \param scope scope handle
  1081. */
  1082. void (*close)(snd_pcm_scope_t *scope);
  1083. } snd_pcm_scope_ops_t;
  1084. snd_pcm_uframes_t snd_pcm_meter_get_bufsize(snd_pcm_t *pcm);
  1085. unsigned int snd_pcm_meter_get_channels(snd_pcm_t *pcm);
  1086. unsigned int snd_pcm_meter_get_rate(snd_pcm_t *pcm);
  1087. snd_pcm_uframes_t snd_pcm_meter_get_now(snd_pcm_t *pcm);
  1088. snd_pcm_uframes_t snd_pcm_meter_get_boundary(snd_pcm_t *pcm);
  1089. int snd_pcm_meter_add_scope(snd_pcm_t *pcm, snd_pcm_scope_t *scope);
  1090. snd_pcm_scope_t *snd_pcm_meter_search_scope(snd_pcm_t *pcm, const char *name);
  1091. int snd_pcm_scope_malloc(snd_pcm_scope_t **ptr);
  1092. void snd_pcm_scope_set_ops(snd_pcm_scope_t *scope,
  1093. const snd_pcm_scope_ops_t *val);
  1094. void snd_pcm_scope_set_name(snd_pcm_scope_t *scope, const char *val);
  1095. const char *snd_pcm_scope_get_name(snd_pcm_scope_t *scope);
  1096. void *snd_pcm_scope_get_callback_private(snd_pcm_scope_t *scope);
  1097. void snd_pcm_scope_set_callback_private(snd_pcm_scope_t *scope, void *val);
  1098. int snd_pcm_scope_s16_open(snd_pcm_t *pcm, const char *name,
  1099. snd_pcm_scope_t **scopep);
  1100. int16_t *snd_pcm_scope_s16_get_channel_buffer(snd_pcm_scope_t *scope,
  1101. unsigned int channel);
  1102. /** \} */
  1103. /**
  1104. * \defgroup PCM_Simple Simple setup functions
  1105. * \ingroup PCM
  1106. * See the \ref pcm page for more details.
  1107. * \{
  1108. */
  1109. /** Simple PCM latency type */
  1110. typedef enum _snd_spcm_latency {
  1111. /** standard latency - for standard playback or capture
  1112. (estimated latency in one direction 350ms) */
  1113. SND_SPCM_LATENCY_STANDARD = 0,
  1114. /** medium latency - software phones etc.
  1115. (estimated latency in one direction maximally 25ms */
  1116. SND_SPCM_LATENCY_MEDIUM,
  1117. /** realtime latency - realtime applications (effect processors etc.)
  1118. (estimated latency in one direction 5ms and better) */
  1119. SND_SPCM_LATENCY_REALTIME
  1120. } snd_spcm_latency_t;
  1121. /** Simple PCM xrun type */
  1122. typedef enum _snd_spcm_xrun_type {
  1123. /** driver / library will ignore all xruns, the stream runs forever */
  1124. SND_SPCM_XRUN_IGNORE = 0,
  1125. /** driver / library stops the stream when an xrun occurs */
  1126. SND_SPCM_XRUN_STOP
  1127. } snd_spcm_xrun_type_t;
  1128. /** Simple PCM duplex type */
  1129. typedef enum _snd_spcm_duplex_type {
  1130. /** liberal duplex - the buffer and period sizes might not match */
  1131. SND_SPCM_DUPLEX_LIBERAL = 0,
  1132. /** pedantic duplex - the buffer and period sizes MUST match */
  1133. SND_SPCM_DUPLEX_PEDANTIC
  1134. } snd_spcm_duplex_type_t;
  1135. int snd_spcm_init(snd_pcm_t *pcm,
  1136. unsigned int rate,
  1137. unsigned int channels,
  1138. snd_pcm_format_t format,
  1139. snd_pcm_subformat_t subformat,
  1140. snd_spcm_latency_t latency,
  1141. snd_pcm_access_t _access,
  1142. snd_spcm_xrun_type_t xrun_type);
  1143. int snd_spcm_init_duplex(snd_pcm_t *playback_pcm,
  1144. snd_pcm_t *capture_pcm,
  1145. unsigned int rate,
  1146. unsigned int channels,
  1147. snd_pcm_format_t format,
  1148. snd_pcm_subformat_t subformat,
  1149. snd_spcm_latency_t latency,
  1150. snd_pcm_access_t _access,
  1151. snd_spcm_xrun_type_t xrun_type,
  1152. snd_spcm_duplex_type_t duplex_type);
  1153. int snd_spcm_init_get_params(snd_pcm_t *pcm,
  1154. unsigned int *rate,
  1155. snd_pcm_uframes_t *buffer_size,
  1156. snd_pcm_uframes_t *period_size);
  1157. /** \} */
  1158. /**
  1159. * \defgroup PCM_Deprecated Deprecated Functions
  1160. * \ingroup PCM
  1161. * See the \ref pcm page for more details.
  1162. * \{
  1163. */
  1164. /* Deprecated functions, for compatibility */
  1165. const char *snd_pcm_start_mode_name(snd_pcm_start_t mode) __attribute__((deprecated));
  1166. const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode) __attribute__((deprecated));
  1167. int snd_pcm_sw_params_set_start_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_start_t val) __attribute__((deprecated));
  1168. snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
  1169. int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_xrun_t val) __attribute__((deprecated));
  1170. snd_pcm_xrun_t snd_pcm_sw_params_get_xrun_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
  1171. #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_SW_PARAMS_API)
  1172. int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val) __attribute__((deprecated));
  1173. int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val) __attribute__((deprecated));
  1174. int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int val) __attribute__((deprecated));
  1175. int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params, unsigned int *val) __attribute__((deprecated));
  1176. #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
  1177. #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
  1178. int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
  1179. int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
  1180. int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
  1181. int snd_pcm_hw_params_test_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) __attribute__((deprecated));
  1182. int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) __attribute__((deprecated));
  1183. int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
  1184. int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
  1185. int snd_pcm_hw_params_set_tick_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) __attribute__((deprecated));
  1186. int snd_pcm_hw_params_set_tick_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
  1187. int snd_pcm_hw_params_set_tick_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
  1188. int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
  1189. #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
  1190. /** \} */
  1191. #ifdef __cplusplus
  1192. }
  1193. #endif
  1194. #endif /* __ALSA_PCM_H */