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