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., 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
33 extern "C" {
34 #endif
35 
43 #define SND_PCM_DLSYM_VERSION _dlsym_pcm_001
44 
46 typedef struct _snd_pcm_info snd_pcm_info_t;
47 
62 typedef struct _snd_pcm_hw_params snd_pcm_hw_params_t;
63 
65 typedef struct _snd_pcm_sw_params snd_pcm_sw_params_t;
67  typedef struct _snd_pcm_status snd_pcm_status_t;
69 typedef struct _snd_pcm_access_mask snd_pcm_access_mask_t;
71 typedef struct _snd_pcm_format_mask snd_pcm_format_mask_t;
73 typedef struct _snd_pcm_subformat_mask snd_pcm_subformat_mask_t;
74 
76 typedef enum _snd_pcm_class {
86  SND_PCM_CLASS_LAST = SND_PCM_CLASS_DIGITIZER
88 
90 typedef enum _snd_pcm_subclass {
95  SND_PCM_SUBCLASS_LAST = SND_PCM_SUBCLASS_MULTI_MIX
97 
99 typedef enum _snd_pcm_stream {
104  SND_PCM_STREAM_LAST = SND_PCM_STREAM_CAPTURE
106 
108 typedef enum _snd_pcm_access {
119  SND_PCM_ACCESS_LAST = SND_PCM_ACCESS_RW_NONINTERLEAVED
121 
123 typedef enum _snd_pcm_format {
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 
241 #elif __BYTE_ORDER == __BIG_ENDIAN
242 
260 #else
261 #error "Unknown endian"
262 #endif
264 
266 typedef enum _snd_pcm_subformat {
269  SND_PCM_SUBFORMAT_LAST = SND_PCM_SUBFORMAT_STD
271 
273 typedef enum _snd_pcm_state {
292  SND_PCM_STATE_LAST = SND_PCM_STATE_DISCONNECTED
294 
296 typedef enum _snd_pcm_start {
301  SND_PCM_START_LAST = SND_PCM_START_EXPLICIT
303 
305 typedef enum _snd_pcm_xrun {
310  SND_PCM_XRUN_LAST = SND_PCM_XRUN_STOP
312 
314 typedef enum _snd_pcm_tstamp {
323  SND_PCM_TSTAMP_LAST = SND_PCM_TSTAMP_ENABLE
325 
326 typedef enum _snd_pcm_tstamp_type {
330  SND_PCM_TSTAMP_TYPE_LAST = SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW,
332 
333 typedef 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 */
338 
339 typedef 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 */
352 
354 typedef unsigned long snd_pcm_uframes_t;
356 typedef long snd_pcm_sframes_t;
357 
359 #define SND_PCM_NONBLOCK 0x00000001
360 
361 #define SND_PCM_ASYNC 0x00000002
362 
363 #define SND_PCM_ABORT 0x00008000
364 
365 #define SND_PCM_NO_AUTO_RESAMPLE 0x00010000
366 
367 #define SND_PCM_NO_AUTO_CHANNELS 0x00020000
368 
369 #define SND_PCM_NO_AUTO_FORMAT 0x00040000
370 
371 #define SND_PCM_NO_SOFTVOL 0x00080000
372 
374 typedef struct _snd_pcm snd_pcm_t;
375 
441  SND_PCM_TYPE_LAST = SND_PCM_TYPE_MMAP_EMUL
442 };
443 
446 
448 typedef struct _snd_pcm_channel_area {
450  void *addr;
452  unsigned int first;
454  unsigned int step;
456 
458 typedef union _snd_pcm_sync_id {
460  unsigned char id[16];
462  unsigned short id16[8];
464  unsigned int id32[4];
466 
468 typedef struct _snd_pcm_scope snd_pcm_scope_t;
469 
470 int snd_pcm_open(snd_pcm_t **pcm, const char *name,
471  snd_pcm_stream_t stream, int mode);
472 int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name,
473  snd_pcm_stream_t stream, int mode,
474  snd_config_t *lconf);
476  const char *name, const char *orig_name,
477  snd_pcm_stream_t stream, int mode);
478 
479 int snd_pcm_close(snd_pcm_t *pcm);
480 const char *snd_pcm_name(snd_pcm_t *pcm);
481 snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm);
484 int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
485 int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
486 int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
487 static __inline__ int snd_pcm_abort(snd_pcm_t *pcm) { return snd_pcm_nonblock(pcm, 2); }
489  snd_async_callback_t callback, void *private_data);
491 int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
494 int snd_pcm_hw_free(snd_pcm_t *pcm);
497 int snd_pcm_prepare(snd_pcm_t *pcm);
498 int snd_pcm_reset(snd_pcm_t *pcm);
499 int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status);
500 int snd_pcm_start(snd_pcm_t *pcm);
501 int snd_pcm_drop(snd_pcm_t *pcm);
502 int snd_pcm_drain(snd_pcm_t *pcm);
503 int snd_pcm_pause(snd_pcm_t *pcm, int enable);
505 int snd_pcm_hwsync(snd_pcm_t *pcm);
506 int snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
507 int snd_pcm_resume(snd_pcm_t *pcm);
508 int snd_pcm_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail, snd_htimestamp_t *tstamp);
509 snd_pcm_sframes_t snd_pcm_avail(snd_pcm_t *pcm);
510 snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm);
511 int snd_pcm_avail_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *availp, snd_pcm_sframes_t *delayp);
512 snd_pcm_sframes_t snd_pcm_rewindable(snd_pcm_t *pcm);
513 snd_pcm_sframes_t snd_pcm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
514 snd_pcm_sframes_t snd_pcm_forwardable(snd_pcm_t *pcm);
515 snd_pcm_sframes_t snd_pcm_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
516 snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
517 snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
518 snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
519 snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
520 int snd_pcm_wait(snd_pcm_t *pcm, int timeout);
521 
522 int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2);
523 int snd_pcm_unlink(snd_pcm_t *pcm);
524 
526 #define SND_CHMAP_API_VERSION ((1 << 16) | (0 << 8) | 1)
527 
535 };
536 
576  SND_CHMAP_LAST = SND_CHMAP_BRC,
577 };
578 
580 #define SND_CHMAP_POSITION_MASK 0xffff
581 
583 #define SND_CHMAP_PHASE_INVERSE (0x01 << 16)
584 
585 #define SND_CHMAP_DRIVER_SPEC (0x02 << 16)
586 
588 typedef struct snd_pcm_chmap {
589  unsigned int channels;
590  unsigned int pos[0];
592 
594 typedef struct snd_pcm_chmap_query {
598 
599 
602  int subdev,
603  snd_pcm_stream_t stream);
606 int snd_pcm_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map);
607 
608 const char *snd_pcm_chmap_type_name(enum snd_pcm_chmap_type val);
609 const char *snd_pcm_chmap_name(enum snd_pcm_chmap_position val);
610 const char *snd_pcm_chmap_long_name(enum snd_pcm_chmap_position val);
611 int snd_pcm_chmap_print(const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
612 unsigned int snd_pcm_chmap_from_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 
622 int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent);
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);
631  snd_pcm_uframes_t *buffer_size,
632  snd_pcm_uframes_t *period_size);
633 
643 size_t snd_pcm_info_sizeof(void);
648 #define snd_pcm_info_alloca(ptr) __snd_alloca(ptr, snd_pcm_info)
651 void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src);
652 unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj);
653 unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj);
655 int snd_pcm_info_get_card(const snd_pcm_info_t *obj);
656 const char *snd_pcm_info_get_id(const snd_pcm_info_t *obj);
657 const char *snd_pcm_info_get_name(const snd_pcm_info_t *obj);
658 const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj);
661 unsigned int snd_pcm_info_get_subdevices_count(const snd_pcm_info_t *obj);
662 unsigned int snd_pcm_info_get_subdevices_avail(const snd_pcm_info_t *obj);
664 void snd_pcm_info_set_device(snd_pcm_info_t *obj, unsigned int val);
665 void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val);
667 
678 
691 int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params); /* deprecated, use audio_ts_type */
694  unsigned int *rate_num,
695  unsigned int *rate_den);
698 
699 #if 0
700 typedef struct _snd_pcm_hw_strategy snd_pcm_hw_strategy_t;
701 
702 /* choices need to be sorted on ascending badness */
703 typedef 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 
708 int 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 
713 void snd_pcm_hw_strategy_free(snd_pcm_hw_strategy_t *strategy);
714 int snd_pcm_hw_strategy_simple(snd_pcm_hw_strategy_t **strategyp,
715  unsigned int badness_min,
716  unsigned int badness_max);
717 int 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 
725 size_t snd_pcm_hw_params_sizeof(void);
730 #define snd_pcm_hw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_hw_params)
734 
735 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
736 
744 
752 
760 
761 int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params, unsigned int *val);
762 int snd_pcm_hw_params_get_channels_min(const snd_pcm_hw_params_t *params, unsigned int *val);
763 int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *params, unsigned int *val);
764 int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
765 int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
766 int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
767 int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
768 int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max);
769 int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
770 int snd_pcm_hw_params_set_channels_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
771 int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
772 
773 int snd_pcm_hw_params_get_rate(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
774 int snd_pcm_hw_params_get_rate_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
775 int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
776 int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
777 int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
778 int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
779 int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
780 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);
781 int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
782 int snd_pcm_hw_params_set_rate_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
783 int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
784 int snd_pcm_hw_params_set_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
785 int snd_pcm_hw_params_get_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
786 int snd_pcm_hw_params_set_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
787 int snd_pcm_hw_params_get_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
788 int snd_pcm_hw_params_set_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
789 int snd_pcm_hw_params_get_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
790 
791 int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
792 int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
793 int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
794 int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
795 int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
796 int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
797 int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
798 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);
799 int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
800 int snd_pcm_hw_params_set_period_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
801 int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
802 
803 int snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
804 int snd_pcm_hw_params_get_period_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
805 int snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
806 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);
807 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);
808 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);
809 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);
810 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);
811 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);
812 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);
813 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);
815 
816 int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
817 int snd_pcm_hw_params_get_periods_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
818 int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
819 int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
820 int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
821 int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
822 int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
823 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);
824 int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
825 int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
826 int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
828 
829 int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
830 int snd_pcm_hw_params_get_buffer_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
831 int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
832 int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
833 int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
834 int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
835 int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
836 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);
837 int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
838 int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
839 int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
840 
841 int snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
842 int snd_pcm_hw_params_get_buffer_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
843 int snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
844 int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
845 int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
846 int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
847 int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
848 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);
849 int snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
850 int snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
851 int 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 
855 int snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
856 
866 size_t snd_pcm_sw_params_sizeof(void);
871 #define snd_pcm_sw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_sw_params)
875 int 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 
883 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
884 int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
886 int snd_pcm_sw_params_get_period_event(const snd_pcm_sw_params_t *params, int *val);
887 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
888 int snd_pcm_sw_params_get_start_threshold(const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val);
889 int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
890 int snd_pcm_sw_params_get_stop_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
891 int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
892 int snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
893 int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
894 int 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 
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 
914 size_t snd_pcm_access_mask_sizeof(void);
919 #define snd_pcm_access_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_access_mask)
929 
939 size_t snd_pcm_format_mask_sizeof(void);
944 #define snd_pcm_format_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_format_mask)
954 
964 size_t snd_pcm_subformat_mask_sizeof(void);
969 #define snd_pcm_subformat_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_subformat_mask)
979 
989 size_t snd_pcm_status_sizeof(void);
994 #define snd_pcm_status_alloca(ptr) __snd_alloca(ptr, snd_pcm_status)
1006  snd_pcm_audio_tstamp_report_t *audio_tstamp_report);
1008  snd_pcm_audio_tstamp_config_t *audio_tstamp_config);
1009 
1010 static inline void snd_pcm_pack_audio_tstamp_config(unsigned int *data,
1012 {
1013  *data = config->report_delay;
1014  *data <<= 4;
1015  *data |= config->type_requested;
1016 }
1017 
1018 static inline void snd_pcm_unpack_audio_tstamp_report(unsigned int data, unsigned int accuracy,
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 
1028 snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj);
1029 snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj);
1030 snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj);
1031 snd_pcm_uframes_t snd_pcm_status_get_overrange(const snd_pcm_status_t *obj);
1032 
1042 const char *snd_pcm_type_name(snd_pcm_type_t type);
1043 const char *snd_pcm_stream_name(const snd_pcm_stream_t stream);
1044 const char *snd_pcm_access_name(const snd_pcm_access_t _access);
1045 const char *snd_pcm_format_name(const snd_pcm_format_t format);
1046 const char *snd_pcm_format_description(const snd_pcm_format_t format);
1047 const char *snd_pcm_subformat_name(const snd_pcm_subformat_t subformat);
1048 const char *snd_pcm_subformat_description(const snd_pcm_subformat_t subformat);
1049 snd_pcm_format_t snd_pcm_format_value(const char* name);
1050 const char *snd_pcm_tstamp_mode_name(const snd_pcm_tstamp_t mode);
1051 const char *snd_pcm_state_name(const snd_pcm_state_t state);
1052 
1062 int snd_pcm_dump(snd_pcm_t *pcm, snd_output_t *out);
1065 int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out);
1069 
1079 int 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);
1083 snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm,
1084  snd_pcm_uframes_t offset,
1085  snd_pcm_uframes_t frames);
1086 snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
1087 snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
1088 snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
1089 snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
1090 
1107 int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */
1108 int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */
1109 snd_pcm_format_t snd_pcm_build_linear_format(int width, int pwidth, int unsignd, int big_endian);
1110 ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
1111 u_int8_t snd_pcm_format_silence(snd_pcm_format_t format);
1115 int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int samples);
1116 
1117 snd_pcm_sframes_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes);
1118 ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *pcm, snd_pcm_sframes_t frames);
1119 long snd_pcm_bytes_to_samples(snd_pcm_t *pcm, ssize_t bytes);
1120 ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, long samples);
1121 
1122 int 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);
1124 int 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);
1126 int 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);
1129 int 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 
1143 typedef 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
1149 
1151 typedef struct _snd_pcm_hook snd_pcm_hook_t;
1153 typedef int (*snd_pcm_hook_func_t)(snd_pcm_hook_t *hook);
1156 void snd_pcm_hook_set_private(snd_pcm_hook_t *hook, void *private_data);
1157 int 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);
1161 
1172 typedef struct _snd_pcm_scope_ops {
1176  int (*enable)(snd_pcm_scope_t *scope);
1180  void (*disable)(snd_pcm_scope_t *scope);
1184  void (*start)(snd_pcm_scope_t *scope);
1188  void (*stop)(snd_pcm_scope_t *scope);
1192  void (*update)(snd_pcm_scope_t *scope);
1196  void (*reset)(snd_pcm_scope_t *scope);
1200  void (*close)(snd_pcm_scope_t *scope);
1202 
1203 snd_pcm_uframes_t snd_pcm_meter_get_bufsize(snd_pcm_t *pcm);
1204 unsigned int snd_pcm_meter_get_channels(snd_pcm_t *pcm);
1205 unsigned int snd_pcm_meter_get_rate(snd_pcm_t *pcm);
1206 snd_pcm_uframes_t snd_pcm_meter_get_now(snd_pcm_t *pcm);
1207 snd_pcm_uframes_t snd_pcm_meter_get_boundary(snd_pcm_t *pcm);
1209 snd_pcm_scope_t *snd_pcm_meter_search_scope(snd_pcm_t *pcm, const char *name);
1212  const snd_pcm_scope_ops_t *val);
1213 void snd_pcm_scope_set_name(snd_pcm_scope_t *scope, const char *val);
1214 const char *snd_pcm_scope_get_name(snd_pcm_scope_t *scope);
1216 void snd_pcm_scope_set_callback_private(snd_pcm_scope_t *scope, void *val);
1217 int snd_pcm_scope_s16_open(snd_pcm_t *pcm, const char *name,
1218  snd_pcm_scope_t **scopep);
1220  unsigned int channel);
1221 
1232 typedef enum _snd_spcm_latency {
1243 
1245 typedef enum _snd_spcm_xrun_type {
1251 
1253 typedef enum _snd_spcm_duplex_type {
1259 
1260 int 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 
1269 int 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 
1281  unsigned int *rate,
1282  snd_pcm_uframes_t *buffer_size,
1283  snd_pcm_uframes_t *period_size);
1284 
1294 /* Deprecated functions, for compatibility */
1295 const char *snd_pcm_start_mode_name(snd_pcm_start_t mode) __attribute__((deprecated));
1296 const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode) __attribute__((deprecated));
1297 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));
1298 snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
1299 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));
1300 snd_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)
1302 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));
1303 int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val) __attribute__((deprecated));
1304 int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int val) __attribute__((deprecated));
1305 int 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)
1308 int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1309 int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1310 int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1311 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));
1312 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));
1313 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));
1314 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));
1315 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));
1316 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));
1317 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));
1318 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));
1319 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
1320 
1323 #ifdef __cplusplus
1324 }
1325 #endif
1326 
1327 #endif /* __ALSA_PCM_H */