ALSA project - the C library reference
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pcm.h
Go to the documentation of this file.
1 
12 /*
13  * This library is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as
15  * published by the Free Software Foundation; either version 2.1 of
16  * the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26  *
27  */
28 
29 #ifndef __ALSA_PCM_H
30 #define __ALSA_PCM_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <stdint.h>
37 
45 #define SND_PCM_DLSYM_VERSION _dlsym_pcm_001
46 
48 typedef struct _snd_pcm_info snd_pcm_info_t;
49 
64 typedef struct _snd_pcm_hw_params snd_pcm_hw_params_t;
65 
67 typedef struct _snd_pcm_sw_params snd_pcm_sw_params_t;
69  typedef struct _snd_pcm_status snd_pcm_status_t;
71 typedef struct _snd_pcm_access_mask snd_pcm_access_mask_t;
73 typedef struct _snd_pcm_format_mask snd_pcm_format_mask_t;
75 typedef struct _snd_pcm_subformat_mask snd_pcm_subformat_mask_t;
76 
78 typedef enum _snd_pcm_class {
88  SND_PCM_CLASS_LAST = SND_PCM_CLASS_DIGITIZER
90 
92 typedef enum _snd_pcm_subclass {
97  SND_PCM_SUBCLASS_LAST = SND_PCM_SUBCLASS_MULTI_MIX
99 
101 typedef enum _snd_pcm_stream {
106  SND_PCM_STREAM_LAST = SND_PCM_STREAM_CAPTURE
108 
110 typedef enum _snd_pcm_access {
121  SND_PCM_ACCESS_LAST = SND_PCM_ACCESS_RW_NONINTERLEAVED
123 
125 typedef enum _snd_pcm_format {
212  /* G.723 (ADPCM) 24 kbit/s, 8 samples in 3 bytes */
213  SND_PCM_FORMAT_G723_24,
214  /* G.723 (ADPCM) 24 kbit/s, 1 sample in 1 byte */
215  SND_PCM_FORMAT_G723_24_1B,
216  /* G.723 (ADPCM) 40 kbit/s, 8 samples in 3 bytes */
217  SND_PCM_FORMAT_G723_40,
218  /* G.723 (ADPCM) 40 kbit/s, 1 sample in 1 byte */
219  SND_PCM_FORMAT_G723_40_1B,
220  /* Direct Stream Digital (DSD) in 1-byte samples (x8) */
221  SND_PCM_FORMAT_DSD_U8,
222  /* Direct Stream Digital (DSD) in 2-byte samples (x16) */
223  SND_PCM_FORMAT_DSD_U16_LE,
224  /* Direct Stream Digital (DSD) in 4-byte samples (x32) */
225  SND_PCM_FORMAT_DSD_U32_LE,
226  /* Direct Stream Digital (DSD) in 2-byte samples (x16) */
227  SND_PCM_FORMAT_DSD_U16_BE,
228  /* Direct Stream Digital (DSD) in 4-byte samples (x32) */
229  SND_PCM_FORMAT_DSD_U32_BE,
230  SND_PCM_FORMAT_LAST = SND_PCM_FORMAT_DSD_U32_BE,
231 
232 #if __BYTE_ORDER == __LITTLE_ENDIAN
233 
255 #elif __BYTE_ORDER == __BIG_ENDIAN
256 
278 #else
279 #error "Unknown endian"
280 #endif
282 
284 typedef enum _snd_pcm_subformat {
287  SND_PCM_SUBFORMAT_LAST = SND_PCM_SUBFORMAT_STD
289 
291 typedef enum _snd_pcm_state {
310  SND_PCM_STATE_LAST = SND_PCM_STATE_DISCONNECTED,
314 
316 typedef enum _snd_pcm_start {
321  SND_PCM_START_LAST = SND_PCM_START_EXPLICIT
323 
325 typedef enum _snd_pcm_xrun {
330  SND_PCM_XRUN_LAST = SND_PCM_XRUN_STOP
332 
334 typedef enum _snd_pcm_tstamp {
343  SND_PCM_TSTAMP_LAST = SND_PCM_TSTAMP_ENABLE
345 
346 typedef enum _snd_pcm_tstamp_type {
350  SND_PCM_TSTAMP_TYPE_LAST = SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW,
352 
353 typedef struct _snd_pcm_audio_tstamp_config {
354  /* 5 of max 16 bits used */
355  unsigned int type_requested:4;
356  unsigned int report_delay:1; /* add total delay to A/D or D/A */
358 
359 typedef struct _snd_pcm_audio_tstamp_report {
360  /* 6 of max 16 bits used for bit-fields */
361 
362  /* for backwards compatibility */
363  unsigned int valid:1;
364 
365  /* actual type if hardware could not support requested timestamp */
366  unsigned int actual_type:4;
367 
368  /* accuracy represented in ns units */
369  unsigned int accuracy_report:1; /* 0 if accuracy unknown, 1 if accuracy field is valid */
370  unsigned int accuracy; /* up to 4.29s, will be packed in separate field */
372 
374 typedef unsigned long snd_pcm_uframes_t;
376 typedef long snd_pcm_sframes_t;
377 
379 #define SND_PCM_NONBLOCK 0x00000001
380 
381 #define SND_PCM_ASYNC 0x00000002
382 
383 #define SND_PCM_ABORT 0x00008000
384 
385 #define SND_PCM_NO_AUTO_RESAMPLE 0x00010000
386 
387 #define SND_PCM_NO_AUTO_CHANNELS 0x00020000
388 
389 #define SND_PCM_NO_AUTO_FORMAT 0x00040000
390 
391 #define SND_PCM_NO_SOFTVOL 0x00080000
392 
394 typedef struct _snd_pcm snd_pcm_t;
395 
461  SND_PCM_TYPE_LAST = SND_PCM_TYPE_MMAP_EMUL
462 };
463 
466 
468 typedef struct _snd_pcm_channel_area {
470  void *addr;
472  unsigned int first;
474  unsigned int step;
476 
478 typedef union _snd_pcm_sync_id {
480  unsigned char id[16];
482  unsigned short id16[8];
484  unsigned int id32[4];
486 
488 typedef struct _snd_pcm_scope snd_pcm_scope_t;
489 
490 int snd_pcm_open(snd_pcm_t **pcm, const char *name,
491  snd_pcm_stream_t stream, int mode);
492 int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name,
493  snd_pcm_stream_t stream, int mode,
494  snd_config_t *lconf);
496  const char *name, const char *orig_name,
497  snd_pcm_stream_t stream, int mode);
498 
499 int snd_pcm_close(snd_pcm_t *pcm);
500 const char *snd_pcm_name(snd_pcm_t *pcm);
501 snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm);
504 int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
505 int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
506 int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
507 static __inline__ int snd_pcm_abort(snd_pcm_t *pcm) { return snd_pcm_nonblock(pcm, 2); }
509  snd_async_callback_t callback, void *private_data);
511 int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
514 int snd_pcm_hw_free(snd_pcm_t *pcm);
517 int snd_pcm_prepare(snd_pcm_t *pcm);
518 int snd_pcm_reset(snd_pcm_t *pcm);
519 int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status);
520 int snd_pcm_start(snd_pcm_t *pcm);
521 int snd_pcm_drop(snd_pcm_t *pcm);
522 int snd_pcm_drain(snd_pcm_t *pcm);
523 int snd_pcm_pause(snd_pcm_t *pcm, int enable);
525 int snd_pcm_hwsync(snd_pcm_t *pcm);
526 int snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
527 int snd_pcm_resume(snd_pcm_t *pcm);
528 int snd_pcm_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail, snd_htimestamp_t *tstamp);
529 snd_pcm_sframes_t snd_pcm_avail(snd_pcm_t *pcm);
530 snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm);
531 int snd_pcm_avail_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *availp, snd_pcm_sframes_t *delayp);
532 snd_pcm_sframes_t snd_pcm_rewindable(snd_pcm_t *pcm);
533 snd_pcm_sframes_t snd_pcm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
534 snd_pcm_sframes_t snd_pcm_forwardable(snd_pcm_t *pcm);
535 snd_pcm_sframes_t snd_pcm_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
536 snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
537 snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
538 snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
539 snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
540 int snd_pcm_wait(snd_pcm_t *pcm, int timeout);
541 
542 int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2);
543 int snd_pcm_unlink(snd_pcm_t *pcm);
544 
546 #define SND_CHMAP_API_VERSION ((1 << 16) | (0 << 8) | 1)
547 
555 };
556 
596  SND_CHMAP_LAST = SND_CHMAP_BRC,
597 };
598 
600 #define SND_CHMAP_POSITION_MASK 0xffff
601 
603 #define SND_CHMAP_PHASE_INVERSE (0x01 << 16)
604 
605 #define SND_CHMAP_DRIVER_SPEC (0x02 << 16)
606 
608 typedef struct snd_pcm_chmap {
609  unsigned int channels;
610  unsigned int pos[0];
612 
614 typedef struct snd_pcm_chmap_query {
618 
619 
622  int subdev,
623  snd_pcm_stream_t stream);
626 int snd_pcm_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map);
627 
628 const char *snd_pcm_chmap_type_name(enum snd_pcm_chmap_type val);
629 const char *snd_pcm_chmap_name(enum snd_pcm_chmap_position val);
630 const char *snd_pcm_chmap_long_name(enum snd_pcm_chmap_position val);
631 int snd_pcm_chmap_print(const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
632 unsigned int snd_pcm_chmap_from_string(const char *str);
634 
635 //int snd_pcm_mixer_element(snd_pcm_t *pcm, snd_mixer_t *mixer, snd_mixer_elem_t **elem);
636 
637 /*
638  * application helpers - these functions are implemented on top
639  * of the basic API
640  */
641 
642 int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent);
644  snd_pcm_format_t format,
645  snd_pcm_access_t access,
646  unsigned int channels,
647  unsigned int rate,
648  int soft_resample,
649  unsigned int latency);
651  snd_pcm_uframes_t *buffer_size,
652  snd_pcm_uframes_t *period_size);
653 
663 size_t snd_pcm_info_sizeof(void);
668 #define snd_pcm_info_alloca(ptr) __snd_alloca(ptr, snd_pcm_info)
671 void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src);
672 unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj);
673 unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj);
675 int snd_pcm_info_get_card(const snd_pcm_info_t *obj);
676 const char *snd_pcm_info_get_id(const snd_pcm_info_t *obj);
677 const char *snd_pcm_info_get_name(const snd_pcm_info_t *obj);
678 const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj);
681 unsigned int snd_pcm_info_get_subdevices_count(const snd_pcm_info_t *obj);
682 unsigned int snd_pcm_info_get_subdevices_avail(const snd_pcm_info_t *obj);
684 void snd_pcm_info_set_device(snd_pcm_info_t *obj, unsigned int val);
685 void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val);
687 
698 
711 int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params); /* deprecated, use audio_ts_type */
714  unsigned int *rate_num,
715  unsigned int *rate_den);
718 
719 #if 0
720 typedef struct _snd_pcm_hw_strategy snd_pcm_hw_strategy_t;
721 
722 /* choices need to be sorted on ascending badness */
723 typedef struct _snd_pcm_hw_strategy_simple_choices_list {
724  unsigned int value;
725  unsigned int badness;
726 } snd_pcm_hw_strategy_simple_choices_list_t;
727 
728 int snd_pcm_hw_params_strategy(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
729  const snd_pcm_hw_strategy_t *strategy,
730  unsigned int badness_min,
731  unsigned int badness_max);
732 
733 void snd_pcm_hw_strategy_free(snd_pcm_hw_strategy_t *strategy);
734 int snd_pcm_hw_strategy_simple(snd_pcm_hw_strategy_t **strategyp,
735  unsigned int badness_min,
736  unsigned int badness_max);
737 int snd_pcm_hw_params_try_explain_failure(snd_pcm_t *pcm,
738  snd_pcm_hw_params_t *fail,
739  snd_pcm_hw_params_t *success,
740  unsigned int depth,
741  snd_output_t *out);
742 
743 #endif
744 
745 size_t snd_pcm_hw_params_sizeof(void);
750 #define snd_pcm_hw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_hw_params)
754 
755 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
756 
764 
772 
780 
781 int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params, unsigned int *val);
782 int snd_pcm_hw_params_get_channels_min(const snd_pcm_hw_params_t *params, unsigned int *val);
783 int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *params, unsigned int *val);
784 int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
785 int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
786 int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
787 int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
788 int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max);
789 int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
790 int snd_pcm_hw_params_set_channels_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
791 int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
792 
793 int snd_pcm_hw_params_get_rate(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
794 int snd_pcm_hw_params_get_rate_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
795 int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
796 int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
797 int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
798 int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
799 int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
800 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);
801 int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
802 int snd_pcm_hw_params_set_rate_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
803 int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
804 int snd_pcm_hw_params_set_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
805 int snd_pcm_hw_params_get_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
806 int snd_pcm_hw_params_set_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
807 int snd_pcm_hw_params_get_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
808 int snd_pcm_hw_params_set_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
809 int snd_pcm_hw_params_get_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
810 
811 int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
812 int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
813 int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
814 int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
815 int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
816 int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
817 int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
818 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);
819 int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
820 int snd_pcm_hw_params_set_period_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
821 int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
822 
823 int snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
824 int snd_pcm_hw_params_get_period_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
825 int snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
826 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);
827 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);
828 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);
829 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);
830 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);
831 int snd_pcm_hw_params_set_period_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
832 int snd_pcm_hw_params_set_period_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
833 int snd_pcm_hw_params_set_period_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
835 
836 int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
837 int snd_pcm_hw_params_get_periods_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
838 int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
839 int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
840 int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
841 int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
842 int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
843 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);
844 int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
845 int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
846 int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
848 
849 int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
850 int snd_pcm_hw_params_get_buffer_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
851 int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
852 int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
853 int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
854 int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
855 int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
856 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);
857 int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
858 int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
859 int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
860 
861 int snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
862 int snd_pcm_hw_params_get_buffer_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
863 int snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
864 int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
865 int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
866 int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
867 int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
868 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);
869 int snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
870 int snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
871 int snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
872 
873 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
874 
875 int snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
876 
886 size_t snd_pcm_sw_params_sizeof(void);
891 #define snd_pcm_sw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_sw_params)
895 int snd_pcm_sw_params_get_boundary(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
896 
897 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_SW_PARAMS_API)
898 
903 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
904 int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
906 int snd_pcm_sw_params_get_period_event(const snd_pcm_sw_params_t *params, int *val);
907 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
908 int snd_pcm_sw_params_get_start_threshold(const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val);
909 int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
910 int snd_pcm_sw_params_get_stop_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
911 int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
912 int snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
913 int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
914 int snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
915 
916 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
917 
920 /* include old API */
921 #ifndef ALSA_LIBRARY_BUILD
922 #if defined(ALSA_PCM_OLD_HW_PARAMS_API) || defined(ALSA_PCM_OLD_SW_PARAMS_API)
923 #include "pcm_old.h"
924 #endif
925 #endif
926 
934 size_t snd_pcm_access_mask_sizeof(void);
939 #define snd_pcm_access_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_access_mask)
949 
959 size_t snd_pcm_format_mask_sizeof(void);
964 #define snd_pcm_format_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_format_mask)
974 
984 size_t snd_pcm_subformat_mask_sizeof(void);
989 #define snd_pcm_subformat_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_subformat_mask)
999 
1009 size_t snd_pcm_status_sizeof(void);
1014 #define snd_pcm_status_alloca(ptr) __snd_alloca(ptr, snd_pcm_status)
1026  snd_pcm_audio_tstamp_report_t *audio_tstamp_report);
1028  snd_pcm_audio_tstamp_config_t *audio_tstamp_config);
1029 
1030 static inline void snd_pcm_pack_audio_tstamp_config(unsigned int *data,
1032 {
1033  *data = config->report_delay;
1034  *data <<= 4;
1035  *data |= config->type_requested;
1036 }
1037 
1038 static inline void snd_pcm_unpack_audio_tstamp_report(unsigned int data, unsigned int accuracy,
1040 {
1041  data >>= 16;
1042  report->valid = data & 1;
1043  report->actual_type = (data >> 1) & 0xF;
1044  report->accuracy_report = (data >> 5) & 1;
1045  report->accuracy = accuracy;
1046 }
1047 
1048 snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj);
1049 snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj);
1050 snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj);
1051 snd_pcm_uframes_t snd_pcm_status_get_overrange(const snd_pcm_status_t *obj);
1052 
1062 const char *snd_pcm_type_name(snd_pcm_type_t type);
1063 const char *snd_pcm_stream_name(const snd_pcm_stream_t stream);
1064 const char *snd_pcm_access_name(const snd_pcm_access_t _access);
1065 const char *snd_pcm_format_name(const snd_pcm_format_t format);
1066 const char *snd_pcm_format_description(const snd_pcm_format_t format);
1067 const char *snd_pcm_subformat_name(const snd_pcm_subformat_t subformat);
1068 const char *snd_pcm_subformat_description(const snd_pcm_subformat_t subformat);
1069 snd_pcm_format_t snd_pcm_format_value(const char* name);
1070 const char *snd_pcm_tstamp_mode_name(const snd_pcm_tstamp_t mode);
1071 const char *snd_pcm_state_name(const snd_pcm_state_t state);
1072 
1082 int snd_pcm_dump(snd_pcm_t *pcm, snd_output_t *out);
1085 int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out);
1089 
1099 int snd_pcm_mmap_begin(snd_pcm_t *pcm,
1100  const snd_pcm_channel_area_t **areas,
1101  snd_pcm_uframes_t *offset,
1102  snd_pcm_uframes_t *frames);
1103 snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm,
1104  snd_pcm_uframes_t offset,
1105  snd_pcm_uframes_t frames);
1106 snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
1107 snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
1108 snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
1109 snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
1110 
1127 int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */
1128 int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */
1129 snd_pcm_format_t snd_pcm_build_linear_format(int width, int pwidth, int unsignd, int big_endian);
1130 ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
1135 int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int samples);
1136 
1137 snd_pcm_sframes_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes);
1138 ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *pcm, snd_pcm_sframes_t frames);
1139 long snd_pcm_bytes_to_samples(snd_pcm_t *pcm, ssize_t bytes);
1140 ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, long samples);
1141 
1142 int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset,
1143  unsigned int samples, snd_pcm_format_t format);
1144 int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset,
1145  unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format);
1146 int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset,
1147  const snd_pcm_channel_area_t *src_channel, snd_pcm_uframes_t src_offset,
1148  unsigned int samples, snd_pcm_format_t format);
1149 int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset,
1150  const snd_pcm_channel_area_t *src_channels, snd_pcm_uframes_t src_offset,
1151  unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format);
1152 int snd_pcm_areas_copy_wrap(const snd_pcm_channel_area_t *dst_channels,
1153  snd_pcm_uframes_t dst_offset,
1154  const snd_pcm_uframes_t dst_size,
1155  const snd_pcm_channel_area_t *src_channels,
1156  snd_pcm_uframes_t src_offset,
1157  const snd_pcm_uframes_t src_size,
1158  const unsigned int channels,
1159  snd_pcm_uframes_t frames,
1160  const snd_pcm_format_t format);
1161 
1172 typedef enum _snd_pcm_hook_type {
1173  SND_PCM_HOOK_TYPE_HW_PARAMS = 0,
1174  SND_PCM_HOOK_TYPE_HW_FREE,
1175  SND_PCM_HOOK_TYPE_CLOSE,
1176  SND_PCM_HOOK_TYPE_LAST = SND_PCM_HOOK_TYPE_CLOSE
1178 
1180 typedef struct _snd_pcm_hook snd_pcm_hook_t;
1182 typedef int (*snd_pcm_hook_func_t)(snd_pcm_hook_t *hook);
1185 void snd_pcm_hook_set_private(snd_pcm_hook_t *hook, void *private_data);
1186 int snd_pcm_hook_add(snd_pcm_hook_t **hookp, snd_pcm_t *pcm,
1187  snd_pcm_hook_type_t type,
1188  snd_pcm_hook_func_t func, void *private_data);
1190 
1201 typedef struct _snd_pcm_scope_ops {
1205  int (*enable)(snd_pcm_scope_t *scope);
1209  void (*disable)(snd_pcm_scope_t *scope);
1213  void (*start)(snd_pcm_scope_t *scope);
1217  void (*stop)(snd_pcm_scope_t *scope);
1221  void (*update)(snd_pcm_scope_t *scope);
1225  void (*reset)(snd_pcm_scope_t *scope);
1229  void (*close)(snd_pcm_scope_t *scope);
1231 
1232 snd_pcm_uframes_t snd_pcm_meter_get_bufsize(snd_pcm_t *pcm);
1233 unsigned int snd_pcm_meter_get_channels(snd_pcm_t *pcm);
1234 unsigned int snd_pcm_meter_get_rate(snd_pcm_t *pcm);
1235 snd_pcm_uframes_t snd_pcm_meter_get_now(snd_pcm_t *pcm);
1236 snd_pcm_uframes_t snd_pcm_meter_get_boundary(snd_pcm_t *pcm);
1238 snd_pcm_scope_t *snd_pcm_meter_search_scope(snd_pcm_t *pcm, const char *name);
1241  const snd_pcm_scope_ops_t *val);
1242 void snd_pcm_scope_set_name(snd_pcm_scope_t *scope, const char *val);
1243 const char *snd_pcm_scope_get_name(snd_pcm_scope_t *scope);
1245 void snd_pcm_scope_set_callback_private(snd_pcm_scope_t *scope, void *val);
1246 int snd_pcm_scope_s16_open(snd_pcm_t *pcm, const char *name,
1247  snd_pcm_scope_t **scopep);
1249  unsigned int channel);
1250 
1261 typedef enum _snd_spcm_latency {
1272 
1274 typedef enum _snd_spcm_xrun_type {
1280 
1282 typedef enum _snd_spcm_duplex_type {
1288 
1289 int snd_spcm_init(snd_pcm_t *pcm,
1290  unsigned int rate,
1291  unsigned int channels,
1292  snd_pcm_format_t format,
1293  snd_pcm_subformat_t subformat,
1294  snd_spcm_latency_t latency,
1295  snd_pcm_access_t _access,
1296  snd_spcm_xrun_type_t xrun_type);
1297 
1298 int snd_spcm_init_duplex(snd_pcm_t *playback_pcm,
1299  snd_pcm_t *capture_pcm,
1300  unsigned int rate,
1301  unsigned int channels,
1302  snd_pcm_format_t format,
1303  snd_pcm_subformat_t subformat,
1304  snd_spcm_latency_t latency,
1305  snd_pcm_access_t _access,
1306  snd_spcm_xrun_type_t xrun_type,
1307  snd_spcm_duplex_type_t duplex_type);
1308 
1310  unsigned int *rate,
1311  snd_pcm_uframes_t *buffer_size,
1312  snd_pcm_uframes_t *period_size);
1313 
1323 /* Deprecated functions, for compatibility */
1324 const char *snd_pcm_start_mode_name(snd_pcm_start_t mode) __attribute__((deprecated));
1325 const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode) __attribute__((deprecated));
1326 int snd_pcm_sw_params_set_start_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_start_t val) __attribute__((deprecated));
1327 snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
1328 int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_xrun_t val) __attribute__((deprecated));
1329 snd_pcm_xrun_t snd_pcm_sw_params_get_xrun_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
1330 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_SW_PARAMS_API)
1331 int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val) __attribute__((deprecated));
1332 int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val) __attribute__((deprecated));
1333 int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int val) __attribute__((deprecated));
1334 int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params, unsigned int *val) __attribute__((deprecated));
1335 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
1336 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
1337 int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1338 int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1339 int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1340 int snd_pcm_hw_params_test_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) __attribute__((deprecated));
1341 int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) __attribute__((deprecated));
1342 int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1343 int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1344 int snd_pcm_hw_params_set_tick_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) __attribute__((deprecated));
1345 int snd_pcm_hw_params_set_tick_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1346 int snd_pcm_hw_params_set_tick_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1347 int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1348 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
1349 
1352 #ifdef __cplusplus
1353 }
1354 #endif
1355 
1356 #endif /* __ALSA_PCM_H */