2 * PCM Interface - local header file
3 * Copyright (c) 2000 by Jaroslav Kysela <perex@perex.cz>
4 * Abramo Bagnara <abramo@alsa-project.org>
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define _snd_mask sndrv_mask
29 #define _snd_pcm_access_mask _snd_mask
30 #define _snd_pcm_format_mask _snd_mask
31 #define _snd_pcm_subformat_mask _snd_mask
35 #define SND_INTERVAL_INLINE
38 #define SND_MASK_INLINE
41 typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t;
42 #define SND_PCM_HW_PARAM_ACCESS SNDRV_PCM_HW_PARAM_ACCESS
43 #define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK
44 #define SND_PCM_HW_PARAM_FORMAT SNDRV_PCM_HW_PARAM_FORMAT
45 #define SND_PCM_HW_PARAM_SUBFORMAT SNDRV_PCM_HW_PARAM_SUBFORMAT
46 #define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK
47 #define SND_PCM_HW_PARAM_SAMPLE_BITS SNDRV_PCM_HW_PARAM_SAMPLE_BITS
48 #define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL
49 #define SND_PCM_HW_PARAM_FRAME_BITS SNDRV_PCM_HW_PARAM_FRAME_BITS
50 #define SND_PCM_HW_PARAM_CHANNELS SNDRV_PCM_HW_PARAM_CHANNELS
51 #define SND_PCM_HW_PARAM_RATE SNDRV_PCM_HW_PARAM_RATE
52 #define SND_PCM_HW_PARAM_PERIOD_TIME SNDRV_PCM_HW_PARAM_PERIOD_TIME
53 #define SND_PCM_HW_PARAM_PERIOD_SIZE SNDRV_PCM_HW_PARAM_PERIOD_SIZE
54 #define SND_PCM_HW_PARAM_PERIOD_BYTES SNDRV_PCM_HW_PARAM_PERIOD_BYTES
55 #define SND_PCM_HW_PARAM_PERIODS SNDRV_PCM_HW_PARAM_PERIODS
56 #define SND_PCM_HW_PARAM_BUFFER_TIME SNDRV_PCM_HW_PARAM_BUFFER_TIME
57 #define SND_PCM_HW_PARAM_BUFFER_SIZE SNDRV_PCM_HW_PARAM_BUFFER_SIZE
58 #define SND_PCM_HW_PARAM_BUFFER_BYTES SNDRV_PCM_HW_PARAM_BUFFER_BYTES
59 #define SND_PCM_HW_PARAM_TICK_TIME SNDRV_PCM_HW_PARAM_TICK_TIME
60 #define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL
61 #define SND_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_LAST_MASK
62 #define SND_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_FIRST_MASK
63 #define SND_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_LAST_INTERVAL
64 #define SND_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_FIRST_INTERVAL
66 /** device accepts mmaped access */
67 #define SND_PCM_INFO_MMAP SNDRV_PCM_INFO_MMAP
68 /** device accepts mmaped access with sample resolution */
69 #define SND_PCM_INFO_MMAP_VALID SNDRV_PCM_INFO_MMAP_VALID
70 /** device is doing double buffering */
71 #define SND_PCM_INFO_DOUBLE SNDRV_PCM_INFO_DOUBLE
72 /** device transfers samples in batch */
73 #define SND_PCM_INFO_BATCH SNDRV_PCM_INFO_BATCH
74 /** device accepts interleaved samples */
75 #define SND_PCM_INFO_INTERLEAVED SNDRV_PCM_INFO_INTERLEAVED
76 /** device accepts non-interleaved samples */
77 #define SND_PCM_INFO_NONINTERLEAVED SNDRV_PCM_INFO_NONINTERLEAVED
78 /** device accepts complex sample organization */
79 #define SND_PCM_INFO_COMPLEX SNDRV_PCM_INFO_COMPLEX
80 /** device is capable block transfers */
81 #define SND_PCM_INFO_BLOCK_TRANSFER SNDRV_PCM_INFO_BLOCK_TRANSFER
82 /** device can detect DAC/ADC overrange */
83 #define SND_PCM_INFO_OVERRANGE SNDRV_PCM_INFO_OVERRANGE
84 /** device supports resume */
85 #define SND_PCM_INFO_RESUME SNDRV_PCM_INFO_RESUME
86 /** device is capable to pause */
87 #define SND_PCM_INFO_PAUSE SNDRV_PCM_INFO_PAUSE
88 /** device can do only half duplex */
89 #define SND_PCM_INFO_HALF_DUPLEX SNDRV_PCM_INFO_HALF_DUPLEX
90 /** device can do only joint duplex (same parameters) */
91 #define SND_PCM_INFO_JOINT_DUPLEX SNDRV_PCM_INFO_JOINT_DUPLEX
92 /** device can do a kind of synchronized start */
93 #define SND_PCM_INFO_SYNC_START SNDRV_PCM_INFO_SYNC_START
94 /** device can disable period wakeups */
95 #define SND_PCM_INFO_NO_PERIOD_WAKEUP SNDRV_PCM_INFO_NO_PERIOD_WAKEUP
97 #define SND_PCM_HW_PARAMS_NORESAMPLE SNDRV_PCM_HW_PARAMS_NORESAMPLE
98 #define SND_PCM_HW_PARAMS_EXPORT_BUFFER SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER
99 #define SND_PCM_HW_PARAMS_NO_PERIOD_WAKEUP SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP
101 #define SND_PCM_INFO_MONOTONIC 0x80000000
103 typedef struct _snd_pcm_rbptr {
105 volatile snd_pcm_uframes_t *ptr;
109 snd_pcm_t **link_dst;
111 void (*changed)(snd_pcm_t *pcm, snd_pcm_t *src);
114 typedef struct _snd_pcm_channel_info {
115 unsigned int channel;
116 void *addr; /* base address of channel samples */
117 unsigned int first; /* offset to first sample in bits */
118 unsigned int step; /* samples distance in bits */
119 enum { SND_PCM_AREA_SHM, SND_PCM_AREA_MMAP, SND_PCM_AREA_LOCAL } type;
122 struct snd_shm_area *area;
131 } snd_pcm_channel_info_t;
134 int (*close)(snd_pcm_t *pcm);
135 int (*nonblock)(snd_pcm_t *pcm, int nonblock);
136 int (*async)(snd_pcm_t *pcm, int sig, pid_t pid);
137 int (*info)(snd_pcm_t *pcm, snd_pcm_info_t *info);
138 int (*hw_refine)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
139 int (*hw_params)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
140 int (*hw_free)(snd_pcm_t *pcm);
141 int (*sw_params)(snd_pcm_t *pcm, snd_pcm_sw_params_t *params);
142 int (*channel_info)(snd_pcm_t *pcm, snd_pcm_channel_info_t *info);
143 void (*dump)(snd_pcm_t *pcm, snd_output_t *out);
144 int (*mmap)(snd_pcm_t *pcm);
145 int (*munmap)(snd_pcm_t *pcm);
149 int (*status)(snd_pcm_t *pcm, snd_pcm_status_t *status);
150 int (*prepare)(snd_pcm_t *pcm);
151 int (*reset)(snd_pcm_t *pcm);
152 int (*start)(snd_pcm_t *pcm);
153 int (*drop)(snd_pcm_t *pcm);
154 int (*drain)(snd_pcm_t *pcm);
155 int (*pause)(snd_pcm_t *pcm, int enable);
156 snd_pcm_state_t (*state)(snd_pcm_t *pcm);
157 int (*hwsync)(snd_pcm_t *pcm);
158 int (*delay)(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
159 int (*resume)(snd_pcm_t *pcm);
160 int (*link)(snd_pcm_t *pcm1, snd_pcm_t *pcm2);
161 int (*link_slaves)(snd_pcm_t *pcm, snd_pcm_t *master);
162 int (*unlink)(snd_pcm_t *pcm);
163 snd_pcm_sframes_t (*rewindable)(snd_pcm_t *pcm);
164 snd_pcm_sframes_t (*rewind)(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
165 snd_pcm_sframes_t (*forwardable)(snd_pcm_t *pcm);
166 snd_pcm_sframes_t (*forward)(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
167 snd_pcm_sframes_t (*writei)(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
168 snd_pcm_sframes_t (*writen)(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
169 snd_pcm_sframes_t (*readi)(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
170 snd_pcm_sframes_t (*readn)(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
171 snd_pcm_sframes_t (*avail_update)(snd_pcm_t *pcm);
172 snd_pcm_sframes_t (*mmap_commit)(snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t size);
173 int (*htimestamp)(snd_pcm_t *pcm, snd_pcm_uframes_t *avail, snd_htimestamp_t *tstamp);
174 int (*poll_descriptors_count)(snd_pcm_t *pcm);
175 int (*poll_descriptors)(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
176 int (*poll_revents)(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
177 } snd_pcm_fast_ops_t;
183 snd_pcm_stream_t stream;
185 long minperiodtime; /* in us */
188 unsigned short poll_events;
192 snd_pcm_access_t access; /* access mode */
193 snd_pcm_format_t format; /* SND_PCM_FORMAT_* */
194 snd_pcm_subformat_t subformat; /* subformat */
195 unsigned int channels; /* channels */
196 unsigned int rate; /* rate in Hz */
197 snd_pcm_uframes_t period_size;
198 unsigned int period_time; /* period duration */
199 snd_interval_t periods;
200 snd_pcm_tstamp_t tstamp_mode; /* timestamp mode */
201 unsigned int period_step;
202 snd_pcm_uframes_t avail_min; /* min avail frames for wakeup */
204 snd_pcm_uframes_t start_threshold;
205 snd_pcm_uframes_t stop_threshold;
206 snd_pcm_uframes_t silence_threshold; /* Silence filling happens when
207 noise is nearest than this */
208 snd_pcm_uframes_t silence_size; /* Silence filling size */
209 snd_pcm_uframes_t boundary; /* pointers wrap point */
210 unsigned int info; /* Info for returned setup */
211 unsigned int msbits; /* used most significant bits */
212 unsigned int rate_num; /* rate numerator */
213 unsigned int rate_den; /* rate denominator */
214 unsigned int hw_flags; /* actual hardware flags */
215 snd_pcm_uframes_t fifo_size; /* chip FIFO size in frames */
216 snd_pcm_uframes_t buffer_size;
217 snd_interval_t buffer_time;
218 unsigned int sample_bits;
219 unsigned int frame_bits;
220 snd_pcm_rbptr_t appl;
222 snd_pcm_uframes_t min_align;
223 unsigned int mmap_rw: 1; /* use always mmapped buffer */
224 unsigned int mmap_shadow: 1; /* don't call actual mmap,
225 * use the mmaped buffer of the slave
227 unsigned int donot_close: 1; /* don't close this PCM */
228 snd_pcm_channel_info_t *mmap_channels;
229 snd_pcm_channel_area_t *running_areas;
230 snd_pcm_channel_area_t *stopped_areas;
231 const snd_pcm_ops_t *ops;
232 const snd_pcm_fast_ops_t *fast_ops;
234 snd_pcm_t *fast_op_arg;
236 struct list_head async_handlers;
239 /* make local functions really local */
240 /* Grrr, these cannot be local - a bad aserver uses them!
241 #define snd_pcm_async \
243 #define snd_pcm_mmap \
245 #define snd_pcm_munmap \
247 #define snd_pcm_hw_refine \
250 #define snd_pcm_new \
252 #define snd_pcm_free \
254 #define snd_pcm_areas_from_buf \
255 snd1_pcm_areas_from_buf
256 #define snd_pcm_areas_from_bufs \
257 snd1_pcm_areas_from_bufs
258 #define snd_pcm_open_named_slave \
259 snd1_pcm_open_named_slave
260 #define snd_pcm_conf_generic_id \
261 snd1_pcm_conf_generic_id
262 #define snd_pcm_hw_open_fd \
264 #define snd_pcm_wait_nocheck \
265 snd1_pcm_wait_nocheck
266 #define snd_pcm_rate_get_default_converter \
267 snd1_pcm_rate_get_default_converter
268 #define snd_pcm_set_hw_ptr \
270 #define snd_pcm_set_appl_ptr \
271 snd1_pcm_set_appl_ptr
272 #define snd_pcm_link_hw_ptr \
274 #define snd_pcm_link_appl_ptr \
275 snd1_pcm_link_appl_ptr
276 #define snd_pcm_unlink_hw_ptr \
277 snd1_pcm_unlink_hw_ptr
278 #define snd_pcm_unlink_appl_ptr \
279 snd1_pcm_unlink_appl_ptr
280 #define snd_pcm_mmap_appl_ptr \
281 snd1_pcm_mmap_appl_ptr
282 #define snd_pcm_mmap_appl_backward \
283 snd1_pcm_mmap_appl_backward
284 #define snd_pcm_mmap_appl_forward \
285 snd1_pcm_mmap_appl_forward
286 #define snd_pcm_mmap_hw_backward \
287 snd1_pcm_mmap_hw_backward
288 #define snd_pcm_mmap_hw_forward \
289 snd1_pcm_mmap_hw_forward
290 #define snd_pcm_read_areas \
292 #define snd_pcm_write_areas \
294 #define snd_pcm_read_mmap \
296 #define snd_pcm_write_mmap \
298 #define snd_pcm_channel_info_shm \
299 snd1_pcm_channel_info_shm
300 #define snd_pcm_hw_refine_soft \
301 snd1_pcm_hw_refine_soft
302 #define snd_pcm_hw_refine_slave \
303 snd1_pcm_hw_refine_slave
304 #define snd_pcm_hw_params_slave \
305 snd1_pcm_hw_params_slave
306 #define snd_pcm_hw_param_refine_near \
307 snd1_pcm_hw_param_refine_near
308 #define snd_pcm_hw_param_refine_multiple \
309 snd1_pcm_hw_param_refine_multiple
310 #define snd_pcm_hw_param_empty \
311 snd1_pcm_hw_param_empty
312 #define snd_pcm_hw_param_always_eq \
313 snd1_pcm_hw_param_always_eq
314 #define snd_pcm_hw_param_never_eq \
315 snd1_pcm_hw_param_never_eq
316 #define snd_pcm_hw_param_get_mask \
317 snd1_pcm_hw_param_get_mask
318 #define snd_pcm_hw_param_get_interval \
319 snd1_pcm_hw_param_get_interval
320 #define snd_pcm_hw_param_any \
321 snd1_pcm_hw_param_any
322 #define snd_pcm_hw_param_set_integer \
323 snd1_pcm_hw_param_set_integer
324 #define snd_pcm_hw_param_set_first \
325 snd1_pcm_hw_param_set_first
326 #define snd_pcm_hw_param_set_last \
327 snd1_pcm_hw_param_set_last
328 #define snd_pcm_hw_param_set_near \
329 snd1_pcm_hw_param_set_near
330 #define snd_pcm_hw_param_set_min \
331 snd1_pcm_hw_param_set_min
332 #define snd_pcm_hw_param_set_max \
333 snd1_pcm_hw_param_set_max
334 #define snd_pcm_hw_param_set_minmax \
335 snd1_pcm_hw_param_set_minmax
336 #define snd_pcm_hw_param_set \
337 snd1_pcm_hw_param_set
338 #define snd_pcm_hw_param_set_mask \
339 snd1_pcm_hw_param_set_mask
340 #define snd_pcm_hw_param_get \
341 snd1_pcm_hw_param_get
342 #define snd_pcm_hw_param_get_min \
343 snd1_pcm_hw_param_get_min
344 #define snd_pcm_hw_param_get_max \
345 snd1_pcm_hw_param_get_max
346 #define snd_pcm_hw_param_name \
347 snd1_pcm_hw_param_name
349 int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name,
350 snd_pcm_stream_t stream, int mode);
351 int snd_pcm_free(snd_pcm_t *pcm);
353 void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, void *buf);
354 void snd_pcm_areas_from_bufs(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, void **bufs);
356 int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid);
357 int snd_pcm_mmap(snd_pcm_t *pcm);
358 int snd_pcm_munmap(snd_pcm_t *pcm);
359 int snd_pcm_mmap_ready(snd_pcm_t *pcm);
360 void snd_pcm_set_hw_ptr(snd_pcm_t *pcm, volatile snd_pcm_uframes_t *hw_ptr, int fd, off_t offset);
361 void snd_pcm_set_appl_ptr(snd_pcm_t *pcm, volatile snd_pcm_uframes_t *appl_ptr, int fd, off_t offset);
362 void snd_pcm_link_hw_ptr(snd_pcm_t *pcm, snd_pcm_t *slave);
363 void snd_pcm_link_appl_ptr(snd_pcm_t *pcm, snd_pcm_t *slave);
364 void snd_pcm_unlink_hw_ptr(snd_pcm_t *pcm, snd_pcm_t *slave);
365 void snd_pcm_unlink_appl_ptr(snd_pcm_t *pcm, snd_pcm_t *slave);
366 snd_pcm_sframes_t snd_pcm_mmap_appl_ptr(snd_pcm_t *pcm, off_t offset);
367 void snd_pcm_mmap_appl_backward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
368 void snd_pcm_mmap_appl_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
369 void snd_pcm_mmap_hw_backward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
370 void snd_pcm_mmap_hw_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
372 snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
373 snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
374 snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
375 snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
377 typedef snd_pcm_sframes_t (*snd_pcm_xfer_areas_func_t)(snd_pcm_t *pcm,
378 const snd_pcm_channel_area_t *areas,
379 snd_pcm_uframes_t offset,
380 snd_pcm_uframes_t size);
382 snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas,
383 snd_pcm_uframes_t offset, snd_pcm_uframes_t size,
384 snd_pcm_xfer_areas_func_t func);
385 snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas,
386 snd_pcm_uframes_t offset, snd_pcm_uframes_t size,
387 snd_pcm_xfer_areas_func_t func);
388 snd_pcm_sframes_t snd_pcm_read_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t offset,
389 snd_pcm_uframes_t size);
390 snd_pcm_sframes_t snd_pcm_write_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t offset,
391 snd_pcm_uframes_t size);
392 static inline int snd_pcm_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info)
394 return pcm->ops->channel_info(pcm, info);
396 int snd_pcm_channel_info_shm(snd_pcm_t *pcm, snd_pcm_channel_info_t *info, int shmid);
397 int _snd_pcm_poll_descriptor(snd_pcm_t *pcm);
398 #define _snd_pcm_link_descriptor _snd_pcm_poll_descriptor /* FIXME */
399 #define _snd_pcm_async_descriptor _snd_pcm_poll_descriptor /* FIXME */
401 /* handle special error cases */
402 static inline int snd_pcm_check_error(snd_pcm_t *pcm, int err)
405 switch (snd_pcm_state(pcm)) {
406 case SND_PCM_STATE_XRUN:
408 case SND_PCM_STATE_SUSPENDED:
410 case SND_PCM_STATE_DISCONNECTED:
419 static inline snd_pcm_uframes_t snd_pcm_mmap_playback_avail(snd_pcm_t *pcm)
421 snd_pcm_sframes_t avail;
422 avail = *pcm->hw.ptr + pcm->buffer_size - *pcm->appl.ptr;
424 avail += pcm->boundary;
425 else if ((snd_pcm_uframes_t) avail >= pcm->boundary)
426 avail -= pcm->boundary;
430 static inline snd_pcm_uframes_t snd_pcm_mmap_capture_avail(snd_pcm_t *pcm)
432 snd_pcm_sframes_t avail;
433 avail = *pcm->hw.ptr - *pcm->appl.ptr;
435 avail += pcm->boundary;
439 static inline snd_pcm_uframes_t snd_pcm_mmap_avail(snd_pcm_t *pcm)
441 if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
442 return snd_pcm_mmap_playback_avail(pcm);
444 return snd_pcm_mmap_capture_avail(pcm);
447 static inline snd_pcm_sframes_t snd_pcm_mmap_playback_hw_avail(snd_pcm_t *pcm)
449 return pcm->buffer_size - snd_pcm_mmap_playback_avail(pcm);
452 static inline snd_pcm_sframes_t snd_pcm_mmap_capture_hw_avail(snd_pcm_t *pcm)
454 return pcm->buffer_size - snd_pcm_mmap_capture_avail(pcm);
457 static inline snd_pcm_sframes_t snd_pcm_mmap_hw_avail(snd_pcm_t *pcm)
459 snd_pcm_sframes_t avail;
460 avail = *pcm->hw.ptr - *pcm->appl.ptr;
461 if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
462 avail += pcm->buffer_size;
464 avail += pcm->boundary;
465 return pcm->buffer_size - avail;
468 static inline const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm)
470 if (pcm->stopped_areas &&
471 snd_pcm_state(pcm) != SND_PCM_STATE_RUNNING)
472 return pcm->stopped_areas;
473 return pcm->running_areas;
476 static inline snd_pcm_uframes_t snd_pcm_mmap_offset(snd_pcm_t *pcm)
479 return *pcm->appl.ptr % pcm->buffer_size;
482 static inline snd_pcm_uframes_t snd_pcm_mmap_hw_offset(snd_pcm_t *pcm)
485 return *pcm->hw.ptr % pcm->buffer_size;
488 static inline snd_pcm_uframes_t snd_pcm_mmap_playback_delay(snd_pcm_t *pcm)
490 return snd_pcm_mmap_playback_hw_avail(pcm);
493 static inline snd_pcm_uframes_t snd_pcm_mmap_capture_delay(snd_pcm_t *pcm)
495 return snd_pcm_mmap_capture_hw_avail(pcm);
498 static inline snd_pcm_sframes_t snd_pcm_mmap_delay(snd_pcm_t *pcm)
500 if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
501 return snd_pcm_mmap_playback_delay(pcm);
503 return snd_pcm_mmap_capture_delay(pcm);
506 static inline void *snd_pcm_channel_area_addr(const snd_pcm_channel_area_t *area, snd_pcm_uframes_t offset)
508 unsigned int bitofs = area->first + area->step * offset;
509 assert(bitofs % 8 == 0);
510 return (char *) area->addr + bitofs / 8;
513 static inline unsigned int snd_pcm_channel_area_step(const snd_pcm_channel_area_t *area)
515 assert(area->step % 8 == 0);
516 return area->step / 8;
519 static inline snd_pcm_sframes_t _snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
521 return pcm->fast_ops->writei(pcm->fast_op_arg, buffer, size);
524 static inline snd_pcm_sframes_t _snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
526 return pcm->fast_ops->writen(pcm->fast_op_arg, bufs, size);
529 static inline snd_pcm_sframes_t _snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
531 return pcm->fast_ops->readi(pcm->fast_op_arg, buffer, size);
534 static inline snd_pcm_sframes_t _snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
536 return pcm->fast_ops->readn(pcm->fast_op_arg, bufs, size);
539 static inline int muldiv(int a, int b, int c, int *r)
541 int64_t n = (int64_t)a * b;
555 static inline int muldiv_down(int a, int b, int c)
557 int64_t v = (int64_t)a * b / c;
567 static inline int muldiv_near(int a, int b, int c)
570 int n = muldiv(a, b, c, &r);
571 if (r >= (c + 1) / 2)
576 int snd_pcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
577 int _snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
578 int snd_pcm_hw_refine_soft(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
579 int snd_pcm_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
580 int (*cprepare)(snd_pcm_t *pcm,
581 snd_pcm_hw_params_t *params),
582 int (*cchange)(snd_pcm_t *pcm,
583 snd_pcm_hw_params_t *params,
584 snd_pcm_hw_params_t *sparams),
585 int (*sprepare)(snd_pcm_t *pcm,
586 snd_pcm_hw_params_t *params),
587 int (*schange)(snd_pcm_t *pcm,
588 snd_pcm_hw_params_t *params,
589 snd_pcm_hw_params_t *sparams),
590 int (*srefine)(snd_pcm_t *pcm,
591 snd_pcm_hw_params_t *sparams));
592 int snd_pcm_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
593 int (*cchange)(snd_pcm_t *pcm,
594 snd_pcm_hw_params_t *params,
595 snd_pcm_hw_params_t *sparams),
596 int (*sprepare)(snd_pcm_t *pcm,
597 snd_pcm_hw_params_t *params),
598 int (*schange)(snd_pcm_t *pcm,
599 snd_pcm_hw_params_t *params,
600 snd_pcm_hw_params_t *sparams),
601 int (*sparams)(snd_pcm_t *pcm,
602 snd_pcm_hw_params_t *sparams));
605 void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params);
606 void _snd_pcm_hw_param_set_empty(snd_pcm_hw_params_t *params,
607 snd_pcm_hw_param_t var);
608 int _snd_pcm_hw_param_set_interval(snd_pcm_hw_params_t *params,
609 snd_pcm_hw_param_t var,
610 const snd_interval_t *val);
611 int _snd_pcm_hw_param_set_mask(snd_pcm_hw_params_t *params,
612 snd_pcm_hw_param_t var, const snd_mask_t *mask);
613 int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params,
614 snd_pcm_hw_param_t var);
615 int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params,
616 snd_pcm_hw_param_t var);
617 int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params,
618 snd_pcm_hw_param_t var, unsigned int val, int dir);
619 static inline int _snd_pcm_hw_params_set_format(snd_pcm_hw_params_t *params,
620 snd_pcm_format_t val)
622 return _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_FORMAT,
623 (unsigned long) val, 0);
626 static inline int _snd_pcm_hw_params_set_subformat(snd_pcm_hw_params_t *params,
627 snd_pcm_subformat_t val)
629 return _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_SUBFORMAT,
630 (unsigned long) val, 0);
633 int _snd_pcm_hw_param_set_min(snd_pcm_hw_params_t *params,
634 snd_pcm_hw_param_t var, unsigned int val, int dir);
635 int _snd_pcm_hw_param_set_max(snd_pcm_hw_params_t *params,
636 snd_pcm_hw_param_t var, unsigned int val, int dir);
637 int _snd_pcm_hw_param_set_minmax(snd_pcm_hw_params_t *params,
638 snd_pcm_hw_param_t var,
639 unsigned int min, int mindir,
640 unsigned int max, int maxdir);
641 int _snd_pcm_hw_param_refine(snd_pcm_hw_params_t *params,
642 snd_pcm_hw_param_t var,
643 const snd_pcm_hw_params_t *src);
644 int _snd_pcm_hw_params_refine(snd_pcm_hw_params_t *params,
646 const snd_pcm_hw_params_t *src);
647 int snd_pcm_hw_param_refine_near(snd_pcm_t *pcm,
648 snd_pcm_hw_params_t *params,
649 snd_pcm_hw_param_t var,
650 const snd_pcm_hw_params_t *src);
651 int snd_pcm_hw_param_refine_multiple(snd_pcm_t *pcm,
652 snd_pcm_hw_params_t *params,
653 snd_pcm_hw_param_t var,
654 const snd_pcm_hw_params_t *src);
655 int snd_pcm_hw_param_empty(const snd_pcm_hw_params_t *params,
656 snd_pcm_hw_param_t var);
657 int snd_pcm_hw_param_always_eq(const snd_pcm_hw_params_t *params,
658 snd_pcm_hw_param_t var,
659 const snd_pcm_hw_params_t *params1);
660 int snd_pcm_hw_param_never_eq(const snd_pcm_hw_params_t *params,
661 snd_pcm_hw_param_t var,
662 const snd_pcm_hw_params_t *params1);
663 const snd_mask_t *snd_pcm_hw_param_get_mask(const snd_pcm_hw_params_t *params,
664 snd_pcm_hw_param_t var);
665 const snd_interval_t *snd_pcm_hw_param_get_interval(const snd_pcm_hw_params_t *params,
666 snd_pcm_hw_param_t var);
668 int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
669 snd_pcm_hw_param_t var);
670 int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
672 snd_pcm_hw_param_t var);
673 int snd_pcm_hw_param_set_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
674 snd_pcm_hw_param_t var, unsigned int *rval, int *dir);
675 int snd_pcm_hw_param_set_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
676 snd_pcm_hw_param_t var, unsigned int *rval, int *dir);
677 int snd_pcm_hw_param_set_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
678 snd_pcm_hw_param_t var, unsigned int *val, int *dir);
679 int snd_pcm_hw_param_set_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
681 snd_pcm_hw_param_t var,
682 unsigned int *val, int *dir);
683 int snd_pcm_hw_param_set_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
685 snd_pcm_hw_param_t var, unsigned int *val, int *dir);
686 int snd_pcm_hw_param_set_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
688 snd_pcm_hw_param_t var,
689 unsigned int *min, int *mindir,
690 unsigned int *max, int *maxdir);
691 int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
693 snd_pcm_hw_param_t var, unsigned int val, int dir);
694 int snd_pcm_hw_param_set_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
696 snd_pcm_hw_param_t var, const snd_mask_t *mask);
697 int snd_pcm_hw_param_get(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var,
698 unsigned int *val, int *dir);
699 int snd_pcm_hw_param_get_min(const snd_pcm_hw_params_t *params,
700 snd_pcm_hw_param_t var,
701 unsigned int *val, int *dir);
702 int snd_pcm_hw_param_get_max(const snd_pcm_hw_params_t *params,
703 snd_pcm_hw_param_t var,
704 unsigned int *val, int *dir);
707 snd_pcm_sframes_t INTERNAL(snd_pcm_forward)(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
709 int INTERNAL(snd_pcm_hw_params_get_access)(const snd_pcm_hw_params_t *params, snd_pcm_access_t *access);
710 int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t access);
711 int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t access);
712 int INTERNAL(snd_pcm_hw_params_set_access_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *access);
713 int INTERNAL(snd_pcm_hw_params_set_access_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *access);
714 int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask);
715 int snd_pcm_hw_params_get_access_mask(snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask);
717 int INTERNAL(snd_pcm_hw_params_get_format)(const snd_pcm_hw_params_t *params, snd_pcm_format_t *val);
718 int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
719 int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
720 int INTERNAL(snd_pcm_hw_params_set_format_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format);
721 int INTERNAL(snd_pcm_hw_params_set_format_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format);
722 int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask);
723 void snd_pcm_hw_params_get_format_mask(snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask);
725 int INTERNAL(snd_pcm_hw_params_get_subformat)(const snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat);
726 int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t subformat);
727 int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t subformat);
728 int INTERNAL(snd_pcm_hw_params_set_subformat_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat);
729 int INTERNAL(snd_pcm_hw_params_set_subformat_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat);
730 int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask);
731 void snd_pcm_hw_params_get_subformat_mask(snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask);
733 int INTERNAL(snd_pcm_hw_params_get_channels)(const snd_pcm_hw_params_t *params, unsigned int *val);
734 int INTERNAL(snd_pcm_hw_params_get_channels_min)(const snd_pcm_hw_params_t *params, unsigned int *val);
735 int INTERNAL(snd_pcm_hw_params_get_channels_max)(const snd_pcm_hw_params_t *params, unsigned int *val);
736 int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
737 int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
738 int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
739 int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
740 int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max);
741 int INTERNAL(snd_pcm_hw_params_set_channels_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
742 int INTERNAL(snd_pcm_hw_params_set_channels_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
743 int INTERNAL(snd_pcm_hw_params_set_channels_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
745 int INTERNAL(snd_pcm_hw_params_get_rate)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
746 int INTERNAL(snd_pcm_hw_params_get_rate_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
747 int INTERNAL(snd_pcm_hw_params_get_rate_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
748 int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
749 int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
750 int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
751 int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
752 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);
753 int INTERNAL(snd_pcm_hw_params_set_rate_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
754 int INTERNAL(snd_pcm_hw_params_set_rate_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
755 int INTERNAL(snd_pcm_hw_params_set_rate_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
757 int INTERNAL(snd_pcm_hw_params_get_period_time)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
758 int INTERNAL(snd_pcm_hw_params_get_period_time_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
759 int INTERNAL(snd_pcm_hw_params_get_period_time_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
760 int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
761 int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
762 int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
763 int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
764 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);
765 int INTERNAL(snd_pcm_hw_params_set_period_time_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
766 int INTERNAL(snd_pcm_hw_params_set_period_time_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
767 int INTERNAL(snd_pcm_hw_params_set_period_time_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
769 int INTERNAL(snd_pcm_hw_params_get_period_size)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
770 int INTERNAL(snd_pcm_hw_params_get_period_size_min)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
771 int INTERNAL(snd_pcm_hw_params_get_period_size_max)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
772 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);
773 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);
774 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);
775 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);
776 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);
777 int INTERNAL(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);
778 int INTERNAL(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);
779 int INTERNAL(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);
780 int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
782 int INTERNAL(snd_pcm_hw_params_get_periods)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
783 int INTERNAL(snd_pcm_hw_params_get_periods_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
784 int INTERNAL(snd_pcm_hw_params_get_periods_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
785 int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
786 int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
787 int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
788 int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
789 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);
790 int INTERNAL(snd_pcm_hw_params_set_periods_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
791 int INTERNAL(snd_pcm_hw_params_set_periods_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
792 int INTERNAL(snd_pcm_hw_params_set_periods_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
793 int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
795 int INTERNAL(snd_pcm_hw_params_get_buffer_time)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
796 int INTERNAL(snd_pcm_hw_params_get_buffer_time_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
797 int INTERNAL(snd_pcm_hw_params_get_buffer_time_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
798 int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
799 int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
800 int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
801 int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
802 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);
803 int INTERNAL(snd_pcm_hw_params_set_buffer_time_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
804 int INTERNAL(snd_pcm_hw_params_set_buffer_time_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
805 int INTERNAL(snd_pcm_hw_params_set_buffer_time_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
807 int INTERNAL(snd_pcm_hw_params_get_buffer_size)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
808 int INTERNAL(snd_pcm_hw_params_get_buffer_size_min)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
809 int INTERNAL(snd_pcm_hw_params_get_buffer_size_max)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
810 int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
811 int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
812 int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
813 int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
814 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);
815 int INTERNAL(snd_pcm_hw_params_set_buffer_size_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
816 int INTERNAL(snd_pcm_hw_params_set_buffer_size_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
817 int INTERNAL(snd_pcm_hw_params_set_buffer_size_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
819 int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val);
820 int INTERNAL(snd_pcm_sw_params_get_tstamp_mode)(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_t *val);
821 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
822 int INTERNAL(snd_pcm_sw_params_get_avail_min)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
823 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
824 int INTERNAL(snd_pcm_sw_params_get_start_threshold)(const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val);
825 int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
826 int INTERNAL(snd_pcm_sw_params_get_stop_threshold)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
827 int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
828 int INTERNAL(snd_pcm_sw_params_get_silence_threshold)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
829 int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
830 int INTERNAL(snd_pcm_sw_params_get_silence_size)(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
831 #endif /* INTERNAL */
833 const char *snd_pcm_hw_param_name(snd_pcm_hw_param_t param);
834 void snd_pcm_hw_param_dump(const snd_pcm_hw_params_t *params,
835 snd_pcm_hw_param_t var, snd_output_t *out);
837 int snd_pcm_hw_strategy_simple_near(snd_pcm_hw_strategy_t *strategy, int order,
838 snd_pcm_hw_param_t var,
841 int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy, int order,
842 snd_pcm_hw_param_t var,
844 snd_pcm_hw_strategy_simple_choices_list_t *choices);
847 #define SCONF_MANDATORY 1
848 #define SCONF_UNCHANGED 2
850 int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
851 snd_config_t **pcm_conf, unsigned int count, ...);
853 #define SND_PCM_APPEND (1<<8)
855 int snd_pcm_open_named_slave(snd_pcm_t **pcmp, const char *name,
857 snd_config_t *conf, snd_pcm_stream_t stream,
858 int mode, snd_config_t *parent_conf);
860 snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *root,
861 snd_config_t *conf, snd_pcm_stream_t stream,
862 int mode, snd_config_t *parent_conf)
864 return snd_pcm_open_named_slave(pcmp, NULL, root, conf, stream,
867 int snd_pcm_conf_generic_id(const char *id);
869 int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, int mmap_emulation, int sync_ptr_ioctl);
870 int __snd_pcm_mmap_emul_open(snd_pcm_t **pcmp, const char *name,
871 snd_pcm_t *slave, int close_slave);
873 int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout);
875 const snd_config_t *snd_pcm_rate_get_default_converter(snd_config_t *root);
877 #define SND_PCM_HW_PARBIT_ACCESS (1U << SND_PCM_HW_PARAM_ACCESS)
878 #define SND_PCM_HW_PARBIT_FORMAT (1U << SND_PCM_HW_PARAM_FORMAT)
879 #define SND_PCM_HW_PARBIT_SUBFORMAT (1U << SND_PCM_HW_PARAM_SUBFORMAT)
880 #define SND_PCM_HW_PARBIT_CHANNELS (1U << SND_PCM_HW_PARAM_CHANNELS)
881 #define SND_PCM_HW_PARBIT_RATE (1U << SND_PCM_HW_PARAM_RATE)
882 #define SND_PCM_HW_PARBIT_PERIOD_TIME (1U << SND_PCM_HW_PARAM_PERIOD_TIME)
883 #define SND_PCM_HW_PARBIT_PERIOD_SIZE (1U << SND_PCM_HW_PARAM_PERIOD_SIZE)
884 #define SND_PCM_HW_PARBIT_PERIODS (1U << SND_PCM_HW_PARAM_PERIODS)
885 #define SND_PCM_HW_PARBIT_BUFFER_TIME (1U << SND_PCM_HW_PARAM_BUFFER_TIME)
886 #define SND_PCM_HW_PARBIT_BUFFER_SIZE (1U << SND_PCM_HW_PARAM_BUFFER_SIZE)
887 #define SND_PCM_HW_PARBIT_SAMPLE_BITS (1U << SND_PCM_HW_PARAM_SAMPLE_BITS)
888 #define SND_PCM_HW_PARBIT_FRAME_BITS (1U << SND_PCM_HW_PARAM_FRAME_BITS)
889 #define SND_PCM_HW_PARBIT_PERIOD_BYTES (1U << SND_PCM_HW_PARAM_PERIOD_BYTES)
890 #define SND_PCM_HW_PARBIT_BUFFER_BYTES (1U << SND_PCM_HW_PARAM_BUFFER_BYTES)
891 #define SND_PCM_HW_PARBIT_TICK_TIME (1U << SND_PCM_HW_PARAM_TICK_TIME)
894 #define SND_PCM_ACCBIT_MMAP { ((1U << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
895 (1U << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
896 (1U << SND_PCM_ACCESS_MMAP_COMPLEX)) }
897 #define SND_PCM_ACCBIT_MMAPI { (1U << SND_PCM_ACCESS_MMAP_INTERLEAVED) }
898 #define SND_PCM_ACCBIT_MMAPN { (1U << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) }
899 #define SND_PCM_ACCBIT_MMAPC { (1U << SND_PCM_ACCESS_MMAP_COMPLEX) }
901 #define SND_PCM_ACCBIT_SHM { ((1U << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
902 (1U << SND_PCM_ACCESS_RW_INTERLEAVED) | \
903 (1U << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
904 (1U << SND_PCM_ACCESS_RW_NONINTERLEAVED)) }
905 #define SND_PCM_ACCBIT_SHMI { ((1U << SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
906 (1U << SND_PCM_ACCESS_RW_INTERLEAVED)) }
907 #define SND_PCM_ACCBIT_SHMN { ((1U << SND_PCM_ACCESS_MMAP_NONINTERLEAVED) | \
908 (1U << SND_PCM_ACCESS_RW_NONINTERLEAVED)) }
910 #define SND_PCM_FMTBIT_LINEAR \
911 { ((1U << SND_PCM_FORMAT_S8) | \
912 (1U << SND_PCM_FORMAT_U8) | \
913 (1U << SND_PCM_FORMAT_S16_LE) | \
914 (1U << SND_PCM_FORMAT_S16_BE) | \
915 (1U << SND_PCM_FORMAT_U16_LE) | \
916 (1U << SND_PCM_FORMAT_U16_BE) | \
917 (1U << SND_PCM_FORMAT_S24_LE) | \
918 (1U << SND_PCM_FORMAT_S24_BE) | \
919 (1U << SND_PCM_FORMAT_U24_LE) | \
920 (1U << SND_PCM_FORMAT_U24_BE) | \
921 (1U << SND_PCM_FORMAT_S32_LE) | \
922 (1U << SND_PCM_FORMAT_S32_BE) | \
923 (1U << SND_PCM_FORMAT_U32_LE) | \
924 (1U << SND_PCM_FORMAT_U32_BE)), \
925 ((1U << (SND_PCM_FORMAT_S24_3LE - 32)) | \
926 (1U << (SND_PCM_FORMAT_U24_3LE - 32)) | \
927 (1U << (SND_PCM_FORMAT_S24_3BE - 32)) | \
928 (1U << (SND_PCM_FORMAT_U24_3BE - 32)) | \
929 (1U << (SND_PCM_FORMAT_S20_3LE - 32)) | \
930 (1U << (SND_PCM_FORMAT_U20_3LE - 32)) | \
931 (1U << (SND_PCM_FORMAT_S20_3BE - 32)) | \
932 (1U << (SND_PCM_FORMAT_U20_3BE - 32)) | \
933 (1U << (SND_PCM_FORMAT_S18_3LE - 32)) | \
934 (1U << (SND_PCM_FORMAT_U18_3LE - 32)) | \
935 (1U << (SND_PCM_FORMAT_S18_3BE - 32)) | \
936 (1U << (SND_PCM_FORMAT_U18_3BE - 32))) }
939 #define SND_PCM_FMTBIT_FLOAT \
940 { ((1U << SND_PCM_FORMAT_FLOAT_LE) | \
941 (1U << SND_PCM_FORMAT_FLOAT_BE) | \
942 (1U << SND_PCM_FORMAT_FLOAT64_LE) | \
943 (1U << SND_PCM_FORMAT_FLOAT64_BE)) }
946 typedef union snd_tmp_float {
951 typedef union snd_tmp_double {
956 /* get the current timestamp */
957 static inline void gettimestamp(snd_htimestamp_t *tstamp, int monotonic)
959 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
961 clock_gettime(CLOCK_MONOTONIC, tstamp);
966 gettimeofday(&tv, 0);
967 tstamp->tv_sec = tv.tv_sec;
968 tstamp->tv_nsec = tv.tv_usec * 1000L;
969 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)