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