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 
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 {
204  /* G.723 (ADPCM) 24 kbit/s, 8 samples in 3 bytes */
205  SND_PCM_FORMAT_G723_24,
206  /* G.723 (ADPCM) 24 kbit/s, 1 sample in 1 byte */
207  SND_PCM_FORMAT_G723_24_1B,
208  /* G.723 (ADPCM) 40 kbit/s, 8 samples in 3 bytes */
209  SND_PCM_FORMAT_G723_40,
210  /* G.723 (ADPCM) 40 kbit/s, 1 sample in 1 byte */
211  SND_PCM_FORMAT_G723_40_1B,
212  /* Direct Stream Digital (DSD) in 1-byte samples (x8) */
213  SND_PCM_FORMAT_DSD_U8,
214  /* Direct Stream Digital (DSD) in 2-byte samples (x16) */
215  SND_PCM_FORMAT_DSD_U16_LE,
216  /* Direct Stream Digital (DSD) in 4-byte samples (x32) */
217  SND_PCM_FORMAT_DSD_U32_LE,
218  /* Direct Stream Digital (DSD) in 2-byte samples (x16) */
219  SND_PCM_FORMAT_DSD_U16_BE,
220  /* Direct Stream Digital (DSD) in 4-byte samples (x32) */
221  SND_PCM_FORMAT_DSD_U32_BE,
222  SND_PCM_FORMAT_LAST = SND_PCM_FORMAT_DSD_U32_BE,
223 
224 #if __BYTE_ORDER == __LITTLE_ENDIAN
225 
243 #elif __BYTE_ORDER == __BIG_ENDIAN
244 
262 #else
263 #error "Unknown endian"
264 #endif
266 
268 typedef enum _snd_pcm_subformat {
271  SND_PCM_SUBFORMAT_LAST = SND_PCM_SUBFORMAT_STD
273 
275 typedef enum _snd_pcm_state {
294  SND_PCM_STATE_LAST = SND_PCM_STATE_DISCONNECTED
296 
298 typedef enum _snd_pcm_start {
303  SND_PCM_START_LAST = SND_PCM_START_EXPLICIT
305 
307 typedef enum _snd_pcm_xrun {
312  SND_PCM_XRUN_LAST = SND_PCM_XRUN_STOP
314 
316 typedef enum _snd_pcm_tstamp {
325  SND_PCM_TSTAMP_LAST = SND_PCM_TSTAMP_ENABLE
327 
328 typedef enum _snd_pcm_tstamp_type {
332  SND_PCM_TSTAMP_TYPE_LAST = SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW,
334 
335 typedef struct _snd_pcm_audio_tstamp_config {
336  /* 5 of max 16 bits used */
337  unsigned int type_requested:4;
338  unsigned int report_delay:1; /* add total delay to A/D or D/A */
340 
341 typedef struct _snd_pcm_audio_tstamp_report {
342  /* 6 of max 16 bits used for bit-fields */
343 
344  /* for backwards compatibility */
345  unsigned int valid:1;
346 
347  /* actual type if hardware could not support requested timestamp */
348  unsigned int actual_type:4;
349 
350  /* accuracy represented in ns units */
351  unsigned int accuracy_report:1; /* 0 if accuracy unknown, 1 if accuracy field is valid */
352  unsigned int accuracy; /* up to 4.29s, will be packed in separate field */
354 
356 typedef unsigned long snd_pcm_uframes_t;
358 typedef long snd_pcm_sframes_t;
359 
361 #define SND_PCM_NONBLOCK 0x00000001
362 
363 #define SND_PCM_ASYNC 0x00000002
364 
365 #define SND_PCM_ABORT 0x00008000
366 
367 #define SND_PCM_NO_AUTO_RESAMPLE 0x00010000
368 
369 #define SND_PCM_NO_AUTO_CHANNELS 0x00020000
370 
371 #define SND_PCM_NO_AUTO_FORMAT 0x00040000
372 
373 #define SND_PCM_NO_SOFTVOL 0x00080000
374 
376 typedef struct _snd_pcm snd_pcm_t;
377 
443  SND_PCM_TYPE_LAST = SND_PCM_TYPE_MMAP_EMUL
444 };
445 
448 
450 typedef struct _snd_pcm_channel_area {
452  void *addr;
454  unsigned int first;
456  unsigned int step;
458 
460 typedef union _snd_pcm_sync_id {
462  unsigned char id[16];
464  unsigned short id16[8];
466  unsigned int id32[4];
468 
470 typedef struct _snd_pcm_scope snd_pcm_scope_t;
471 
472 int snd_pcm_open(snd_pcm_t **pcm, const char *name,
473  snd_pcm_stream_t stream, int mode);
474 int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name,
475  snd_pcm_stream_t stream, int mode,
476  snd_config_t *lconf);
478  const char *name, const char *orig_name,
479  snd_pcm_stream_t stream, int mode);
480 
481 int snd_pcm_close(snd_pcm_t *pcm);
482 const char *snd_pcm_name(snd_pcm_t *pcm);
483 snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm);
486 int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
487 int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
488 int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
489 static __inline__ int snd_pcm_abort(snd_pcm_t *pcm) { return snd_pcm_nonblock(pcm, 2); }
491  snd_async_callback_t callback, void *private_data);
493 int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
496 int snd_pcm_hw_free(snd_pcm_t *pcm);
499 int snd_pcm_prepare(snd_pcm_t *pcm);
500 int snd_pcm_reset(snd_pcm_t *pcm);
501 int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status);
502 int snd_pcm_start(snd_pcm_t *pcm);
503 int snd_pcm_drop(snd_pcm_t *pcm);
504 int snd_pcm_drain(snd_pcm_t *pcm);
505 int snd_pcm_pause(snd_pcm_t *pcm, int enable);
507 int snd_pcm_hwsync(snd_pcm_t *pcm);
508 int snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
509 int snd_pcm_resume(snd_pcm_t *pcm);
510 int snd_pcm_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail, snd_htimestamp_t *tstamp);
511 snd_pcm_sframes_t snd_pcm_avail(snd_pcm_t *pcm);
512 snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm);
513 int snd_pcm_avail_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *availp, snd_pcm_sframes_t *delayp);
514 snd_pcm_sframes_t snd_pcm_rewindable(snd_pcm_t *pcm);
515 snd_pcm_sframes_t snd_pcm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
516 snd_pcm_sframes_t snd_pcm_forwardable(snd_pcm_t *pcm);
517 snd_pcm_sframes_t snd_pcm_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
518 snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
519 snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
520 snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
521 snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
522 int snd_pcm_wait(snd_pcm_t *pcm, int timeout);
523 
524 int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2);
525 int snd_pcm_unlink(snd_pcm_t *pcm);
526 
528 #define SND_CHMAP_API_VERSION ((1 << 16) | (0 << 8) | 1)
529 
537 };
538 
578  SND_CHMAP_LAST = SND_CHMAP_BRC,
579 };
580 
582 #define SND_CHMAP_POSITION_MASK 0xffff
583 
585 #define SND_CHMAP_PHASE_INVERSE (0x01 << 16)
586 
587 #define SND_CHMAP_DRIVER_SPEC (0x02 << 16)
588 
590 typedef struct snd_pcm_chmap {
591  unsigned int channels;
592  unsigned int pos[0];
594 
596 typedef struct snd_pcm_chmap_query {
600 
601 
604  int subdev,
605  snd_pcm_stream_t stream);
608 int snd_pcm_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map);
609 
610 const char *snd_pcm_chmap_type_name(enum snd_pcm_chmap_type val);
611 const char *snd_pcm_chmap_name(enum snd_pcm_chmap_position val);
612 const char *snd_pcm_chmap_long_name(enum snd_pcm_chmap_position val);
613 int snd_pcm_chmap_print(const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
614 unsigned int snd_pcm_chmap_from_string(const char *str);
616 
617 //int snd_pcm_mixer_element(snd_pcm_t *pcm, snd_mixer_t *mixer, snd_mixer_elem_t **elem);
618 
619 /*
620  * application helpers - these functions are implemented on top
621  * of the basic API
622  */
623 
624 int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent);
626  snd_pcm_format_t format,
627  snd_pcm_access_t access,
628  unsigned int channels,
629  unsigned int rate,
630  int soft_resample,
631  unsigned int latency);
633  snd_pcm_uframes_t *buffer_size,
634  snd_pcm_uframes_t *period_size);
635 
645 size_t snd_pcm_info_sizeof(void);
650 #define snd_pcm_info_alloca(ptr) __snd_alloca(ptr, snd_pcm_info)
653 void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src);
654 unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj);
655 unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj);
657 int snd_pcm_info_get_card(const snd_pcm_info_t *obj);
658 const char *snd_pcm_info_get_id(const snd_pcm_info_t *obj);
659 const char *snd_pcm_info_get_name(const snd_pcm_info_t *obj);
660 const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj);
663 unsigned int snd_pcm_info_get_subdevices_count(const snd_pcm_info_t *obj);
664 unsigned int snd_pcm_info_get_subdevices_avail(const snd_pcm_info_t *obj);
666 void snd_pcm_info_set_device(snd_pcm_info_t *obj, unsigned int val);
667 void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val);
669 
680 
693 int snd_pcm_hw_params_supports_audio_wallclock_ts(const snd_pcm_hw_params_t *params); /* deprecated, use audio_ts_type */
696  unsigned int *rate_num,
697  unsigned int *rate_den);
700 
701 #if 0
702 typedef struct _snd_pcm_hw_strategy snd_pcm_hw_strategy_t;
703 
704 /* choices need to be sorted on ascending badness */
705 typedef struct _snd_pcm_hw_strategy_simple_choices_list {
706  unsigned int value;
707  unsigned int badness;
708 } snd_pcm_hw_strategy_simple_choices_list_t;
709 
710 int snd_pcm_hw_params_strategy(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
711  const snd_pcm_hw_strategy_t *strategy,
712  unsigned int badness_min,
713  unsigned int badness_max);
714 
715 void snd_pcm_hw_strategy_free(snd_pcm_hw_strategy_t *strategy);
716 int snd_pcm_hw_strategy_simple(snd_pcm_hw_strategy_t **strategyp,
717  unsigned int badness_min,
718  unsigned int badness_max);
719 int snd_pcm_hw_params_try_explain_failure(snd_pcm_t *pcm,
720  snd_pcm_hw_params_t *fail,
721  snd_pcm_hw_params_t *success,
722  unsigned int depth,
723  snd_output_t *out);
724 
725 #endif
726 
727 size_t snd_pcm_hw_params_sizeof(void);
732 #define snd_pcm_hw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_hw_params)
736 
737 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
738 
746 
754 
762 
763 int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params, unsigned int *val);
764 int snd_pcm_hw_params_get_channels_min(const snd_pcm_hw_params_t *params, unsigned int *val);
765 int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *params, unsigned int *val);
766 int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
767 int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
768 int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
769 int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
770 int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max);
771 int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
772 int snd_pcm_hw_params_set_channels_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
773 int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
774 
775 int snd_pcm_hw_params_get_rate(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
776 int snd_pcm_hw_params_get_rate_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
777 int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
778 int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
779 int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
780 int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
781 int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
782 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);
783 int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
784 int snd_pcm_hw_params_set_rate_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
785 int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
786 int snd_pcm_hw_params_set_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
787 int snd_pcm_hw_params_get_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
788 int snd_pcm_hw_params_set_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
789 int snd_pcm_hw_params_get_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
790 int snd_pcm_hw_params_set_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
791 int snd_pcm_hw_params_get_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
792 
793 int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
794 int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
795 int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
796 int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
797 int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
798 int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
799 int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
800 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);
801 int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
802 int snd_pcm_hw_params_set_period_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
803 int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
804 
805 int snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
806 int snd_pcm_hw_params_get_period_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
807 int snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
808 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);
809 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);
810 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);
811 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);
812 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);
813 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);
814 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);
815 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);
817 
818 int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
819 int snd_pcm_hw_params_get_periods_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
820 int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
821 int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
822 int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
823 int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
824 int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
825 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);
826 int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
827 int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
828 int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
830 
831 int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
832 int snd_pcm_hw_params_get_buffer_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
833 int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
834 int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
835 int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
836 int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
837 int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
838 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);
839 int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
840 int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
841 int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
842 
843 int snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
844 int snd_pcm_hw_params_get_buffer_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
845 int snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
846 int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
847 int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
848 int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
849 int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
850 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);
851 int snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
852 int snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
853 int snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
854 
855 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
856 
857 int snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
858 
868 size_t snd_pcm_sw_params_sizeof(void);
873 #define snd_pcm_sw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_sw_params)
877 int snd_pcm_sw_params_get_boundary(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
878 
879 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_SW_PARAMS_API)
880 
885 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
886 int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
888 int snd_pcm_sw_params_get_period_event(const snd_pcm_sw_params_t *params, int *val);
889 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
890 int snd_pcm_sw_params_get_start_threshold(const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val);
891 int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
892 int snd_pcm_sw_params_get_stop_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
893 int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
894 int snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
895 int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
896 int snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
897 
898 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
899 
902 /* include old API */
903 #ifndef ALSA_LIBRARY_BUILD
904 #if defined(ALSA_PCM_OLD_HW_PARAMS_API) || defined(ALSA_PCM_OLD_SW_PARAMS_API)
905 #include "pcm_old.h"
906 #endif
907 #endif
908 
916 size_t snd_pcm_access_mask_sizeof(void);
921 #define snd_pcm_access_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_access_mask)
931 
941 size_t snd_pcm_format_mask_sizeof(void);
946 #define snd_pcm_format_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_format_mask)
956 
966 size_t snd_pcm_subformat_mask_sizeof(void);
971 #define snd_pcm_subformat_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_subformat_mask)
981 
991 size_t snd_pcm_status_sizeof(void);
996 #define snd_pcm_status_alloca(ptr) __snd_alloca(ptr, snd_pcm_status)
1008  snd_pcm_audio_tstamp_report_t *audio_tstamp_report);
1010  snd_pcm_audio_tstamp_config_t *audio_tstamp_config);
1011 
1012 static inline void snd_pcm_pack_audio_tstamp_config(unsigned int *data,
1014 {
1015  *data = config->report_delay;
1016  *data <<= 4;
1017  *data |= config->type_requested;
1018 }
1019 
1020 static inline void snd_pcm_unpack_audio_tstamp_report(unsigned int data, unsigned int accuracy,
1022 {
1023  data >>= 16;
1024  report->valid = data & 1;
1025  report->actual_type = (data >> 1) & 0xF;
1026  report->accuracy_report = (data >> 5) & 1;
1027  report->accuracy = accuracy;
1028 }
1029 
1030 snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj);
1031 snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj);
1032 snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj);
1033 snd_pcm_uframes_t snd_pcm_status_get_overrange(const snd_pcm_status_t *obj);
1034 
1044 const char *snd_pcm_type_name(snd_pcm_type_t type);
1045 const char *snd_pcm_stream_name(const snd_pcm_stream_t stream);
1046 const char *snd_pcm_access_name(const snd_pcm_access_t _access);
1047 const char *snd_pcm_format_name(const snd_pcm_format_t format);
1048 const char *snd_pcm_format_description(const snd_pcm_format_t format);
1049 const char *snd_pcm_subformat_name(const snd_pcm_subformat_t subformat);
1050 const char *snd_pcm_subformat_description(const snd_pcm_subformat_t subformat);
1051 snd_pcm_format_t snd_pcm_format_value(const char* name);
1052 const char *snd_pcm_tstamp_mode_name(const snd_pcm_tstamp_t mode);
1053 const char *snd_pcm_state_name(const snd_pcm_state_t state);
1054 
1064 int snd_pcm_dump(snd_pcm_t *pcm, snd_output_t *out);
1067 int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out);
1071 
1081 int snd_pcm_mmap_begin(snd_pcm_t *pcm,
1082  const snd_pcm_channel_area_t **areas,
1083  snd_pcm_uframes_t *offset,
1084  snd_pcm_uframes_t *frames);
1085 snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm,
1086  snd_pcm_uframes_t offset,
1087  snd_pcm_uframes_t frames);
1088 snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
1089 snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
1090 snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
1091 snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
1092 
1109 int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */
1110 int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */
1111 snd_pcm_format_t snd_pcm_build_linear_format(int width, int pwidth, int unsignd, int big_endian);
1112 ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
1117 int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int samples);
1118 
1119 snd_pcm_sframes_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes);
1120 ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *pcm, snd_pcm_sframes_t frames);
1121 long snd_pcm_bytes_to_samples(snd_pcm_t *pcm, ssize_t bytes);
1122 ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, long samples);
1123 
1124 int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset,
1125  unsigned int samples, snd_pcm_format_t format);
1126 int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset,
1127  unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format);
1128 int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset,
1129  const snd_pcm_channel_area_t *src_channel, snd_pcm_uframes_t src_offset,
1130  unsigned int samples, snd_pcm_format_t format);
1131 int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset,
1132  const snd_pcm_channel_area_t *src_channels, snd_pcm_uframes_t src_offset,
1133  unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format);
1134 
1145 typedef enum _snd_pcm_hook_type {
1146  SND_PCM_HOOK_TYPE_HW_PARAMS = 0,
1147  SND_PCM_HOOK_TYPE_HW_FREE,
1148  SND_PCM_HOOK_TYPE_CLOSE,
1149  SND_PCM_HOOK_TYPE_LAST = SND_PCM_HOOK_TYPE_CLOSE
1151 
1153 typedef struct _snd_pcm_hook snd_pcm_hook_t;
1155 typedef int (*snd_pcm_hook_func_t)(snd_pcm_hook_t *hook);
1158 void snd_pcm_hook_set_private(snd_pcm_hook_t *hook, void *private_data);
1159 int snd_pcm_hook_add(snd_pcm_hook_t **hookp, snd_pcm_t *pcm,
1160  snd_pcm_hook_type_t type,
1161  snd_pcm_hook_func_t func, void *private_data);
1163 
1174 typedef struct _snd_pcm_scope_ops {
1178  int (*enable)(snd_pcm_scope_t *scope);
1182  void (*disable)(snd_pcm_scope_t *scope);
1186  void (*start)(snd_pcm_scope_t *scope);
1190  void (*stop)(snd_pcm_scope_t *scope);
1194  void (*update)(snd_pcm_scope_t *scope);
1198  void (*reset)(snd_pcm_scope_t *scope);
1202  void (*close)(snd_pcm_scope_t *scope);
1204 
1205 snd_pcm_uframes_t snd_pcm_meter_get_bufsize(snd_pcm_t *pcm);
1206 unsigned int snd_pcm_meter_get_channels(snd_pcm_t *pcm);
1207 unsigned int snd_pcm_meter_get_rate(snd_pcm_t *pcm);
1208 snd_pcm_uframes_t snd_pcm_meter_get_now(snd_pcm_t *pcm);
1209 snd_pcm_uframes_t snd_pcm_meter_get_boundary(snd_pcm_t *pcm);
1211 snd_pcm_scope_t *snd_pcm_meter_search_scope(snd_pcm_t *pcm, const char *name);
1214  const snd_pcm_scope_ops_t *val);
1215 void snd_pcm_scope_set_name(snd_pcm_scope_t *scope, const char *val);
1216 const char *snd_pcm_scope_get_name(snd_pcm_scope_t *scope);
1218 void snd_pcm_scope_set_callback_private(snd_pcm_scope_t *scope, void *val);
1219 int snd_pcm_scope_s16_open(snd_pcm_t *pcm, const char *name,
1220  snd_pcm_scope_t **scopep);
1222  unsigned int channel);
1223 
1234 typedef enum _snd_spcm_latency {
1245 
1247 typedef enum _snd_spcm_xrun_type {
1253 
1255 typedef enum _snd_spcm_duplex_type {
1261 
1262 int snd_spcm_init(snd_pcm_t *pcm,
1263  unsigned int rate,
1264  unsigned int channels,
1265  snd_pcm_format_t format,
1266  snd_pcm_subformat_t subformat,
1267  snd_spcm_latency_t latency,
1268  snd_pcm_access_t _access,
1269  snd_spcm_xrun_type_t xrun_type);
1270 
1271 int snd_spcm_init_duplex(snd_pcm_t *playback_pcm,
1272  snd_pcm_t *capture_pcm,
1273  unsigned int rate,
1274  unsigned int channels,
1275  snd_pcm_format_t format,
1276  snd_pcm_subformat_t subformat,
1277  snd_spcm_latency_t latency,
1278  snd_pcm_access_t _access,
1279  snd_spcm_xrun_type_t xrun_type,
1280  snd_spcm_duplex_type_t duplex_type);
1281 
1283  unsigned int *rate,
1284  snd_pcm_uframes_t *buffer_size,
1285  snd_pcm_uframes_t *period_size);
1286 
1296 /* Deprecated functions, for compatibility */
1297 const char *snd_pcm_start_mode_name(snd_pcm_start_t mode) __attribute__((deprecated));
1298 const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode) __attribute__((deprecated));
1299 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));
1300 snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
1301 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));
1302 snd_pcm_xrun_t snd_pcm_sw_params_get_xrun_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
1303 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_SW_PARAMS_API)
1304 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));
1305 int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val) __attribute__((deprecated));
1306 int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int val) __attribute__((deprecated));
1307 int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params, unsigned int *val) __attribute__((deprecated));
1308 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
1309 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
1310 int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1311 int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1312 int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1313 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));
1314 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));
1315 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));
1316 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));
1317 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));
1318 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));
1319 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));
1320 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));
1321 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
1322 
1325 #ifdef __cplusplus
1326 }
1327 #endif
1328 
1329 #endif /* __ALSA_PCM_H */