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 {
327  SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0,
332 
334 typedef unsigned long snd_pcm_uframes_t;
336 typedef long snd_pcm_sframes_t;
337 
339 #define SND_PCM_NONBLOCK 0x00000001
340 
341 #define SND_PCM_ASYNC 0x00000002
342 
343 #define SND_PCM_ABORT 0x00008000
344 
345 #define SND_PCM_NO_AUTO_RESAMPLE 0x00010000
346 
347 #define SND_PCM_NO_AUTO_CHANNELS 0x00020000
348 
349 #define SND_PCM_NO_AUTO_FORMAT 0x00040000
350 
351 #define SND_PCM_NO_SOFTVOL 0x00080000
352 
354 typedef struct _snd_pcm snd_pcm_t;
355 
421  SND_PCM_TYPE_LAST = SND_PCM_TYPE_MMAP_EMUL
422 };
423 
426 
428 typedef struct _snd_pcm_channel_area {
430  void *addr;
432  unsigned int first;
434  unsigned int step;
436 
438 typedef union _snd_pcm_sync_id {
440  unsigned char id[16];
442  unsigned short id16[8];
444  unsigned int id32[4];
446 
448 typedef struct _snd_pcm_scope snd_pcm_scope_t;
449 
450 int snd_pcm_open(snd_pcm_t **pcm, const char *name,
451  snd_pcm_stream_t stream, int mode);
452 int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name,
453  snd_pcm_stream_t stream, int mode,
454  snd_config_t *lconf);
456  const char *name, const char *orig_name,
457  snd_pcm_stream_t stream, int mode);
458 
459 int snd_pcm_close(snd_pcm_t *pcm);
460 const char *snd_pcm_name(snd_pcm_t *pcm);
461 snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm);
464 int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
465 int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
466 int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
467 static __inline__ int snd_pcm_abort(snd_pcm_t *pcm) { return snd_pcm_nonblock(pcm, 2); }
469  snd_async_callback_t callback, void *private_data);
471 int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
474 int snd_pcm_hw_free(snd_pcm_t *pcm);
477 int snd_pcm_prepare(snd_pcm_t *pcm);
478 int snd_pcm_reset(snd_pcm_t *pcm);
479 int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status);
480 int snd_pcm_start(snd_pcm_t *pcm);
481 int snd_pcm_drop(snd_pcm_t *pcm);
482 int snd_pcm_drain(snd_pcm_t *pcm);
483 int snd_pcm_pause(snd_pcm_t *pcm, int enable);
485 int snd_pcm_hwsync(snd_pcm_t *pcm);
486 int snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
487 int snd_pcm_resume(snd_pcm_t *pcm);
488 int snd_pcm_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail, snd_htimestamp_t *tstamp);
489 snd_pcm_sframes_t snd_pcm_avail(snd_pcm_t *pcm);
490 snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm);
491 int snd_pcm_avail_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *availp, snd_pcm_sframes_t *delayp);
492 snd_pcm_sframes_t snd_pcm_rewindable(snd_pcm_t *pcm);
493 snd_pcm_sframes_t snd_pcm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
494 snd_pcm_sframes_t snd_pcm_forwardable(snd_pcm_t *pcm);
495 snd_pcm_sframes_t snd_pcm_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames);
496 snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
497 snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
498 snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
499 snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
500 int snd_pcm_wait(snd_pcm_t *pcm, int timeout);
501 
502 int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2);
503 int snd_pcm_unlink(snd_pcm_t *pcm);
504 
506 #define SND_CHMAP_API_VERSION ((1 << 16) | (0 << 8) | 1)
507 
510  SND_CHMAP_TYPE_NONE = 0,
515 };
516 
556  SND_CHMAP_LAST = SND_CHMAP_BRC,
557 };
558 
560 #define SND_CHMAP_POSITION_MASK 0xffff
561 
563 #define SND_CHMAP_PHASE_INVERSE (0x01 << 16)
564 
565 #define SND_CHMAP_DRIVER_SPEC (0x02 << 16)
566 
568 typedef struct snd_pcm_chmap {
569  unsigned int channels;
570  unsigned int pos[0];
572 
574 typedef struct snd_pcm_chmap_query {
578 
579 
582  int subdev,
583  snd_pcm_stream_t stream);
586 int snd_pcm_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map);
587 
588 const char *snd_pcm_chmap_type_name(enum snd_pcm_chmap_type val);
589 const char *snd_pcm_chmap_name(enum snd_pcm_chmap_position val);
590 const char *snd_pcm_chmap_long_name(enum snd_pcm_chmap_position val);
591 int snd_pcm_chmap_print(const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
592 unsigned int snd_pcm_chmap_from_string(const char *str);
594 
595 //int snd_pcm_mixer_element(snd_pcm_t *pcm, snd_mixer_t *mixer, snd_mixer_elem_t **elem);
596 
597 /*
598  * application helpers - these functions are implemented on top
599  * of the basic API
600  */
601 
602 int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent);
604  snd_pcm_format_t format,
605  snd_pcm_access_t access,
606  unsigned int channels,
607  unsigned int rate,
608  int soft_resample,
609  unsigned int latency);
611  snd_pcm_uframes_t *buffer_size,
612  snd_pcm_uframes_t *period_size);
613 
623 size_t snd_pcm_info_sizeof(void);
628 #define snd_pcm_info_alloca(ptr) __snd_alloca(ptr, snd_pcm_info)
631 void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src);
632 unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj);
633 unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj);
635 int snd_pcm_info_get_card(const snd_pcm_info_t *obj);
636 const char *snd_pcm_info_get_id(const snd_pcm_info_t *obj);
637 const char *snd_pcm_info_get_name(const snd_pcm_info_t *obj);
638 const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj);
641 unsigned int snd_pcm_info_get_subdevices_count(const snd_pcm_info_t *obj);
642 unsigned int snd_pcm_info_get_subdevices_avail(const snd_pcm_info_t *obj);
644 void snd_pcm_info_set_device(snd_pcm_info_t *obj, unsigned int val);
645 void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val);
647 
658 
673  unsigned int *rate_num,
674  unsigned int *rate_den);
677 
678 #if 0
679 typedef struct _snd_pcm_hw_strategy snd_pcm_hw_strategy_t;
680 
681 /* choices need to be sorted on ascending badness */
682 typedef struct _snd_pcm_hw_strategy_simple_choices_list {
683  unsigned int value;
684  unsigned int badness;
685 } snd_pcm_hw_strategy_simple_choices_list_t;
686 
687 int snd_pcm_hw_params_strategy(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
688  const snd_pcm_hw_strategy_t *strategy,
689  unsigned int badness_min,
690  unsigned int badness_max);
691 
692 void snd_pcm_hw_strategy_free(snd_pcm_hw_strategy_t *strategy);
693 int snd_pcm_hw_strategy_simple(snd_pcm_hw_strategy_t **strategyp,
694  unsigned int badness_min,
695  unsigned int badness_max);
696 int snd_pcm_hw_params_try_explain_failure(snd_pcm_t *pcm,
697  snd_pcm_hw_params_t *fail,
698  snd_pcm_hw_params_t *success,
699  unsigned int depth,
700  snd_output_t *out);
701 
702 #endif
703 
704 size_t snd_pcm_hw_params_sizeof(void);
709 #define snd_pcm_hw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_hw_params)
713 
714 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
715 
723 
731 
739 
740 int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params, unsigned int *val);
741 int snd_pcm_hw_params_get_channels_min(const snd_pcm_hw_params_t *params, unsigned int *val);
742 int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *params, unsigned int *val);
743 int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
744 int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
745 int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
746 int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
747 int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max);
748 int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
749 int snd_pcm_hw_params_set_channels_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
750 int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
751 
752 int snd_pcm_hw_params_get_rate(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
753 int snd_pcm_hw_params_get_rate_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
754 int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
755 int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
756 int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
757 int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
758 int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
759 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);
760 int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
761 int snd_pcm_hw_params_set_rate_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
762 int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
763 int snd_pcm_hw_params_set_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
764 int snd_pcm_hw_params_get_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
765 int snd_pcm_hw_params_set_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
766 int snd_pcm_hw_params_get_export_buffer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
767 int snd_pcm_hw_params_set_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
768 int snd_pcm_hw_params_get_period_wakeup(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val);
769 
770 int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
771 int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
772 int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
773 int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
774 int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
775 int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
776 int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
777 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);
778 int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
779 int snd_pcm_hw_params_set_period_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
780 int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
781 
782 int snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
783 int snd_pcm_hw_params_get_period_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
784 int snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
785 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);
786 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);
787 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);
788 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);
789 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);
790 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);
791 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);
792 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);
794 
795 int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
796 int snd_pcm_hw_params_get_periods_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
797 int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
798 int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
799 int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
800 int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
801 int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
802 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);
803 int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
804 int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
805 int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
807 
808 int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
809 int snd_pcm_hw_params_get_buffer_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
810 int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
811 int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
812 int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir);
813 int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
814 int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
815 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);
816 int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
817 int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
818 int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
819 
820 int snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
821 int snd_pcm_hw_params_get_buffer_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
822 int snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
823 int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
824 int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val);
825 int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
826 int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
827 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);
828 int snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
829 int snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
830 int snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
831 
832 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
833 
834 int snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
835 
845 size_t snd_pcm_sw_params_sizeof(void);
850 #define snd_pcm_sw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_sw_params)
854 int snd_pcm_sw_params_get_boundary(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
855 
856 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_SW_PARAMS_API)
857 
862 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
863 int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
865 int snd_pcm_sw_params_get_period_event(const snd_pcm_sw_params_t *params, int *val);
866 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
867 int snd_pcm_sw_params_get_start_threshold(const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val);
868 int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
869 int snd_pcm_sw_params_get_stop_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
870 int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
871 int snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
872 int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val);
873 int snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val);
874 
875 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
876 
879 /* include old API */
880 #ifndef ALSA_LIBRARY_BUILD
881 #if defined(ALSA_PCM_OLD_HW_PARAMS_API) || defined(ALSA_PCM_OLD_SW_PARAMS_API)
882 #include "pcm_old.h"
883 #endif
884 #endif
885 
893 size_t snd_pcm_access_mask_sizeof(void);
898 #define snd_pcm_access_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_access_mask)
908 
918 size_t snd_pcm_format_mask_sizeof(void);
923 #define snd_pcm_format_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_format_mask)
933 
943 size_t snd_pcm_subformat_mask_sizeof(void);
948 #define snd_pcm_subformat_mask_alloca(ptr) __snd_alloca(ptr, snd_pcm_subformat_mask)
958 
968 size_t snd_pcm_status_sizeof(void);
973 #define snd_pcm_status_alloca(ptr) __snd_alloca(ptr, snd_pcm_status)
983 snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj);
984 snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj);
985 snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj);
986 snd_pcm_uframes_t snd_pcm_status_get_overrange(const snd_pcm_status_t *obj);
987 
997 const char *snd_pcm_type_name(snd_pcm_type_t type);
998 const char *snd_pcm_stream_name(const snd_pcm_stream_t stream);
999 const char *snd_pcm_access_name(const snd_pcm_access_t _access);
1000 const char *snd_pcm_format_name(const snd_pcm_format_t format);
1001 const char *snd_pcm_format_description(const snd_pcm_format_t format);
1002 const char *snd_pcm_subformat_name(const snd_pcm_subformat_t subformat);
1003 const char *snd_pcm_subformat_description(const snd_pcm_subformat_t subformat);
1004 snd_pcm_format_t snd_pcm_format_value(const char* name);
1005 const char *snd_pcm_tstamp_mode_name(const snd_pcm_tstamp_t mode);
1006 const char *snd_pcm_state_name(const snd_pcm_state_t state);
1007 
1017 int snd_pcm_dump(snd_pcm_t *pcm, snd_output_t *out);
1020 int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out);
1024 
1034 int snd_pcm_mmap_begin(snd_pcm_t *pcm,
1035  const snd_pcm_channel_area_t **areas,
1036  snd_pcm_uframes_t *offset,
1037  snd_pcm_uframes_t *frames);
1038 snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm,
1039  snd_pcm_uframes_t offset,
1040  snd_pcm_uframes_t frames);
1041 snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
1042 snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
1043 snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
1044 snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
1045 
1062 int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */
1063 int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */
1064 snd_pcm_format_t snd_pcm_build_linear_format(int width, int pwidth, int unsignd, int big_endian);
1065 ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
1066 u_int8_t snd_pcm_format_silence(snd_pcm_format_t format);
1070 int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int samples);
1071 
1072 snd_pcm_sframes_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes);
1073 ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *pcm, snd_pcm_sframes_t frames);
1074 long snd_pcm_bytes_to_samples(snd_pcm_t *pcm, ssize_t bytes);
1075 ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, long samples);
1076 
1077 int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset,
1078  unsigned int samples, snd_pcm_format_t format);
1079 int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset,
1080  unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format);
1081 int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset,
1082  const snd_pcm_channel_area_t *src_channel, snd_pcm_uframes_t src_offset,
1083  unsigned int samples, snd_pcm_format_t format);
1084 int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset,
1085  const snd_pcm_channel_area_t *src_channels, snd_pcm_uframes_t src_offset,
1086  unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format);
1087 
1098 typedef enum _snd_pcm_hook_type {
1099  SND_PCM_HOOK_TYPE_HW_PARAMS = 0,
1100  SND_PCM_HOOK_TYPE_HW_FREE,
1101  SND_PCM_HOOK_TYPE_CLOSE,
1102  SND_PCM_HOOK_TYPE_LAST = SND_PCM_HOOK_TYPE_CLOSE
1104 
1106 typedef struct _snd_pcm_hook snd_pcm_hook_t;
1108 typedef int (*snd_pcm_hook_func_t)(snd_pcm_hook_t *hook);
1111 void snd_pcm_hook_set_private(snd_pcm_hook_t *hook, void *private_data);
1112 int snd_pcm_hook_add(snd_pcm_hook_t **hookp, snd_pcm_t *pcm,
1113  snd_pcm_hook_type_t type,
1114  snd_pcm_hook_func_t func, void *private_data);
1116 
1127 typedef struct _snd_pcm_scope_ops {
1131  int (*enable)(snd_pcm_scope_t *scope);
1135  void (*disable)(snd_pcm_scope_t *scope);
1139  void (*start)(snd_pcm_scope_t *scope);
1143  void (*stop)(snd_pcm_scope_t *scope);
1147  void (*update)(snd_pcm_scope_t *scope);
1151  void (*reset)(snd_pcm_scope_t *scope);
1155  void (*close)(snd_pcm_scope_t *scope);
1157 
1158 snd_pcm_uframes_t snd_pcm_meter_get_bufsize(snd_pcm_t *pcm);
1159 unsigned int snd_pcm_meter_get_channels(snd_pcm_t *pcm);
1160 unsigned int snd_pcm_meter_get_rate(snd_pcm_t *pcm);
1161 snd_pcm_uframes_t snd_pcm_meter_get_now(snd_pcm_t *pcm);
1162 snd_pcm_uframes_t snd_pcm_meter_get_boundary(snd_pcm_t *pcm);
1164 snd_pcm_scope_t *snd_pcm_meter_search_scope(snd_pcm_t *pcm, const char *name);
1167  const snd_pcm_scope_ops_t *val);
1168 void snd_pcm_scope_set_name(snd_pcm_scope_t *scope, const char *val);
1169 const char *snd_pcm_scope_get_name(snd_pcm_scope_t *scope);
1171 void snd_pcm_scope_set_callback_private(snd_pcm_scope_t *scope, void *val);
1172 int snd_pcm_scope_s16_open(snd_pcm_t *pcm, const char *name,
1173  snd_pcm_scope_t **scopep);
1175  unsigned int channel);
1176 
1187 typedef enum _snd_spcm_latency {
1198 
1200 typedef enum _snd_spcm_xrun_type {
1206 
1208 typedef enum _snd_spcm_duplex_type {
1214 
1215 int snd_spcm_init(snd_pcm_t *pcm,
1216  unsigned int rate,
1217  unsigned int channels,
1218  snd_pcm_format_t format,
1219  snd_pcm_subformat_t subformat,
1220  snd_spcm_latency_t latency,
1221  snd_pcm_access_t _access,
1222  snd_spcm_xrun_type_t xrun_type);
1223 
1224 int snd_spcm_init_duplex(snd_pcm_t *playback_pcm,
1225  snd_pcm_t *capture_pcm,
1226  unsigned int rate,
1227  unsigned int channels,
1228  snd_pcm_format_t format,
1229  snd_pcm_subformat_t subformat,
1230  snd_spcm_latency_t latency,
1231  snd_pcm_access_t _access,
1232  snd_spcm_xrun_type_t xrun_type,
1233  snd_spcm_duplex_type_t duplex_type);
1234 
1236  unsigned int *rate,
1237  snd_pcm_uframes_t *buffer_size,
1238  snd_pcm_uframes_t *period_size);
1239 
1249 /* Deprecated functions, for compatibility */
1250 const char *snd_pcm_start_mode_name(snd_pcm_start_t mode) __attribute__((deprecated));
1251 const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode) __attribute__((deprecated));
1252 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));
1253 snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
1254 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));
1255 snd_pcm_xrun_t snd_pcm_sw_params_get_xrun_mode(const snd_pcm_sw_params_t *params) __attribute__((deprecated));
1256 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_SW_PARAMS_API)
1257 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));
1258 int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val) __attribute__((deprecated));
1259 int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int val) __attribute__((deprecated));
1260 int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params, unsigned int *val) __attribute__((deprecated));
1261 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
1262 #if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
1263 int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1264 int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1265 int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
1266 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));
1267 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));
1268 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));
1269 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));
1270 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));
1271 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));
1272 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));
1273 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));
1274 #endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
1275 
1278 #ifdef __cplusplus
1279 }
1280 #endif
1281 
1282 #endif /* __ALSA_PCM_H */