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