From 8f0cb26fdfbd637765ed6ab65b365e43206c99f5 Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Tue, 6 Feb 2001 23:48:10 +0000 Subject: [PATCH] Control API encapsulation. Better names for kernel API. Simpler PCM hw_params API. Added missing const. --- aserver/aserver.c | 14 +- include/Makefile.am | 2 +- include/aserver.h | 2 +- include/conf.h | 35 +- include/control.h | 107 ++-- include/control_m4.h | 284 +++++++++++ include/global.h | 18 +- include/header.h | 1 + include/hwdep_m4.h | 6 +- include/local.h | 28 ++ include/pcm.h | 14 +- include/pcm_m4.h | 146 +++--- include/rawmidi.h | 1 + include/rawmidi_m4.h | 12 +- include/timer.h | 3 + src/conf.c | 67 +-- src/control/Makefile.am | 2 +- src/control/bag.c | 2 - src/control/cards.c | 13 +- src/control/control.c | 80 ++- src/control/control_hw.c | 10 +- src/control/control_local.h | 49 +- src/control/control_m4.c | 937 ++++++++++++++++++++++++++++++++++++ src/control/control_shm.c | 18 +- src/control/controls.c | 70 +-- src/control/defaults.c | 1 - src/hwdep/hwdep.c | 1 - src/hwdep/hwdep_m4.c | 8 +- src/input.c | 2 - src/instr/fm.c | 1 - src/instr/iwffff.c | 1 - src/instr/simple.c | 1 - src/mixer/mixer.c | 1 - src/mixer/mixer_local.h | 1 - src/mixer/simple.c | 82 ++-- src/output.c | 2 - src/pcm/interval.c | 2 - src/pcm/mask.c | 2 - src/pcm/mask_inline.h | 1 - src/pcm/pcm.c | 31 +- src/pcm/pcm_adpcm.c | 6 +- src/pcm/pcm_alaw.c | 6 +- src/pcm/pcm_copy.c | 4 +- src/pcm/pcm_file.c | 14 +- src/pcm/pcm_hw.c | 5 +- src/pcm/pcm_linear.c | 6 +- src/pcm/pcm_local.h | 12 +- src/pcm/pcm_m4.c | 356 ++++++++------ src/pcm/pcm_misc.c | 1 - src/pcm/pcm_mmap.c | 1 - src/pcm/pcm_mulaw.c | 6 +- src/pcm/pcm_multi.c | 5 +- src/pcm/pcm_null.c | 2 +- src/pcm/pcm_params.c | 10 +- src/pcm/pcm_plug.c | 14 +- src/pcm/pcm_rate.c | 6 +- src/pcm/pcm_route.c | 6 +- src/pcm/pcm_share.c | 7 +- src/pcm/pcm_shm.c | 11 +- src/rawmidi/rawmidi.c | 5 +- src/rawmidi/rawmidi_hw.c | 3 +- src/rawmidi/rawmidi_local.h | 2 - src/rawmidi/rawmidi_m4.c | 12 +- src/seq/seq.c | 4 +- src/seq/seq_local.h | 2 - src/seq/seq_midi_event.c | 1 - src/seq/seqmid.c | 1 - src/timer/timer.c | 1 - test/control.c | 4 +- test/mixer.c | 4 +- test/switches.c | 4 +- 71 files changed, 1943 insertions(+), 636 deletions(-) create mode 100644 include/control_m4.h create mode 100644 src/control/control_m4.c diff --git a/aserver/aserver.c b/aserver/aserver.c index f143c264..6f879824 100644 --- a/aserver/aserver.c +++ b/aserver/aserver.c @@ -24,10 +24,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -573,13 +571,13 @@ int ctl_shm_cmd(client_t *client) ctrl->cmd = 0; ctl = client->device.control.handle; switch (cmd) { - case SNDRV_CTL_IOCTL_HW_INFO: - ctrl->result = snd_ctl_hw_info(ctl, &ctrl->u.hw_info); + case SNDRV_CTL_IOCTL_INFO: + ctrl->result = snd_ctl_info(ctl, &ctrl->u.hw_info); break; case SNDRV_CTL_IOCTL_CONTROL_LIST: { size_t maxsize = CTL_SHM_DATA_MAXLEN; - if (ctrl->u.clist.controls_request * sizeof(*ctrl->u.clist.pids) > maxsize) { + if (ctrl->u.clist.space * sizeof(*ctrl->u.clist.pids) > maxsize) { ctrl->result = -EFAULT; break; } @@ -837,7 +835,7 @@ int inet_handler(waiter_t *waiter, unsigned short events ATTRIBUTE_UNUSED) return 0; } -int server(char *sockname, int port) +int server(const char *sockname, int port) { int err; unsigned int k; @@ -939,8 +937,8 @@ int main(int argc, char **argv) int c; snd_config_t *conf; snd_config_iterator_t i; - char *socket = NULL; - char *host = NULL; + const char *socket = NULL; + const char *host = NULL; long port = -1; int err; char *srvname; diff --git a/include/Makefile.am b/include/Makefile.am index e6fcfe2b..c0d741ca 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -5,7 +5,7 @@ sysinclude_HEADERS = asoundlib.h # header_files=header.h version.h global.h input.h output.h error.h mixer.h \ pcm.h pcm_m4.h rawmidi.h rawmidi_m4.h timer.h \ - hwdep.h hwdep_m4.h control.h \ + hwdep.h hwdep_m4.h control.h control_m4.h \ seq.h seqmid.h seq_midi_event.h \ conv.h instr.h conf.h footer.h diff --git a/include/aserver.h b/include/aserver.h index de092bc6..2f7f523c 100644 --- a/include/aserver.h +++ b/include/aserver.h @@ -89,7 +89,7 @@ typedef struct { int cmd; union { int device; - snd_ctl_hw_info_t hw_info; + snd_ctl_info_t hw_info; snd_control_list_t clist; snd_control_info_t cinfo; snd_control_t cread; diff --git a/include/conf.h b/include/conf.h index 6e83042a..178be798 100644 --- a/include/conf.h +++ b/include/conf.h @@ -1,4 +1,18 @@ +#define LIST_HEAD_IS_DEFINED +struct list_head { + struct list_head *next, *prev; +}; + +/** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ +#define list_entry(ptr, type, member) \ + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + enum _snd_config_type { SND_CONFIG_TYPE_INTEGER, SND_CONFIG_TYPE_REAL, @@ -50,30 +64,27 @@ int snd_config_top(snd_config_t **config); int snd_config_load(snd_config_t *config, snd_input_t *in); int snd_config_save(snd_config_t *config, snd_output_t *out); -int snd_config_search(snd_config_t *config, char *key, snd_config_t **result); +int snd_config_search(snd_config_t *config, const char *key, + snd_config_t **result); int snd_config_searchv(snd_config_t *config, snd_config_t **result, ...); int snd_config_add(snd_config_t *config, snd_config_t *leaf); int snd_config_delete(snd_config_t *config); -int snd_config_make(snd_config_t **config, char *key, +int snd_config_make(snd_config_t **config, const char *key, snd_config_type_t type); -int snd_config_integer_make(snd_config_t **config, char *key); -int snd_config_real_make(snd_config_t **config, char *key); -int snd_config_string_make(snd_config_t **config, char *key); -int snd_config_compound_make(snd_config_t **config, char *key, int join); +int snd_config_integer_make(snd_config_t **config, const char *key); +int snd_config_real_make(snd_config_t **config, const char *key); +int snd_config_string_make(snd_config_t **config, const char *key); +int snd_config_compound_make(snd_config_t **config, const char *key, int join); int snd_config_integer_set(snd_config_t *config, long value); int snd_config_real_set(snd_config_t *config, double value); -int snd_config_string_set(snd_config_t *config, char *value); +int snd_config_string_set(snd_config_t *config, const char *value); int snd_config_integer_get(snd_config_t *config, long *value); int snd_config_real_get(snd_config_t *config, double *value); -int snd_config_string_get(snd_config_t *config, char **value); - -/* One argument: long, double or char* */ -int snd_config_set(snd_config_t *config, ...); -int snd_config_get(snd_config_t *config, void *); +int snd_config_string_get(snd_config_t *config, const char **value); typedef struct list_head *snd_config_iterator_t; diff --git a/include/control.h b/include/control.h index f4c3fff5..f629888d 100644 --- a/include/control.h +++ b/include/control.h @@ -6,21 +6,20 @@ ****************************************************************************/ typedef struct sndrv_aes_iec958 snd_aes_iec958_t; -typedef union sndrv_digital_audio snd_digital_audio_t; -typedef struct sndrv_ctl_hw_info snd_ctl_hw_info_t; -typedef struct sndrv_control_id snd_control_id_t; -typedef struct sndrv_control_list snd_control_list_t; -typedef struct sndrv_control_info snd_control_info_t; -typedef struct sndrv_control snd_control_t; -typedef struct sndrv_ctl_event snd_ctl_event_t; +typedef struct _snd_ctl_info snd_ctl_info_t; +typedef struct _snd_control_id snd_control_id_t; +typedef struct _snd_control_list snd_control_list_t; +typedef struct _snd_control_info snd_control_info_t; +typedef struct _snd_control snd_control_t; +typedef struct _snd_ctl_event snd_ctl_event_t; #ifdef SND_ENUM_TYPECHECK -typedef struct __snd_card_type *snd_card_type; +typedef struct __snd_card_type *snd_card_type_t; typedef struct __snd_control_type *snd_control_type_t; typedef struct __snd_control_iface *snd_control_iface_t; typedef struct __snd_ctl_event_type *snd_ctl_event_type_t; #else -typedef enum sndrv_card_type snd_card_type; +typedef enum sndrv_card_type snd_card_type_t; typedef enum sndrv_control_type snd_control_type_t; typedef enum sndrv_control_iface snd_control_iface_t; typedef enum sndrv_ctl_event_type snd_ctl_event_type_t; @@ -102,6 +101,7 @@ typedef enum sndrv_ctl_event_type snd_ctl_event_type_t; #define SND_CONTROL_TYPE_ENUMERATED ((snd_control_type_t) SNDRV_CONTROL_TYPE_ENUMERATED) #define SND_CONTROL_TYPE_BYTES ((snd_control_type_t) SNDRV_CONTROL_TYPE_BYTES) #define SND_CONTROL_TYPE_IEC958 ((snd_control_type_t) SNDRV_CONTROL_TYPE_IEC958) +#define SND_CONTROL_TYPE_LAST ((snd_control_type_t) SNDRV_CONTROL_TYPE_LAST) #define SND_CONTROL_IFACE_CARD ((snd_control_iface_t) SNDRV_CONTROL_IFACE_CARD) #define SND_CONTROL_IFACE_HWDEP ((snd_control_iface_t) SNDRV_CONTROL_IFACE_HWDEP) @@ -110,20 +110,14 @@ typedef enum sndrv_ctl_event_type snd_ctl_event_type_t; #define SND_CONTROL_IFACE_RAWMIDI ((snd_control_iface_t) SNDRV_CONTROL_IFACE_RAWMIDI) #define SND_CONTROL_IFACE_TIMER ((snd_control_iface_t) SNDRV_CONTROL_IFACE_TIMER) #define SND_CONTROL_IFACE_SEQUENCER ((snd_control_iface_t) SNDRV_CONTROL_IFACE_SEQUENCER) +#define SND_CONTROL_IFACE_LAST ((snd_control_iface_t) SNDRV_CONTROL_IFACE_LAST) #define SND_CTL_EVENT_REBUILD ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_REBUILD) #define SND_CTL_EVENT_VALUE ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_VALUE) #define SND_CTL_EVENT_CHANGE ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_CHANGE) #define SND_CTL_EVENT_ADD ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_ADD) #define SND_CTL_EVENT_REMOVE ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_REMOVE) - -#define SND_CONTROL_ACCESS_READ SNDRV_CONTROL_ACCESS_READ -#define SND_CONTROL_ACCESS_WRITE SNDRV_CONTROL_ACCESS_WRITE -#define SND_CONTROL_ACCESS_READWRITE SNDRV_CONTROL_ACCESS_READWRITE -#define SND_CONTROL_ACCESS_VOLATILE SNDRV_CONTROL_ACCESS_VOLATILE -#define SND_CONTROL_ACCESS_INACTIVE SNDRV_CONTROL_ACCESS_INACTIVE -#define SND_CONTROL_ACCESS_LOCK SNDRV_CONTROL_ACCESS_LOCK -#define SND_CONTROL_ACCESS_INDIRECT SNDRV_CONTROL_ACCESS_INDIRECT +#define SND_CTL_EVENT_LAST ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_LAST) enum _snd_ctl_type { SND_CTL_TYPE_HW, @@ -142,16 +136,7 @@ typedef enum _snd_ctl_type snd_ctl_type_t; #define SND_CTL_TYPE_INET ((snd_ctl_type_t) SND_CTL_TYPE_INET) typedef struct _snd_ctl snd_ctl_t; - -typedef struct _snd_ctl_callbacks { - void *private_data; /* may be used by an application */ - void (*rebuild) (snd_ctl_t *handle, void *private_data); - void (*value) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id); - void (*change) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id); - void (*add) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id); - void (*remove) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id); - void *reserved[58]; /* reserved for the future use - must be NULL!!! */ -} snd_ctl_callbacks_t; +typedef struct _snd_ctl_callbacks snd_ctl_callbacks_t; #ifdef __cplusplus extern "C" { @@ -175,7 +160,7 @@ int snd_ctl_open(snd_ctl_t **handle, char *name); int snd_ctl_close(snd_ctl_t *handle); int snd_ctl_card(snd_ctl_t *handle); int snd_ctl_poll_descriptor(snd_ctl_t *handle); -int snd_ctl_hw_info(snd_ctl_t *handle, snd_ctl_hw_info_t *info); +int snd_ctl_info(snd_ctl_t *handle, snd_ctl_info_t *info); int snd_ctl_clist(snd_ctl_t *handle, snd_control_list_t * list); int snd_ctl_cinfo(snd_ctl_t *handle, snd_control_info_t * sw); int snd_ctl_cread(snd_ctl_t *handle, snd_control_t * control); @@ -191,6 +176,15 @@ int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *handle, int subdev); int snd_ctl_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks); +void snd_control_set_bytes(snd_control_t *obj, void *data, size_t size); + +const char *snd_control_type_name(snd_control_type_t type); +const char *snd_control_iface_name(snd_control_iface_t iface); +const char *snd_ctl_event_type_name(snd_ctl_event_type_t type); + +int snd_control_list_alloc_space(snd_control_list_t *obj, unsigned int entries); +void snd_control_list_free_space(snd_control_list_t *obj); + #ifdef __cplusplus } #endif @@ -199,57 +193,20 @@ int snd_ctl_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks); * Highlevel API for controls */ -#define LIST_HEAD_IS_DEFINED -struct list_head { - struct list_head *next, *prev; -}; - -/** - * list_entry - get the struct for this entry - * @ptr: the &struct list_head pointer. - * @type: the type of the struct this is embedded in. - * @member: the name of the list_struct within the struct. - */ -#define list_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) - - typedef struct _snd_hcontrol_list snd_hcontrol_list_t; typedef struct _snd_hcontrol snd_hcontrol_t; -struct _snd_hcontrol_list { - unsigned int controls_offset; /* W: first control ID to get */ - unsigned int controls_request; /* W: count of control IDs to get */ - unsigned int controls_count; /* R: count of available (set) controls */ - unsigned int controls; /* R: count of all available controls */ - snd_control_id_t *pids; /* W: IDs */ -}; - -struct _snd_hcontrol { - snd_control_id_t id; /* must be always on top */ - struct list_head list; /* links for list of all hcontrols */ - int change: 1, /* structure change */ - value: 1; /* value change */ - /* event callbacks */ - void (*event_change)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol); - void (*event_value)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol); - void (*event_remove)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol); - /* private data */ - void *private_data; - void (*private_free)(void *private_data); - /* links */ - snd_ctl_t *handle; /* associated handle */ -}; - #ifdef __cplusplus extern "C" { #endif -typedef int (snd_ctl_hsort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2); -typedef void (snd_ctl_hcallback_rebuild_t)(snd_ctl_t *handle, void *private_data); -typedef void (snd_ctl_hcallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol); +typedef int (*snd_ctl_hsort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2); +typedef void (*snd_ctl_hcallback_rebuild_t)(snd_ctl_t *handle, void *private_data); +typedef void (*snd_ctl_hcallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol); +typedef void (*snd_hcontrol_callback_t)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol); +typedef void (*snd_hcontrol_private_free_t)(snd_hcontrol_t *hcontrol); -int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t *csort); +int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t csort); int snd_ctl_hfree(snd_ctl_t *handle); snd_hcontrol_t *snd_ctl_hfirst(snd_ctl_t *handle); snd_hcontrol_t *snd_ctl_hlast(snd_ctl_t *handle); @@ -259,9 +216,9 @@ int snd_ctl_hcount(snd_ctl_t *handle); snd_hcontrol_t *snd_ctl_hfind(snd_ctl_t *handle, snd_control_id_t *id); int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist); int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2); -int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t *csort); -int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t *callback, void *private_data); -int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t *callback, void *private_data); +int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t csort); +int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t callback, void *private_data); +int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t callback, void *private_data); int snd_ctl_hevent(snd_ctl_t *handle); int snd_ctl_hbag_create(void **bag); @@ -269,6 +226,8 @@ int snd_ctl_hbag_destroy(void **bag, void (*hcontrol_free)(snd_hcontrol_t *hcont int snd_ctl_hbag_add(void **bag, snd_hcontrol_t *hcontrol); int snd_ctl_hbag_del(void **bag, snd_hcontrol_t *hcontrol); snd_hcontrol_t *snd_ctl_hbag_find(void **bag, snd_control_id_t *id); +int snd_hcontrol_list_alloc_space(snd_hcontrol_list_t *obj, unsigned int entries); +void snd_hcontrol_list_free_space(snd_hcontrol_list_t *obj); #ifdef __cplusplus } diff --git a/include/control_m4.h b/include/control_m4.h new file mode 100644 index 00000000..0e30d544 --- /dev/null +++ b/include/control_m4.h @@ -0,0 +1,284 @@ +#ifdef __cplusplus +extern "C" { +#endif + +size_t snd_control_id_sizeof(); +#define snd_control_id_alloca(ptr) ({ assert(ptr); *ptr = (snd_control_id_t *) alloca(snd_control_id_sizeof()); memset(*ptr, 0, snd_control_id_sizeof()); 0; }) +int snd_control_id_malloc(snd_control_id_t **ptr); +void snd_control_id_free(snd_control_id_t *obj); +void snd_control_id_copy(snd_control_id_t *dst, const snd_control_id_t *src); + +unsigned int snd_control_id_get_numid(const snd_control_id_t *obj); + +snd_control_iface_t snd_control_id_get_interface(const snd_control_id_t *obj); + +unsigned int snd_control_id_get_device(const snd_control_id_t *obj); + +unsigned int snd_control_id_get_subdevice(const snd_control_id_t *obj); + +const char *snd_control_id_get_name(const snd_control_id_t *obj); + +unsigned int snd_control_id_get_index(const snd_control_id_t *obj); + +void snd_control_id_set_numid(snd_control_id_t *obj, unsigned int val); + +void snd_control_id_set_interface(snd_control_id_t *obj, snd_control_iface_t val); + +void snd_control_id_set_device(snd_control_id_t *obj, unsigned int val); + +void snd_control_id_set_subdevice(snd_control_id_t *obj, unsigned int val); + +void snd_control_id_set_name(snd_control_id_t *obj, const char *val); + +void snd_control_id_set_index(snd_control_id_t *obj, unsigned int val); + +size_t snd_ctl_info_sizeof(); +#define snd_ctl_info_alloca(ptr) ({ assert(ptr); *ptr = (snd_ctl_info_t *) alloca(snd_ctl_info_sizeof()); memset(*ptr, 0, snd_ctl_info_sizeof()); 0; }) +int snd_ctl_info_malloc(snd_ctl_info_t **ptr); +void snd_ctl_info_free(snd_ctl_info_t *obj); +void snd_ctl_info_copy(snd_ctl_info_t *dst, const snd_ctl_info_t *src); + +int snd_ctl_info_get_card(const snd_ctl_info_t *obj); + +snd_card_type_t snd_ctl_info_get_type(const snd_ctl_info_t *obj); + +const char *snd_ctl_info_get_id(const snd_ctl_info_t *obj); + +const char *snd_ctl_info_get_abbreviation(const snd_ctl_info_t *obj); + +const char *snd_ctl_info_get_name(const snd_ctl_info_t *obj); + +const char *snd_ctl_info_get_longname(const snd_ctl_info_t *obj); + +const char *snd_ctl_info_get_mixerid(const snd_ctl_info_t *obj); + +const char *snd_ctl_info_get_mixername(const snd_ctl_info_t *obj); + +size_t snd_ctl_event_sizeof(); +#define snd_ctl_event_alloca(ptr) ({ assert(ptr); *ptr = (snd_ctl_event_t *) alloca(snd_ctl_event_sizeof()); memset(*ptr, 0, snd_ctl_event_sizeof()); 0; }) +int snd_ctl_event_malloc(snd_ctl_event_t **ptr); +void snd_ctl_event_free(snd_ctl_event_t *obj); +void snd_ctl_event_copy(snd_ctl_event_t *dst, const snd_ctl_event_t *src); + +snd_ctl_event_type_t snd_ctl_event_get_type(const snd_ctl_event_t *obj); + +unsigned int snd_ctl_event_get_numid(const snd_ctl_event_t *obj); + +void snd_ctl_event_get_id(const snd_ctl_event_t *obj, snd_control_id_t *ptr); + +snd_control_iface_t snd_ctl_event_get_interface(const snd_ctl_event_t *obj); + +unsigned int snd_ctl_event_get_device(const snd_ctl_event_t *obj); + +unsigned int snd_ctl_event_get_subdevice(const snd_ctl_event_t *obj); + +const char *snd_ctl_event_get_name(const snd_ctl_event_t *obj); + +unsigned int snd_ctl_event_get_index(const snd_ctl_event_t *obj); + +size_t snd_control_list_sizeof(); +#define snd_control_list_alloca(ptr) ({ assert(ptr); *ptr = (snd_control_list_t *) alloca(snd_control_list_sizeof()); memset(*ptr, 0, snd_control_list_sizeof()); 0; }) +int snd_control_list_malloc(snd_control_list_t **ptr); +void snd_control_list_free(snd_control_list_t *obj); +void snd_control_list_copy(snd_control_list_t *dst, const snd_control_list_t *src); + +void snd_control_list_set_offset(snd_control_list_t *obj, unsigned int val); + +unsigned int snd_control_list_get_used(const snd_control_list_t *obj); + +unsigned int snd_control_list_get_count(const snd_control_list_t *obj); + +void snd_control_list_get_id(const snd_control_list_t *obj, unsigned int idx, snd_control_id_t *ptr); + +unsigned int snd_control_list_get_numid(const snd_control_list_t *obj, unsigned int idx); + +snd_control_iface_t snd_control_list_get_interface(const snd_control_list_t *obj, unsigned int idx); + +unsigned int snd_control_list_get_device(const snd_control_list_t *obj, unsigned int idx); + +unsigned int snd_control_list_get_subdevice(const snd_control_list_t *obj, unsigned int idx); + +const char *snd_control_list_get_name(const snd_control_list_t *obj, unsigned int idx); + +unsigned int snd_control_list_get_index(const snd_control_list_t *obj, unsigned int idx); + +size_t snd_control_info_sizeof(); +#define snd_control_info_alloca(ptr) ({ assert(ptr); *ptr = (snd_control_info_t *) alloca(snd_control_info_sizeof()); memset(*ptr, 0, snd_control_info_sizeof()); 0; }) +int snd_control_info_malloc(snd_control_info_t **ptr); +void snd_control_info_free(snd_control_info_t *obj); +void snd_control_info_copy(snd_control_info_t *dst, const snd_control_info_t *src); + +snd_control_type_t snd_control_info_get_type(const snd_control_info_t *obj); + +int snd_control_info_is_readable(const snd_control_info_t *obj); + +int snd_control_info_is_writable(const snd_control_info_t *obj); + +int snd_control_info_is_volatile(const snd_control_info_t *obj); + +int snd_control_info_is_inactive(const snd_control_info_t *obj); + +int snd_control_info_is_locked(const snd_control_info_t *obj); + +int snd_control_info_is_indirect(const snd_control_info_t *obj); + +unsigned int snd_control_info_get_count(const snd_control_info_t *obj); + +long snd_control_info_get_min(const snd_control_info_t *obj); + +long snd_control_info_get_max(const snd_control_info_t *obj); + +long snd_control_info_get_step(const snd_control_info_t *obj); + +unsigned int snd_control_info_get_items(const snd_control_info_t *obj); + +void snd_control_info_set_item(snd_control_info_t *obj, unsigned int val); + +const char *snd_control_info_get_item_name(const snd_control_info_t *obj); + +void snd_control_info_get_id(const snd_control_info_t *obj, snd_control_id_t *ptr); + +unsigned int snd_control_info_get_numid(const snd_control_info_t *obj); + +snd_control_iface_t snd_control_info_get_interface(const snd_control_info_t *obj); + +unsigned int snd_control_info_get_device(const snd_control_info_t *obj); + +unsigned int snd_control_info_get_subdevice(const snd_control_info_t *obj); + +const char *snd_control_info_get_name(const snd_control_info_t *obj); + +unsigned int snd_control_info_get_index(const snd_control_info_t *obj); + +void snd_control_info_set_id(snd_control_info_t *obj, const snd_control_id_t *ptr); + +void snd_control_info_set_numid(snd_control_info_t *obj, unsigned int val); + +void snd_control_info_set_interface(snd_control_info_t *obj, snd_control_iface_t val); + +void snd_control_info_set_device(snd_control_info_t *obj, unsigned int val); + +void snd_control_info_set_subdevice(snd_control_info_t *obj, unsigned int val); + +void snd_control_info_set_name(snd_control_info_t *obj, const char *val); + +void snd_control_info_set_index(snd_control_info_t *obj, unsigned int val); + +size_t snd_control_sizeof(); +#define snd_control_alloca(ptr) ({ assert(ptr); *ptr = (snd_control_t *) alloca(snd_control_sizeof()); memset(*ptr, 0, snd_control_sizeof()); 0; }) +int snd_control_malloc(snd_control_t **ptr); +void snd_control_free(snd_control_t *obj); +void snd_control_copy(snd_control_t *dst, const snd_control_t *src); + +void snd_control_get_id(const snd_control_t *obj, snd_control_id_t *ptr); + +unsigned int snd_control_get_numid(const snd_control_t *obj); + +snd_control_iface_t snd_control_get_interface(const snd_control_t *obj); + +unsigned int snd_control_get_device(const snd_control_t *obj); + +unsigned int snd_control_get_subdevice(const snd_control_t *obj); + +const char *snd_control_get_name(const snd_control_t *obj); + +unsigned int snd_control_get_index(const snd_control_t *obj); + +void snd_control_set_id(snd_control_t *obj, const snd_control_id_t *ptr); + +void snd_control_set_numid(snd_control_t *obj, unsigned int val); + +void snd_control_set_interface(snd_control_t *obj, snd_control_iface_t val); + +void snd_control_set_device(snd_control_t *obj, unsigned int val); + +void snd_control_set_subdevice(snd_control_t *obj, unsigned int val); + +void snd_control_set_name(snd_control_t *obj, const char *val); + +void snd_control_set_index(snd_control_t *obj, unsigned int val); + +long snd_control_get_boolean(const snd_control_t *obj, unsigned int idx); + +long snd_control_get_integer(const snd_control_t *obj, unsigned int idx); + +unsigned int snd_control_get_enumerated(const snd_control_t *obj, unsigned int idx); + +unsigned char snd_control_get_byte(const snd_control_t *obj, unsigned int idx); + +void snd_control_set_boolean(snd_control_t *obj, unsigned int idx, long val); + +void snd_control_set_integer(snd_control_t *obj, unsigned int idx, long val); + +void snd_control_set_enumerated(snd_control_t *obj, unsigned int idx, unsigned int val); + +void snd_control_set_byte(snd_control_t *obj, unsigned int idx, unsigned char val); + +const void * snd_control_get_bytes(const snd_control_t *obj); + +void snd_control_get_iec958(const snd_control_t *obj, snd_aes_iec958_t *ptr); + +void snd_control_set_iec958(snd_control_t *obj, const snd_aes_iec958_t *ptr); + +size_t snd_hcontrol_list_sizeof(); +#define snd_hcontrol_list_alloca(ptr) ({ assert(ptr); *ptr = (snd_hcontrol_list_t *) alloca(snd_hcontrol_list_sizeof()); memset(*ptr, 0, snd_hcontrol_list_sizeof()); 0; }) +int snd_hcontrol_list_malloc(snd_hcontrol_list_t **ptr); +void snd_hcontrol_list_free(snd_hcontrol_list_t *obj); +void snd_hcontrol_list_copy(snd_hcontrol_list_t *dst, const snd_hcontrol_list_t *src); + +void snd_hcontrol_list_set_offset(snd_hcontrol_list_t *obj, unsigned int val); + +unsigned int snd_hcontrol_list_get_used(const snd_hcontrol_list_t *obj); + +unsigned int snd_hcontrol_list_get_count(const snd_hcontrol_list_t *obj); + +void snd_hcontrol_list_get_id(const snd_hcontrol_list_t *obj, unsigned int idx, snd_control_id_t *ptr); + +unsigned int snd_hcontrol_list_get_numid(const snd_hcontrol_list_t *obj, unsigned int idx); + +snd_control_iface_t snd_hcontrol_list_get_interface(const snd_hcontrol_list_t *obj, unsigned int idx); + +unsigned int snd_hcontrol_list_get_device(const snd_hcontrol_list_t *obj, unsigned int idx); + +unsigned int snd_hcontrol_list_get_subdevice(const snd_hcontrol_list_t *obj, unsigned int idx); + +const char *snd_hcontrol_list_get_name(const snd_hcontrol_list_t *obj, unsigned int idx); + +unsigned int snd_hcontrol_list_get_index(const snd_hcontrol_list_t *obj, unsigned int idx); + +size_t snd_hcontrol_sizeof(); +#define snd_hcontrol_alloca(ptr) ({ assert(ptr); *ptr = (snd_hcontrol_t *) alloca(snd_hcontrol_sizeof()); memset(*ptr, 0, snd_hcontrol_sizeof()); 0; }) +int snd_hcontrol_malloc(snd_hcontrol_t **ptr); +void snd_hcontrol_free(snd_hcontrol_t *obj); +void snd_hcontrol_copy(snd_hcontrol_t *dst, const snd_hcontrol_t *src); + +void snd_hcontrol_get_id(const snd_hcontrol_t *obj, snd_control_id_t *ptr); + +unsigned int snd_hcontrol_get_numid(const snd_hcontrol_t *obj); + +snd_control_iface_t snd_hcontrol_get_interface(const snd_hcontrol_t *obj); + +unsigned int snd_hcontrol_get_device(const snd_hcontrol_t *obj); + +unsigned int snd_hcontrol_get_subdevice(const snd_hcontrol_t *obj); + +const char *snd_hcontrol_get_name(const snd_hcontrol_t *obj); + +unsigned int snd_hcontrol_get_index(const snd_hcontrol_t *obj); + +void snd_hcontrol_set_callback_change(snd_hcontrol_t *obj, snd_hcontrol_callback_t val); + +void snd_hcontrol_set_callback_value(snd_hcontrol_t *obj, snd_hcontrol_callback_t val); + +void snd_hcontrol_set_callback_remove(snd_hcontrol_t *obj, snd_hcontrol_callback_t val); + +void * snd_hcontrol_get_private_data(const snd_hcontrol_t *obj); + +void snd_hcontrol_set_private_data(snd_hcontrol_t *obj, void * val); + +void snd_hcontrol_set_private_free(snd_hcontrol_t *obj, snd_hcontrol_private_free_t val); + + +#ifdef __cplusplus +} +#endif diff --git a/include/global.h b/include/global.h index 1b69491b..a42e0b6a 100644 --- a/include/global.h +++ b/include/global.h @@ -10,7 +10,7 @@ #define SND_BIG_ENDIAN SNDRV_BIG_ENDIAN #endif -//#define SND_ENUM_TYPECHECK +#define SND_ENUM_TYPECHECK #ifdef SND_ENUM_TYPECHECK #define snd_enum_to_int(v) ((unsigned int)(unsigned long)(v)) @@ -22,19 +22,3 @@ #define snd_enum_incr(v) (++(v)) #endif -enum _snd_set_mode { - SND_CHANGE, - SND_TRY, - SND_TEST, -}; - -#ifdef SND_ENUM_TYPECHECK -typedef struct __snd_set_mode *snd_set_mode_t; -#else -typedef enum _snd_set_mode snd_set_mode_t; -#endif - -#define SND_CHANGE ((snd_set_mode_t) SND_CHANGE) -#define SND_TRY ((snd_set_mode_t) SND_TRY) -#define SND_TEST ((snd_set_mode_t) SND_TEST) - diff --git a/include/header.h b/include/header.h index f7356091..e2fa5efc 100644 --- a/include/header.h +++ b/include/header.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #ifndef ATTRIBUTE_UNUSED diff --git a/include/hwdep_m4.h b/include/hwdep_m4.h index dd02c4d0..19b5072c 100644 --- a/include/hwdep_m4.h +++ b/include/hwdep_m4.h @@ -3,7 +3,7 @@ extern "C" { #endif size_t snd_hwdep_info_sizeof(); -#define snd_hwdep_info_alloca(ptr) ({assert(ptr); *ptr = (snd_hwdep_info_t *) alloca(snd_hwdep_info_sizeof()); 0;}) +#define snd_hwdep_info_alloca(ptr) ({ assert(ptr); *ptr = (snd_hwdep_info_t *) alloca(snd_hwdep_info_sizeof()); memset(*ptr, 0, snd_hwdep_info_sizeof()); 0; }) int snd_hwdep_info_malloc(snd_hwdep_info_t **ptr); void snd_hwdep_info_free(snd_hwdep_info_t *obj); void snd_hwdep_info_copy(snd_hwdep_info_t *dst, const snd_hwdep_info_t *src); @@ -12,9 +12,9 @@ unsigned int snd_hwdep_info_get_device(const snd_hwdep_info_t *obj); int snd_hwdep_info_get_card(const snd_hwdep_info_t *obj); -const char * snd_hwdep_info_get_id(const snd_hwdep_info_t *obj); +const char *snd_hwdep_info_get_id(const snd_hwdep_info_t *obj); -const char * snd_hwdep_info_get_name(const snd_hwdep_info_t *obj); +const char *snd_hwdep_info_get_name(const snd_hwdep_info_t *obj); snd_hwdep_type_t snd_hwdep_info_get_type(const snd_hwdep_info_t *obj); diff --git a/include/local.h b/include/local.h index ecf16653..278aacc5 100644 --- a/include/local.h +++ b/include/local.h @@ -19,12 +19,22 @@ * */ +#ifndef __LOCAL_H +#define __LOCAL_H + #define _snd_interval sndrv_interval #define _snd_pcm_info sndrv_pcm_info #define _snd_pcm_hw_params sndrv_pcm_hw_params #define _snd_pcm_sw_params sndrv_pcm_sw_params #define _snd_pcm_status sndrv_pcm_status +#define _snd_ctl_info sndrv_ctl_info +#define _snd_control_id sndrv_control_id +#define _snd_control_list sndrv_control_list +#define _snd_control_info sndrv_control_info +#define _snd_control sndrv_control +#define _snd_ctl_event sndrv_ctl_event + #define _snd_rawmidi_info sndrv_rawmidi_info #define _snd_rawmidi_params sndrv_rawmidi_params #define _snd_rawmidi_status sndrv_rawmidi_status @@ -32,6 +42,7 @@ #define _snd_hwdep_info sndrv_hwdep_info #include "asoundlib.h" +#include #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) #define ERR(...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, __VA_ARGS__) @@ -41,3 +52,20 @@ #define SYSERR(args...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, errno, ##args) #endif +enum _snd_set_mode { + SND_CHANGE, + SND_TRY, + SND_TEST, +}; + +#ifdef SND_ENUM_TYPECHECK +typedef struct __snd_set_mode *snd_set_mode_t; +#else +typedef enum _snd_set_mode snd_set_mode_t; +#endif + +#define SND_CHANGE ((snd_set_mode_t) SND_CHANGE) +#define SND_TRY ((snd_set_mode_t) SND_TRY) +#define SND_TEST ((snd_set_mode_t) SND_TEST) + +#endif diff --git a/include/pcm.h b/include/pcm.h index 0c3687ca..d1054947 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -41,17 +41,23 @@ typedef enum sndrv_pcm_tstamp snd_pcm_tstamp_t; #define SND_PCM_CLASS_MULTI ((snd_pcm_class_t) SNDRV_PCM_CLASS_MULTI) #define SND_PCM_CLASS_MODEM ((snd_pcm_class_t) SNDRV_PCM_CLASS_MODEM) #define SND_PCM_CLASS_DIGITIZER ((snd_pcm_class_t) SNDRV_PCM_CLASS_DIGITIZER) +#define SND_PCM_CLASS_LAST ((snd_pcm_class_t) SNDRV_PCM_CLASS_LAST) + #define SND_PCM_SUBCLASS_GENERIC_MIX ((snd_pcm_subclass_t) SNDRV_PCM_SUBCLASS_GENERIC_MIX) #define SND_PCM_SUBCLASS_MULTI_MIX ((snd_pcm_subclass_t) SNDRV_PCM_SUBCLASS_MULTI_MIX) +#define SND_PCM_SUBCLASS_LAST ((snd_pcm_subclass_t) SNDRV_PCM_SUBCLASS_LAST) + #define SND_PCM_STREAM_PLAYBACK ((snd_pcm_stream_t) SNDRV_PCM_STREAM_PLAYBACK) #define SND_PCM_STREAM_CAPTURE ((snd_pcm_stream_t) SNDRV_PCM_STREAM_CAPTURE) #define SND_PCM_STREAM_LAST ((snd_pcm_stream_t) SNDRV_PCM_STREAM_LAST) + #define SND_PCM_ACCESS_MMAP_INTERLEAVED ((snd_pcm_access_t) SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) #define SND_PCM_ACCESS_MMAP_NONINTERLEAVED ((snd_pcm_access_t) SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED) #define SND_PCM_ACCESS_MMAP_COMPLEX ((snd_pcm_access_t) SNDRV_PCM_ACCESS_MMAP_COMPLEX) #define SND_PCM_ACCESS_RW_INTERLEAVED ((snd_pcm_access_t) SNDRV_PCM_ACCESS_RW_INTERLEAVED) #define SND_PCM_ACCESS_RW_NONINTERLEAVED ((snd_pcm_access_t) SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) #define SND_PCM_ACCESS_LAST ((snd_pcm_access_t) SNDRV_PCM_ACCESS_LAST) + #define SND_PCM_FORMAT_UNKNOWN ((snd_pcm_format_t) -1) #define SND_PCM_FORMAT_S8 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_S8) #define SND_PCM_FORMAT_U8 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_U8) @@ -98,8 +104,10 @@ typedef enum sndrv_pcm_tstamp snd_pcm_tstamp_t; #define SND_PCM_FORMAT_FLOAT ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT) #define SND_PCM_FORMAT_FLOAT64 ((snd_pcm_format_t) SNDRV_PCM_FORMAT_FLOAT64) #define SND_PCM_FORMAT_IEC958_SUBFRAME ((snd_pcm_format_t) SNDRV_PCM_FORMAT_IEC958_SUBFRAME) + #define SND_PCM_SUBFORMAT_STD ((snd_pcm_subformat_t) SNDRV_PCM_SUBFORMAT_STD) #define SND_PCM_SUBFORMAT_LAST ((snd_pcm_subformat_t) SNDRV_PCM_SUBFORMAT_LAST) + #define SND_PCM_STATE_OPEN ((snd_pcm_state_t) SNDRV_PCM_STATE_OPEN) #define SND_PCM_STATE_SETUP ((snd_pcm_state_t) SNDRV_PCM_STATE_SETUP) #define SND_PCM_STATE_PREPARED ((snd_pcm_state_t) SNDRV_PCM_STATE_PREPARED) @@ -108,12 +116,15 @@ typedef enum sndrv_pcm_tstamp snd_pcm_tstamp_t; #define SND_PCM_STATE_DRAINING ((snd_pcm_state_t) SNDRV_PCM_STATE_DRAINING) #define SND_PCM_STATE_PAUSED ((snd_pcm_state_t) SNDRV_PCM_STATE_PAUSED) #define SND_PCM_STATE_LAST ((snd_pcm_state_t) SNDRV_PCM_STATE_LAST) + #define SND_PCM_START_DATA ((snd_pcm_start_t) SNDRV_PCM_START_DATA) #define SND_PCM_START_EXPLICIT ((snd_pcm_start_t) SNDRV_PCM_START_EXPLICIT) #define SND_PCM_START_LAST ((snd_pcm_start_t) SNDRV_PCM_START_LAST) + #define SND_PCM_XRUN_NONE ((snd_pcm_xrun_t) SNDRV_PCM_XRUN_NONE) #define SND_PCM_XRUN_STOP ((snd_pcm_xrun_t) SNDRV_PCM_XRUN_STOP) #define SND_PCM_XRUN_LAST ((snd_pcm_xrun_t) SNDRV_PCM_XRUN_LAST) + #define SND_PCM_TSTAMP_NONE ((snd_pcm_tstamp_t) SNDRV_PCM_TSTAMP_NONE) #define SND_PCM_TSTAMP_MMAP ((snd_pcm_tstamp_t) SNDRV_PCM_TSTAMP_MMAP) #define SND_PCM_TSTAMP_LAST ((snd_pcm_tstamp_t) SNDRV_PCM_TSTAMP_LAST) @@ -200,7 +211,7 @@ typedef struct _snd_pcm_channel_area { extern "C" { #endif -int snd_pcm_open(snd_pcm_t **pcm, char *name, +int snd_pcm_open(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode); snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm); @@ -251,7 +262,6 @@ int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params, unsigned int *rate_num, unsigned int *rate_den); int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_get_flags(const snd_pcm_hw_params_t *params); int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params); int snd_pcm_hw_params_dump(snd_pcm_hw_params_t *params, snd_output_t *out); diff --git a/include/pcm_m4.h b/include/pcm_m4.h index bb7e4848..2089c805 100644 --- a/include/pcm_m4.h +++ b/include/pcm_m4.h @@ -3,8 +3,9 @@ extern "C" { #endif + size_t snd_pcm_access_mask_sizeof(); -#define snd_pcm_access_mask_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_access_mask_t *) alloca(snd_pcm_access_mask_sizeof()); 0;}) +#define snd_pcm_access_mask_alloca(ptr) ({ assert(ptr); *ptr = (snd_pcm_access_mask_t *) alloca(snd_pcm_access_mask_sizeof()); memset(*ptr, 0, snd_pcm_access_mask_sizeof()); 0; }) int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr); void snd_pcm_access_mask_free(snd_pcm_access_mask_t *obj); void snd_pcm_access_mask_copy(snd_pcm_access_mask_t *dst, const snd_pcm_access_mask_t *src); @@ -16,7 +17,7 @@ void snd_pcm_access_mask_set(snd_pcm_access_mask_t *mask, snd_pcm_access_t val); void snd_pcm_access_mask_reset(snd_pcm_access_mask_t *mask, snd_pcm_access_t val); size_t snd_pcm_format_mask_sizeof(); -#define snd_pcm_format_mask_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_format_mask_t *) alloca(snd_pcm_format_mask_sizeof()); 0;}) +#define snd_pcm_format_mask_alloca(ptr) ({ assert(ptr); *ptr = (snd_pcm_format_mask_t *) alloca(snd_pcm_format_mask_sizeof()); memset(*ptr, 0, snd_pcm_format_mask_sizeof()); 0; }) int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr); void snd_pcm_format_mask_free(snd_pcm_format_mask_t *obj); void snd_pcm_format_mask_copy(snd_pcm_format_mask_t *dst, const snd_pcm_format_mask_t *src); @@ -28,7 +29,7 @@ void snd_pcm_format_mask_set(snd_pcm_format_mask_t *mask, snd_pcm_format_t val); void snd_pcm_format_mask_reset(snd_pcm_format_mask_t *mask, snd_pcm_format_t val); size_t snd_pcm_subformat_mask_sizeof(); -#define snd_pcm_subformat_mask_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_subformat_mask_t *) alloca(snd_pcm_subformat_mask_sizeof()); 0;}) +#define snd_pcm_subformat_mask_alloca(ptr) ({ assert(ptr); *ptr = (snd_pcm_subformat_mask_t *) alloca(snd_pcm_subformat_mask_sizeof()); memset(*ptr, 0, snd_pcm_subformat_mask_sizeof()); 0; }) int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr); void snd_pcm_subformat_mask_free(snd_pcm_subformat_mask_t *obj); void snd_pcm_subformat_mask_copy(snd_pcm_subformat_mask_t *dst, const snd_pcm_subformat_mask_t *src); @@ -40,36 +41,40 @@ void snd_pcm_subformat_mask_set(snd_pcm_subformat_mask_t *mask, snd_pcm_subforma void snd_pcm_subformat_mask_reset(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val); size_t snd_pcm_hw_params_sizeof(); -#define snd_pcm_hw_params_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_hw_params_t *) alloca(snd_pcm_hw_params_sizeof()); 0;}) +#define snd_pcm_hw_params_alloca(ptr) ({ assert(ptr); *ptr = (snd_pcm_hw_params_t *) alloca(snd_pcm_hw_params_sizeof()); memset(*ptr, 0, snd_pcm_hw_params_sizeof()); 0; }) int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr); void snd_pcm_hw_params_free(snd_pcm_hw_params_t *obj); void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t *src); snd_pcm_access_t snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_access_t val); +int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val); +int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val); snd_pcm_access_t snd_pcm_hw_params_set_access_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); snd_pcm_access_t snd_pcm_hw_params_set_access_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_access_mask_t *mask); +int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask); snd_pcm_format_t snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_format_t val); +int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val); +int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val); snd_pcm_format_t snd_pcm_hw_params_set_format_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); snd_pcm_format_t snd_pcm_hw_params_set_format_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_format_mask_t *mask); +int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask); +int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val); snd_pcm_subformat_t snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_subformat_t val); +int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val); snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_subformat_mask_t *mask); +int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask); unsigned int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params); unsigned int snd_pcm_hw_params_get_channels_min(const snd_pcm_hw_params_t *params); unsigned int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val); -int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val); -int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val); -int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, unsigned int *max); +int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val); +int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val); +int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val); +int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val); +int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max); unsigned int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val); unsigned int snd_pcm_hw_params_set_channels_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); unsigned int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); @@ -77,10 +82,11 @@ unsigned int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_para unsigned int snd_pcm_hw_params_get_rate(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_rate_min(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, int *dir); -int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); -int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_rate_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +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); unsigned int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); unsigned int snd_pcm_hw_params_set_rate_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); @@ -88,10 +94,11 @@ unsigned int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t unsigned int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, int *dir); -int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); -int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_period_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +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); unsigned int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); unsigned int snd_pcm_hw_params_set_period_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); @@ -99,34 +106,37 @@ unsigned int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_p snd_pcm_uframes_t snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, int *dir); snd_pcm_uframes_t snd_pcm_hw_params_get_period_size_min(const snd_pcm_hw_params_t *params, int *dir); snd_pcm_uframes_t snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_t *params, int *dir); -int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t val, int dir); -int snd_pcm_hw_params_set_period_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val, int *dir); -int snd_pcm_hw_params_set_period_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val, int *dir); -int snd_pcm_hw_params_set_period_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *min, int *mindir, snd_pcm_uframes_t *max, int *maxdir); +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); +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); +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); +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); +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); snd_pcm_uframes_t 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); snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); -int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode); +int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); unsigned int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_periods_min(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params, int *dir); -int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); -int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_periods_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +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); unsigned int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); unsigned int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); -int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode); +int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); unsigned int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_buffer_time_min(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *params, int *dir); -int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); -int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_buffer_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +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); unsigned int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); unsigned int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); @@ -134,10 +144,11 @@ unsigned int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_p snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params); snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size_min(const snd_pcm_hw_params_t *params); snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params); -int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t val); -int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val); -int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val); -int snd_pcm_hw_params_set_buffer_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *min, snd_pcm_uframes_t *max); +int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val); +int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val); +int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val); +int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val); +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); snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val); snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); @@ -145,16 +156,17 @@ snd_pcm_uframes_t snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm unsigned int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, int *dir); -int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir); -int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir); -int snd_pcm_hw_params_set_tick_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir); +int snd_pcm_hw_params_test_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir); +int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir); +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); unsigned int snd_pcm_hw_params_set_tick_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir); unsigned int snd_pcm_hw_params_set_tick_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); unsigned int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir); size_t snd_pcm_sw_params_sizeof(); -#define snd_pcm_sw_params_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_sw_params_t *) alloca(snd_pcm_sw_params_sizeof()); 0;}) +#define snd_pcm_sw_params_alloca(ptr) ({ assert(ptr); *ptr = (snd_pcm_sw_params_t *) alloca(snd_pcm_sw_params_sizeof()); memset(*ptr, 0, snd_pcm_sw_params_sizeof()); 0; }) int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr); void snd_pcm_sw_params_free(snd_pcm_sw_params_t *obj); void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src); @@ -186,8 +198,26 @@ snd_pcm_uframes_t snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_param int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val); snd_pcm_uframes_t snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params); +size_t snd_pcm_status_sizeof(); +#define snd_pcm_status_alloca(ptr) ({ assert(ptr); *ptr = (snd_pcm_status_t *) alloca(snd_pcm_status_sizeof()); memset(*ptr, 0, snd_pcm_status_sizeof()); 0; }) +int snd_pcm_status_malloc(snd_pcm_status_t **ptr); +void snd_pcm_status_free(snd_pcm_status_t *obj); +void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src); + +snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj); + +void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr); + +void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr); + +snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj); + +snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj); + +snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj); + size_t snd_pcm_info_sizeof(); -#define snd_pcm_info_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_info_t *) alloca(snd_pcm_info_sizeof()); 0;}) +#define snd_pcm_info_alloca(ptr) ({ assert(ptr); *ptr = (snd_pcm_info_t *) alloca(snd_pcm_info_sizeof()); memset(*ptr, 0, snd_pcm_info_sizeof()); 0; }) int snd_pcm_info_malloc(snd_pcm_info_t **ptr); void snd_pcm_info_free(snd_pcm_info_t *obj); void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src); @@ -200,11 +230,11 @@ snd_pcm_stream_t snd_pcm_info_get_stream(const snd_pcm_info_t *obj); int snd_pcm_info_get_card(const snd_pcm_info_t *obj); -const char * snd_pcm_info_get_id(const snd_pcm_info_t *obj); +const char *snd_pcm_info_get_id(const snd_pcm_info_t *obj); -const char * snd_pcm_info_get_name(const snd_pcm_info_t *obj); +const char *snd_pcm_info_get_name(const snd_pcm_info_t *obj); -const char * snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj); +const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj); snd_pcm_class_t snd_pcm_info_get_class(const snd_pcm_info_t *obj); @@ -220,24 +250,6 @@ void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val); void snd_pcm_info_set_stream(snd_pcm_info_t *obj, snd_pcm_stream_t val); -size_t snd_pcm_status_sizeof(); -#define snd_pcm_status_alloca(ptr) ({assert(ptr); *ptr = (snd_pcm_status_t *) alloca(snd_pcm_status_sizeof()); 0;}) -int snd_pcm_status_malloc(snd_pcm_status_t **ptr); -void snd_pcm_status_free(snd_pcm_status_t *obj); -void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src); - -snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj); - -void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr); - -void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr); - -snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj); - -snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj); - -snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj); - #ifdef __cplusplus } diff --git a/include/rawmidi.h b/include/rawmidi.h index dbcb8b42..20aa7db5 100644 --- a/include/rawmidi.h +++ b/include/rawmidi.h @@ -17,6 +17,7 @@ typedef enum sndrv_rawmidi_stream snd_rawmidi_stream_t; #define SND_RAWMIDI_STREAM_OUTPUT ((snd_rawmidi_stream_t) SNDRV_RAWMIDI_STREAM_OUTPUT) #define SND_RAWMIDI_STREAM_INPUT ((snd_rawmidi_stream_t) SNDRV_RAWMIDI_STREAM_INPUT) +#define SND_RAWMIDI_STREAM_LAST ((snd_rawmidi_stream_t) SNDRV_RAWMIDI_STREAM_LAST) #define SND_RAWMIDI_INFO_OUTPUT SNDRV_RAWMIDI_INFO_OUTPUT #define SND_RAWMIDI_INFO_INPUT SNDRV_RAWMIDI_INFO_INPUT diff --git a/include/rawmidi_m4.h b/include/rawmidi_m4.h index 5d5e9e37..7c40c97e 100644 --- a/include/rawmidi_m4.h +++ b/include/rawmidi_m4.h @@ -3,7 +3,7 @@ extern "C" { #endif size_t snd_rawmidi_params_sizeof(); -#define snd_rawmidi_params_alloca(ptr) ({assert(ptr); *ptr = (snd_rawmidi_params_t *) alloca(snd_rawmidi_params_sizeof()); 0;}) +#define snd_rawmidi_params_alloca(ptr) ({ assert(ptr); *ptr = (snd_rawmidi_params_t *) alloca(snd_rawmidi_params_sizeof()); memset(*ptr, 0, snd_rawmidi_params_sizeof()); 0; }) int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr); void snd_rawmidi_params_free(snd_rawmidi_params_t *obj); void snd_rawmidi_params_copy(snd_rawmidi_params_t *dst, const snd_rawmidi_params_t *src); @@ -18,7 +18,7 @@ int snd_rawmidi_params_set_no_active_sensing(snd_rawmidi_t *rmidi, snd_rawmidi_p int snd_rawmidi_params_get_no_active_sensing(const snd_rawmidi_params_t *params); size_t snd_rawmidi_info_sizeof(); -#define snd_rawmidi_info_alloca(ptr) ({assert(ptr); *ptr = (snd_rawmidi_info_t *) alloca(snd_rawmidi_info_sizeof()); 0;}) +#define snd_rawmidi_info_alloca(ptr) ({ assert(ptr); *ptr = (snd_rawmidi_info_t *) alloca(snd_rawmidi_info_sizeof()); memset(*ptr, 0, snd_rawmidi_info_sizeof()); 0; }) int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr); void snd_rawmidi_info_free(snd_rawmidi_info_t *obj); void snd_rawmidi_info_copy(snd_rawmidi_info_t *dst, const snd_rawmidi_info_t *src); @@ -33,11 +33,11 @@ int snd_rawmidi_info_get_card(const snd_rawmidi_info_t *obj); unsigned int snd_rawmidi_info_get_flags(const snd_rawmidi_info_t *obj); -const char * snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj); +const char *snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj); -const char * snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj); +const char *snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj); -const char * snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj); +const char *snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj); unsigned int snd_rawmidi_info_get_subdevices_count(const snd_rawmidi_info_t *obj); @@ -50,7 +50,7 @@ void snd_rawmidi_info_set_subdevice(snd_rawmidi_info_t *obj, unsigned int val); void snd_rawmidi_info_set_stream(snd_rawmidi_info_t *obj, snd_rawmidi_stream_t val); size_t snd_rawmidi_status_sizeof(); -#define snd_rawmidi_status_alloca(ptr) ({assert(ptr); *ptr = (snd_rawmidi_status_t *) alloca(snd_rawmidi_status_sizeof()); 0;}) +#define snd_rawmidi_status_alloca(ptr) ({ assert(ptr); *ptr = (snd_rawmidi_status_t *) alloca(snd_rawmidi_status_sizeof()); memset(*ptr, 0, snd_rawmidi_status_sizeof()); 0; }) int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr); void snd_rawmidi_status_free(snd_rawmidi_status_t *obj); void snd_rawmidi_status_copy(snd_rawmidi_status_t *dst, const snd_rawmidi_status_t *src); diff --git a/include/timer.h b/include/timer.h index f88623b8..f146f909 100644 --- a/include/timer.h +++ b/include/timer.h @@ -25,10 +25,13 @@ typedef enum sndrv_timer_slave_type snd_timer_slave_type_t; #define SND_TIMER_TYPE_GLOBAL ((snd_timer_type_t) SNDRV_TIMER_TYPE_GLOBAL) #define SND_TIMER_TYPE_CARD ((snd_timer_type_t) SNDRV_TIMER_TYPE_CARD) #define SND_TIMER_TYPE_PCM ((snd_timer_type_t) SNDRV_TIMER_TYPE_PCM) +#define SND_TIMER_TYPE_LAST ((snd_timer_type_t) SNDRV_TIMER_TYPE_LAST) + #define SND_TIMER_STYPE_NONE ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_NONE #define SND_TIMER_STYPE_APPLICATION ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_APPLICATION #define SND_TIMER_STYPE_SEQUENCER ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_SEQUENCER #define SND_TIMER_STYPE_OSS_SEQUENCER ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_OSS_SEQUENCER +#define SND_TIMER_STYPE_LAST ((snd_timer_slave_type_t) SNDRV_TIMER_STYPE_LAST #define SND_TIMER_GLOBAL_SYSTEM SNDRV_TIMER_GLOBAL_SYSTEM #define SND_TIMER_GLOBAL_RTC SNDRV_TIMER_GLOBAL_RTC diff --git a/src/conf.c b/src/conf.c index db0b5c99..82077e4c 100644 --- a/src/conf.c +++ b/src/conf.c @@ -19,8 +19,6 @@ * */ -#include -#include #include #include #include "local.h" @@ -355,7 +353,7 @@ static int _snd_config_make_add(snd_config_t **config, char *id, return 0; } -static int _snd_config_search(snd_config_t *config, char *id, int len, snd_config_t **result) +static int _snd_config_search(snd_config_t *config, const char *id, int len, snd_config_t **result) { snd_config_iterator_t i; snd_config_foreach(i, config) { @@ -679,7 +677,7 @@ int snd_config_delete(snd_config_t *config) return 0; } -int snd_config_make(snd_config_t **config, char *id, +int snd_config_make(snd_config_t **config, const char *id, snd_config_type_t type) { char *id1; @@ -693,22 +691,22 @@ int snd_config_make(snd_config_t **config, char *id, return _snd_config_make(config, id1, type); } -int snd_config_integer_make(snd_config_t **config, char *id) +int snd_config_integer_make(snd_config_t **config, const char *id) { return snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER); } -int snd_config_real_make(snd_config_t **config, char *id) +int snd_config_real_make(snd_config_t **config, const char *id) { return snd_config_make(config, id, SND_CONFIG_TYPE_REAL); } -int snd_config_string_make(snd_config_t **config, char *id) +int snd_config_string_make(snd_config_t **config, const char *id) { return snd_config_make(config, id, SND_CONFIG_TYPE_STRING); } -int snd_config_compound_make(snd_config_t **config, char *id, +int snd_config_compound_make(snd_config_t **config, const char *id, int join) { int err; @@ -737,7 +735,7 @@ int snd_config_real_set(snd_config_t *config, double value) return 0; } -int snd_config_string_set(snd_config_t *config, char *value) +int snd_config_string_set(snd_config_t *config, const char *value) { assert(config); if (config->type != SND_CONFIG_TYPE_STRING) @@ -750,29 +748,6 @@ int snd_config_string_set(snd_config_t *config, char *value) return 0; } -int snd_config_set(snd_config_t *config, ...) -{ - va_list arg; - va_start(arg, config); - assert(config); - switch (snd_enum_to_int(config->type)) { - case SND_CONFIG_TYPE_INTEGER: - config->u.integer = va_arg(arg, long); - break; - case SND_CONFIG_TYPE_REAL: - config->u.real = va_arg(arg, double); - break; - case SND_CONFIG_TYPE_STRING: - config->u.string = va_arg(arg, char *); - break; - default: - assert(0); - return -EINVAL; - } - va_end(arg); - return 0; -} - int snd_config_integer_get(snd_config_t *config, long *ptr) { assert(config && ptr); @@ -791,7 +766,7 @@ int snd_config_real_get(snd_config_t *config, double *ptr) return 0; } -int snd_config_string_get(snd_config_t *config, char **ptr) +int snd_config_string_get(snd_config_t *config, const char **ptr) { assert(config && ptr); if (config->type != SND_CONFIG_TYPE_STRING) @@ -800,26 +775,6 @@ int snd_config_string_get(snd_config_t *config, char **ptr) return 0; } -int snd_config_get(snd_config_t *config, void *ptr) -{ - assert(config && ptr); - switch (snd_enum_to_int(config->type)) { - case SND_CONFIG_TYPE_INTEGER: - * (long*) ptr = config->u.integer; - break; - case SND_CONFIG_TYPE_REAL: - * (double*) ptr = config->u.real; - break; - case SND_CONFIG_TYPE_STRING: - * (char **) ptr = config->u.string; - break; - default: - assert(0); - return -EINVAL; - } - return 0; -} - void string_print(char *str, int id, snd_output_t *out) { unsigned char *p = str; @@ -980,13 +935,13 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) return _snd_config_save_leaves(config, out, 0, 0); } -int snd_config_search(snd_config_t *config, char *key, snd_config_t **result) +int snd_config_search(snd_config_t *config, const char *key, snd_config_t **result) { assert(config && key && result); while (1) { snd_config_t *n; int err; - char *p = strchr(key, '.'); + const char *p = strchr(key, '.'); if (config->type != SND_CONFIG_TYPE_COMPOUND) return -ENOENT; if (p) { @@ -1008,7 +963,7 @@ int snd_config_searchv(snd_config_t *config, assert(config && result); va_start(arg, result); while (1) { - char *k = va_arg(arg, char *); + const char *k = va_arg(arg, const char *); int err; if (!k) break; diff --git a/src/control/Makefile.am b/src/control/Makefile.am index 4bfbf260..1c358b5c 100644 --- a/src/control/Makefile.am +++ b/src/control/Makefile.am @@ -1,7 +1,7 @@ EXTRA_LTLIBRARIES = libcontrol.la libcontrol_la_SOURCES = cards.c controls.c bag.c defaults.c \ - control.c control_hw.c control_shm.c + control.c control_m4.c control_hw.c control_shm.c all: libcontrol.la diff --git a/src/control/bag.c b/src/control/bag.c index 88d0387b..e143a23c 100644 --- a/src/control/bag.c +++ b/src/control/bag.c @@ -23,10 +23,8 @@ #include #include #include -#include #include #include -#include #define __USE_GNU #include #include "control_local.h" diff --git a/src/control/cards.c b/src/control/cards.c index 3a3742e8..0510994f 100644 --- a/src/control/cards.c +++ b/src/control/cards.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -73,7 +72,7 @@ int snd_card_get_index(const char *string) { int card; snd_ctl_t *handle; - snd_ctl_hw_info_t info; + snd_ctl_info_t info; if (!string || *string == '\0') return -EINVAL; @@ -91,7 +90,7 @@ int snd_card_get_index(const char *string) continue; if (snd_ctl_hw_open(&handle, NULL, card) < 0) continue; - if (snd_ctl_hw_info(handle, &info) < 0) { + if (snd_ctl_info(handle, &info) < 0) { snd_ctl_close(handle); continue; } @@ -105,14 +104,14 @@ int snd_card_get_index(const char *string) int snd_card_get_name(int card, char **name) { snd_ctl_t *handle; - snd_ctl_hw_info_t info; + snd_ctl_info_t info; int err; if (name == NULL) return -EINVAL; if ((err = snd_ctl_hw_open(&handle, NULL, card)) < 0) return err; - if ((err = snd_ctl_hw_info(handle, &info)) < 0) { + if ((err = snd_ctl_info(handle, &info)) < 0) { snd_ctl_close(handle); return err; } @@ -126,14 +125,14 @@ int snd_card_get_name(int card, char **name) int snd_card_get_longname(int card, char **name) { snd_ctl_t *handle; - snd_ctl_hw_info_t info; + snd_ctl_info_t info; int err; if (name == NULL) return -EINVAL; if ((err = snd_ctl_hw_open(&handle, NULL, card)) < 0) return err; - if ((err = snd_ctl_hw_info(handle, &info)) < 0) { + if ((err = snd_ctl_info(handle, &info)) < 0) { snd_ctl_close(handle); return err; } diff --git a/src/control/control.c b/src/control/control.c index b0a2b049..ce856d38 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -24,9 +24,7 @@ #include #include #include -#include #include -#include #include #include "control_local.h" @@ -50,7 +48,7 @@ int snd_ctl_poll_descriptor(snd_ctl_t *ctl) return ctl->ops->poll_descriptor(ctl); } -int snd_ctl_hw_info(snd_ctl_t *ctl, snd_ctl_hw_info_t *info) +int snd_ctl_info(snd_ctl_t *ctl, snd_ctl_info_t *info) { assert(ctl && info); return ctl->ops->hw_info(ctl, info); @@ -175,11 +173,11 @@ int snd_ctl_read(snd_ctl_t *ctl, snd_ctl_callbacks_t * callbacks) int snd_ctl_open(snd_ctl_t **ctlp, char *name) { - char *str; + const char *str; int err; snd_config_t *ctl_conf, *conf, *type_conf; snd_config_iterator_t i; - char *lib = NULL, *open = NULL; + const char *lib = NULL, *open = NULL; int (*open_func)(snd_ctl_t **ctlp, char *name, snd_config_t *conf); void *h; assert(ctlp && name); @@ -240,3 +238,75 @@ int snd_ctl_open(snd_ctl_t **ctlp, char *name) return open_func(ctlp, name, ctl_conf); } +void snd_control_set_bytes(snd_control_t *obj, void *data, size_t size) +{ + assert(obj); + assert(size <= sizeof(obj->value.bytes.data)); + memcpy(obj->value.bytes.data, data, size); +} + +#define TYPE(v) [SND_CONTROL_TYPE_##v] = #v +#define IFACE(v) [SND_CONTROL_IFACE_##v] = #v +#define EVENT(v) [SND_CTL_EVENT_##v] = #v + +const char *snd_control_type_names[] = { + TYPE(NONE), + TYPE(BOOLEAN), + TYPE(INTEGER), + TYPE(ENUMERATED), + TYPE(BYTES), + TYPE(IEC958), +}; + +const char *snd_control_iface_names[] = { + IFACE(CARD), + IFACE(HWDEP), + IFACE(MIXER), + IFACE(PCM), + IFACE(RAWMIDI), + IFACE(TIMER), + IFACE(SEQUENCER), +}; + +const char *snd_ctl_event_type_names[] = { + EVENT(REBUILD), + EVENT(VALUE), + EVENT(CHANGE), + EVENT(ADD), + EVENT(REMOVE), +}; + +const char *snd_control_type_name(snd_control_type_t type) +{ + assert(type <= SND_CONTROL_TYPE_LAST); + return snd_control_type_names[snd_enum_to_int(type)]; +} + +const char *snd_control_iface_name(snd_control_iface_t iface) +{ + assert(iface <= SND_CONTROL_IFACE_LAST); + return snd_control_iface_names[snd_enum_to_int(iface)]; +} + +const char *snd_ctl_event_type_name(snd_ctl_event_type_t type) +{ + assert(type <= SND_CTL_EVENT_LAST); + return snd_ctl_event_type_names[snd_enum_to_int(type)]; +} + +int snd_control_list_alloc_space(snd_control_list_t *obj, unsigned int entries) +{ + obj->pids = calloc(entries, sizeof(*obj->pids)); + if (!obj->pids) { + obj->space = 0; + return -ENOMEM; + } + obj->space = entries; + return 0; +} + +void snd_control_list_free_space(snd_control_list_t *obj) +{ + free(obj->pids); + obj->pids = NULL; +} diff --git a/src/control/control_hw.c b/src/control/control_hw.c index bd0552e0..cc51b478 100644 --- a/src/control/control_hw.c +++ b/src/control/control_hw.c @@ -24,10 +24,8 @@ #include #include #include -#include #include #include -#include #include "control_local.h" #define SNDRV_FILE_CONTROL "/dev/snd/controlC%i" @@ -53,10 +51,10 @@ static int snd_ctl_hw_poll_descriptor(snd_ctl_t *handle) return hw->fd; } -static int snd_ctl_hw_hw_info(snd_ctl_t *handle, snd_ctl_hw_info_t *info) +static int snd_ctl_hw_hw_info(snd_ctl_t *handle, snd_ctl_info_t *info) { snd_ctl_hw_t *hw = handle->private; - if (ioctl(hw->fd, SNDRV_CTL_IOCTL_HW_INFO, info) < 0) + if (ioctl(hw->fd, SNDRV_CTL_IOCTL_INFO, info) < 0) return -errno; return 0; } @@ -182,7 +180,7 @@ snd_ctl_ops_t snd_ctl_hw_ops = { read: snd_ctl_hw_read, }; -int snd_ctl_hw_open(snd_ctl_t **handle, char *name, int card) +int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card) { int fd, ver; char filename[32]; @@ -234,7 +232,7 @@ int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *conf) { snd_config_iterator_t i; long card = -1; - char *str; + const char *str; int err; snd_config_foreach(i, conf) { snd_config_t *n = snd_config_entry(i); diff --git a/src/control/control_local.h b/src/control/control_local.h index f4953c97..b2b07af9 100644 --- a/src/control/control_local.h +++ b/src/control/control_local.h @@ -19,14 +19,13 @@ * */ -#include #include "local.h" #include "list.h" -typedef struct { +typedef struct _snd_ctl_ops { int (*close)(snd_ctl_t *handle); int (*poll_descriptor)(snd_ctl_t *handle); - int (*hw_info)(snd_ctl_t *handle, snd_ctl_hw_info_t *info); + int (*hw_info)(snd_ctl_t *handle, snd_ctl_info_t *info); int (*clist)(snd_ctl_t *handle, snd_control_list_t *list); int (*cinfo)(snd_ctl_t *handle, snd_control_info_t *info); int (*cread)(snd_ctl_t *handle, snd_control_t *control); @@ -53,12 +52,46 @@ struct _snd_ctl { struct list_head hlist; /* list of all controls */ void *hroot; /* root of controls */ void *hroot_new; /* new croot */ - snd_ctl_hsort_t *hsort; - snd_ctl_hcallback_rebuild_t *callback_rebuild; + snd_ctl_hsort_t hsort; + snd_ctl_hcallback_rebuild_t callback_rebuild; void *callback_rebuild_private_data; - snd_ctl_hcallback_add_t *callback_add; + snd_ctl_hcallback_add_t callback_add; void *callback_add_private_data; }; -int snd_ctl_hw_open(snd_ctl_t **handle, char *name, int card); -int snd_ctl_shm_open(snd_ctl_t **handlep, char *name, char *socket, char *sname); +struct _snd_ctl_callbacks { + void *private_data; /* may be used by an application */ + void (*rebuild) (snd_ctl_t *handle, void *private_data); + void (*value) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id); + void (*change) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id); + void (*add) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id); + void (*remove) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id); + void *reserved[58]; /* reserved for the future use - must be NULL!!! */ +}; + +struct _snd_hcontrol_list { + unsigned int offset; /* W: first control ID to get */ + unsigned int space; /* W: count of control IDs to get */ + unsigned int used; /* R: count of available (set) controls */ + unsigned int count; /* R: count of all available controls */ + snd_control_id_t *pids; /* W: IDs */ +}; + +struct _snd_hcontrol { + snd_control_id_t id; /* must be always on top */ + struct list_head list; /* links for list of all hcontrols */ + int change: 1, /* structure change */ + value: 1; /* value change */ + /* event callbacks */ + snd_hcontrol_callback_t callback_change; + snd_hcontrol_callback_t callback_value; + snd_hcontrol_callback_t callback_remove; + /* private data */ + void *private_data; + snd_hcontrol_private_free_t private_free; + /* links */ + snd_ctl_t *handle; /* associated handle */ +}; + +int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card); +int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, const char *sname); diff --git a/src/control/control_m4.c b/src/control/control_m4.c new file mode 100644 index 00000000..99403ca8 --- /dev/null +++ b/src/control/control_m4.c @@ -0,0 +1,937 @@ +/* + * Control - Automatically generated functions + * Copyright (c) 2001 by Abramo Bagnara + * + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "control_local.h" + +size_t snd_control_id_sizeof() +{ + return sizeof(snd_control_id_t); +} + +int snd_control_id_malloc(snd_control_id_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_control_id_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_control_id_free(snd_control_id_t *obj) +{ + free(obj); +} + +void snd_control_id_copy(snd_control_id_t *dst, const snd_control_id_t *src) +{ + assert(dst && src); + *dst = *src; +} + +unsigned int snd_control_id_get_numid(const snd_control_id_t *obj) +{ + assert(obj); + return obj->numid; +} + +snd_control_iface_t snd_control_id_get_interface(const snd_control_id_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->iface); +} + +unsigned int snd_control_id_get_device(const snd_control_id_t *obj) +{ + assert(obj); + return obj->device; +} + +unsigned int snd_control_id_get_subdevice(const snd_control_id_t *obj) +{ + assert(obj); + return obj->subdevice; +} + +const char *snd_control_id_get_name(const snd_control_id_t *obj) +{ + assert(obj); + return obj->name; +} + +unsigned int snd_control_id_get_index(const snd_control_id_t *obj) +{ + assert(obj); + return obj->index; +} + +void snd_control_id_set_numid(snd_control_id_t *obj, unsigned int val) +{ + assert(obj); + obj->numid = val; +} + +void snd_control_id_set_interface(snd_control_id_t *obj, snd_control_iface_t val) +{ + assert(obj); + obj->iface = snd_enum_to_int(val); +} + +void snd_control_id_set_device(snd_control_id_t *obj, unsigned int val) +{ + assert(obj); + obj->device = val; +} + +void snd_control_id_set_subdevice(snd_control_id_t *obj, unsigned int val) +{ + assert(obj); + obj->subdevice = val; +} + +void snd_control_id_set_name(snd_control_id_t *obj, const char *val) +{ + assert(obj); + strncpy(obj->name, val, sizeof(obj->name)); +} + +void snd_control_id_set_index(snd_control_id_t *obj, unsigned int val) +{ + assert(obj); + obj->index = val; +} + +size_t snd_ctl_info_sizeof() +{ + return sizeof(snd_ctl_info_t); +} + +int snd_ctl_info_malloc(snd_ctl_info_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_ctl_info_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_ctl_info_free(snd_ctl_info_t *obj) +{ + free(obj); +} + +void snd_ctl_info_copy(snd_ctl_info_t *dst, const snd_ctl_info_t *src) +{ + assert(dst && src); + *dst = *src; +} + +int snd_ctl_info_get_card(const snd_ctl_info_t *obj) +{ + assert(obj); + return obj->card; +} + +snd_card_type_t snd_ctl_info_get_type(const snd_ctl_info_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->type); +} + +const char *snd_ctl_info_get_id(const snd_ctl_info_t *obj) +{ + assert(obj); + return obj->id; +} + +const char *snd_ctl_info_get_abbreviation(const snd_ctl_info_t *obj) +{ + assert(obj); + return obj->abbreviation; +} + +const char *snd_ctl_info_get_name(const snd_ctl_info_t *obj) +{ + assert(obj); + return obj->name; +} + +const char *snd_ctl_info_get_longname(const snd_ctl_info_t *obj) +{ + assert(obj); + return obj->longname; +} + +const char *snd_ctl_info_get_mixerid(const snd_ctl_info_t *obj) +{ + assert(obj); + return obj->mixerid; +} + +const char *snd_ctl_info_get_mixername(const snd_ctl_info_t *obj) +{ + assert(obj); + return obj->mixername; +} + +size_t snd_ctl_event_sizeof() +{ + return sizeof(snd_ctl_event_t); +} + +int snd_ctl_event_malloc(snd_ctl_event_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_ctl_event_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_ctl_event_free(snd_ctl_event_t *obj) +{ + free(obj); +} + +void snd_ctl_event_copy(snd_ctl_event_t *dst, const snd_ctl_event_t *src) +{ + assert(dst && src); + *dst = *src; +} + +snd_ctl_event_type_t snd_ctl_event_get_type(const snd_ctl_event_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->type); +} + +unsigned int snd_ctl_event_get_numid(const snd_ctl_event_t *obj) +{ + assert(obj); + assert(obj->type != SNDRV_CTL_EVENT_REBUILD); + return obj->data.id.numid; +} + +void snd_ctl_event_get_id(const snd_ctl_event_t *obj, snd_control_id_t *ptr) +{ + assert(obj && ptr); + assert(obj->type != SNDRV_CTL_EVENT_REBUILD); + *ptr = obj->data.id; +} + +snd_control_iface_t snd_ctl_event_get_interface(const snd_ctl_event_t *obj) +{ + assert(obj); + assert(obj->type != SNDRV_CTL_EVENT_REBUILD); + return snd_int_to_enum(obj->data.id.iface); +} + +unsigned int snd_ctl_event_get_device(const snd_ctl_event_t *obj) +{ + assert(obj); + assert(obj->type != SNDRV_CTL_EVENT_REBUILD); + return obj->data.id.device; +} + +unsigned int snd_ctl_event_get_subdevice(const snd_ctl_event_t *obj) +{ + assert(obj); + assert(obj->type != SNDRV_CTL_EVENT_REBUILD); + return obj->data.id.subdevice; +} + +const char *snd_ctl_event_get_name(const snd_ctl_event_t *obj) +{ + assert(obj); + assert(obj->type != SNDRV_CTL_EVENT_REBUILD); + return obj->data.id.name; +} + +unsigned int snd_ctl_event_get_index(const snd_ctl_event_t *obj) +{ + assert(obj); + assert(obj->type != SNDRV_CTL_EVENT_REBUILD); + return obj->data.id.index; +} + +size_t snd_control_list_sizeof() +{ + return sizeof(snd_control_list_t); +} + +int snd_control_list_malloc(snd_control_list_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_control_list_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_control_list_free(snd_control_list_t *obj) +{ + free(obj); +} + +void snd_control_list_copy(snd_control_list_t *dst, const snd_control_list_t *src) +{ + assert(dst && src); + *dst = *src; +} + +void snd_control_list_set_offset(snd_control_list_t *obj, unsigned int val) +{ + assert(obj); + obj->offset = val; +} + +unsigned int snd_control_list_get_used(const snd_control_list_t *obj) +{ + assert(obj); + return obj->used; +} + +unsigned int snd_control_list_get_count(const snd_control_list_t *obj) +{ + assert(obj); + return obj->count; +} + +void snd_control_list_get_id(const snd_control_list_t *obj, unsigned int idx, snd_control_id_t *ptr) +{ + assert(obj && ptr); + assert(idx < obj->used); + *ptr = obj->pids[idx]; +} + +unsigned int snd_control_list_get_numid(const snd_control_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].numid; +} + +snd_control_iface_t snd_control_list_get_interface(const snd_control_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return snd_int_to_enum(obj->pids[idx].iface); +} + +unsigned int snd_control_list_get_device(const snd_control_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].device; +} + +unsigned int snd_control_list_get_subdevice(const snd_control_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].subdevice; +} + +const char *snd_control_list_get_name(const snd_control_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].name; +} + +unsigned int snd_control_list_get_index(const snd_control_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].index; +} + +size_t snd_control_info_sizeof() +{ + return sizeof(snd_control_info_t); +} + +int snd_control_info_malloc(snd_control_info_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_control_info_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_control_info_free(snd_control_info_t *obj) +{ + free(obj); +} + +void snd_control_info_copy(snd_control_info_t *dst, const snd_control_info_t *src) +{ + assert(dst && src); + *dst = *src; +} + +snd_control_type_t snd_control_info_get_type(const snd_control_info_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->type); +} + +int snd_control_info_is_readable(const snd_control_info_t *obj) +{ + assert(obj); + return !!(obj->access & SNDRV_CONTROL_ACCESS_READ); +} + +int snd_control_info_is_writable(const snd_control_info_t *obj) +{ + assert(obj); + return !!(obj->access & SNDRV_CONTROL_ACCESS_WRITE); +} + +int snd_control_info_is_volatile(const snd_control_info_t *obj) +{ + assert(obj); + return !!(obj->access & SNDRV_CONTROL_ACCESS_VOLATILE); +} + +int snd_control_info_is_inactive(const snd_control_info_t *obj) +{ + assert(obj); + return !!(obj->access & SNDRV_CONTROL_ACCESS_INACTIVE); +} + +int snd_control_info_is_locked(const snd_control_info_t *obj) +{ + assert(obj); + return !!(obj->access & SNDRV_CONTROL_ACCESS_LOCK); +} + +int snd_control_info_is_indirect(const snd_control_info_t *obj) +{ + assert(obj); + return !!(obj->access & SNDRV_CONTROL_ACCESS_INDIRECT); +} + +unsigned int snd_control_info_get_count(const snd_control_info_t *obj) +{ + assert(obj); + return obj->count; +} + +long snd_control_info_get_min(const snd_control_info_t *obj) +{ + assert(obj); + assert(obj->type == SNDRV_CONTROL_TYPE_INTEGER); + return obj->value.integer.min; +} + +long snd_control_info_get_max(const snd_control_info_t *obj) +{ + assert(obj); + assert(obj->type == SNDRV_CONTROL_TYPE_INTEGER); + return obj->value.integer.max; +} + +long snd_control_info_get_step(const snd_control_info_t *obj) +{ + assert(obj); + assert(obj->type == SNDRV_CONTROL_TYPE_INTEGER); + return obj->value.integer.step; +} + +unsigned int snd_control_info_get_items(const snd_control_info_t *obj) +{ + assert(obj); + assert(obj->type == SNDRV_CONTROL_TYPE_ENUMERATED); + return obj->value.enumerated.items; +} + +void snd_control_info_set_item(snd_control_info_t *obj, unsigned int val) +{ + assert(obj); + obj->value.enumerated.item = val; +} + +const char *snd_control_info_get_item_name(const snd_control_info_t *obj) +{ + assert(obj); + assert(obj->type == SNDRV_CONTROL_TYPE_ENUMERATED); + return obj->value.enumerated.name; +} + +void snd_control_info_get_id(const snd_control_info_t *obj, snd_control_id_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->id; +} + +unsigned int snd_control_info_get_numid(const snd_control_info_t *obj) +{ + assert(obj); + return obj->id.numid; +} + +snd_control_iface_t snd_control_info_get_interface(const snd_control_info_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->id.iface); +} + +unsigned int snd_control_info_get_device(const snd_control_info_t *obj) +{ + assert(obj); + return obj->id.device; +} + +unsigned int snd_control_info_get_subdevice(const snd_control_info_t *obj) +{ + assert(obj); + return obj->id.subdevice; +} + +const char *snd_control_info_get_name(const snd_control_info_t *obj) +{ + assert(obj); + return obj->id.name; +} + +unsigned int snd_control_info_get_index(const snd_control_info_t *obj) +{ + assert(obj); + return obj->id.index; +} + +void snd_control_info_set_id(snd_control_info_t *obj, const snd_control_id_t *ptr) +{ + assert(obj && ptr); + obj->id = *ptr; +} + +void snd_control_info_set_numid(snd_control_info_t *obj, unsigned int val) +{ + assert(obj); + obj->id.numid = val; +} + +void snd_control_info_set_interface(snd_control_info_t *obj, snd_control_iface_t val) +{ + assert(obj); + obj->id.iface = snd_enum_to_int(val); +} + +void snd_control_info_set_device(snd_control_info_t *obj, unsigned int val) +{ + assert(obj); + obj->id.device = val; +} + +void snd_control_info_set_subdevice(snd_control_info_t *obj, unsigned int val) +{ + assert(obj); + obj->id.subdevice = val; +} + +void snd_control_info_set_name(snd_control_info_t *obj, const char *val) +{ + assert(obj); + strncpy(obj->id.name, val, sizeof(obj->id.name)); +} + +void snd_control_info_set_index(snd_control_info_t *obj, unsigned int val) +{ + assert(obj); + obj->id.index = val; +} + +size_t snd_control_sizeof() +{ + return sizeof(snd_control_t); +} + +int snd_control_malloc(snd_control_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_control_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_control_free(snd_control_t *obj) +{ + free(obj); +} + +void snd_control_copy(snd_control_t *dst, const snd_control_t *src) +{ + assert(dst && src); + *dst = *src; +} + +void snd_control_get_id(const snd_control_t *obj, snd_control_id_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->id; +} + +unsigned int snd_control_get_numid(const snd_control_t *obj) +{ + assert(obj); + return obj->id.numid; +} + +snd_control_iface_t snd_control_get_interface(const snd_control_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->id.iface); +} + +unsigned int snd_control_get_device(const snd_control_t *obj) +{ + assert(obj); + return obj->id.device; +} + +unsigned int snd_control_get_subdevice(const snd_control_t *obj) +{ + assert(obj); + return obj->id.subdevice; +} + +const char *snd_control_get_name(const snd_control_t *obj) +{ + assert(obj); + return obj->id.name; +} + +unsigned int snd_control_get_index(const snd_control_t *obj) +{ + assert(obj); + return obj->id.index; +} + +void snd_control_set_id(snd_control_t *obj, const snd_control_id_t *ptr) +{ + assert(obj && ptr); + obj->id = *ptr; +} + +void snd_control_set_numid(snd_control_t *obj, unsigned int val) +{ + assert(obj); + obj->id.numid = val; +} + +void snd_control_set_interface(snd_control_t *obj, snd_control_iface_t val) +{ + assert(obj); + obj->id.iface = snd_enum_to_int(val); +} + +void snd_control_set_device(snd_control_t *obj, unsigned int val) +{ + assert(obj); + obj->id.device = val; +} + +void snd_control_set_subdevice(snd_control_t *obj, unsigned int val) +{ + assert(obj); + obj->id.subdevice = val; +} + +void snd_control_set_name(snd_control_t *obj, const char *val) +{ + assert(obj); + strncpy(obj->id.name, val, sizeof(obj->id.name)); +} + +void snd_control_set_index(snd_control_t *obj, unsigned int val) +{ + assert(obj); + obj->id.index = val; +} + +long snd_control_get_boolean(const snd_control_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < sizeof(obj->value.integer.value) / sizeof(obj->value.integer.value[0])); + return obj->value.integer.value[idx]; +} + +long snd_control_get_integer(const snd_control_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < sizeof(obj->value.integer.value) / sizeof(obj->value.integer.value[0])); + return obj->value.integer.value[idx]; +} + +unsigned int snd_control_get_enumerated(const snd_control_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < sizeof(obj->value.enumerated.item) / sizeof(obj->value.enumerated.item[0])); + return obj->value.enumerated.item[idx]; +} + +unsigned char snd_control_get_byte(const snd_control_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < sizeof(obj->value.bytes.data)); + return obj->value.bytes.data[idx]; +} + +void snd_control_set_boolean(snd_control_t *obj, unsigned int idx, long val) +{ + assert(obj); + obj->value.integer.value[idx] = val; +} + +void snd_control_set_integer(snd_control_t *obj, unsigned int idx, long val) +{ + assert(obj); + obj->value.integer.value[idx] = val; +} + +void snd_control_set_enumerated(snd_control_t *obj, unsigned int idx, unsigned int val) +{ + assert(obj); + obj->value.enumerated.item[idx] = val; +} + +void snd_control_set_byte(snd_control_t *obj, unsigned int idx, unsigned char val) +{ + assert(obj); + obj->value.bytes.data[idx] = val; +} + +const void * snd_control_get_bytes(const snd_control_t *obj) +{ + assert(obj); + return obj->value.bytes.data; +} + +void snd_control_get_iec958(const snd_control_t *obj, snd_aes_iec958_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->value.iec958; +} + +void snd_control_set_iec958(snd_control_t *obj, const snd_aes_iec958_t *ptr) +{ + assert(obj && ptr); + obj->value.iec958 = *ptr; +} + +size_t snd_hcontrol_list_sizeof() +{ + return sizeof(snd_hcontrol_list_t); +} + +int snd_hcontrol_list_malloc(snd_hcontrol_list_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_hcontrol_list_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_hcontrol_list_free(snd_hcontrol_list_t *obj) +{ + free(obj); +} + +void snd_hcontrol_list_copy(snd_hcontrol_list_t *dst, const snd_hcontrol_list_t *src) +{ + assert(dst && src); + *dst = *src; +} + +void snd_hcontrol_list_set_offset(snd_hcontrol_list_t *obj, unsigned int val) +{ + assert(obj); + obj->offset = val; +} + +unsigned int snd_hcontrol_list_get_used(const snd_hcontrol_list_t *obj) +{ + assert(obj); + return obj->used; +} + +unsigned int snd_hcontrol_list_get_count(const snd_hcontrol_list_t *obj) +{ + assert(obj); + return obj->count; +} + +void snd_hcontrol_list_get_id(const snd_hcontrol_list_t *obj, unsigned int idx, snd_control_id_t *ptr) +{ + assert(obj && ptr); + assert(idx < obj->used); + *ptr = obj->pids[idx]; +} + +unsigned int snd_hcontrol_list_get_numid(const snd_hcontrol_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].numid; +} + +snd_control_iface_t snd_hcontrol_list_get_interface(const snd_hcontrol_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return snd_int_to_enum(obj->pids[idx].iface); +} + +unsigned int snd_hcontrol_list_get_device(const snd_hcontrol_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].device; +} + +unsigned int snd_hcontrol_list_get_subdevice(const snd_hcontrol_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].subdevice; +} + +const char *snd_hcontrol_list_get_name(const snd_hcontrol_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].name; +} + +unsigned int snd_hcontrol_list_get_index(const snd_hcontrol_list_t *obj, unsigned int idx) +{ + assert(obj); + assert(idx < obj->used); + return obj->pids[idx].index; +} + +size_t snd_hcontrol_sizeof() +{ + return sizeof(snd_hcontrol_t); +} + +int snd_hcontrol_malloc(snd_hcontrol_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_hcontrol_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_hcontrol_free(snd_hcontrol_t *obj) +{ + free(obj); +} + +void snd_hcontrol_copy(snd_hcontrol_t *dst, const snd_hcontrol_t *src) +{ + assert(dst && src); + *dst = *src; +} + +void snd_hcontrol_get_id(const snd_hcontrol_t *obj, snd_control_id_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->id; +} + +unsigned int snd_hcontrol_get_numid(const snd_hcontrol_t *obj) +{ + assert(obj); + return obj->id.numid; +} + +snd_control_iface_t snd_hcontrol_get_interface(const snd_hcontrol_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->id.iface); +} + +unsigned int snd_hcontrol_get_device(const snd_hcontrol_t *obj) +{ + assert(obj); + return obj->id.device; +} + +unsigned int snd_hcontrol_get_subdevice(const snd_hcontrol_t *obj) +{ + assert(obj); + return obj->id.subdevice; +} + +const char *snd_hcontrol_get_name(const snd_hcontrol_t *obj) +{ + assert(obj); + return obj->id.name; +} + +unsigned int snd_hcontrol_get_index(const snd_hcontrol_t *obj) +{ + assert(obj); + return obj->id.index; +} + +void snd_hcontrol_set_callback_change(snd_hcontrol_t *obj, snd_hcontrol_callback_t val) +{ + assert(obj); + obj->callback_change = val; +} + +void snd_hcontrol_set_callback_value(snd_hcontrol_t *obj, snd_hcontrol_callback_t val) +{ + assert(obj); + obj->callback_value = val; +} + +void snd_hcontrol_set_callback_remove(snd_hcontrol_t *obj, snd_hcontrol_callback_t val) +{ + assert(obj); + obj->callback_remove = val; +} + +void * snd_hcontrol_get_private_data(const snd_hcontrol_t *obj) +{ + assert(obj); + return obj->private_data; +} + +void snd_hcontrol_set_private_data(snd_hcontrol_t *obj, void * val) +{ + assert(obj); + obj->private_data = val; +} + +void snd_hcontrol_set_private_free(snd_hcontrol_t *obj, snd_hcontrol_private_free_t val) +{ + assert(obj); + obj->private_free = val; +} + diff --git a/src/control/control_shm.c b/src/control/control_shm.c index d83eedd9..45f04b3f 100644 --- a/src/control/control_shm.c +++ b/src/control/control_shm.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -107,13 +106,13 @@ static int snd_ctl_shm_poll_descriptor(snd_ctl_t *ctl) return fd; } -static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_hw_info_t *info) +static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_info_t *info) { snd_ctl_shm_t *shm = ctl->private; volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl; int err; // ctrl->u.hw_info = *info; - ctrl->cmd = SNDRV_CTL_IOCTL_HW_INFO; + ctrl->cmd = SNDRV_CTL_IOCTL_INFO; err = snd_ctl_shm_action(ctl); if (err < 0) return err; @@ -126,7 +125,7 @@ static int snd_ctl_shm_clist(snd_ctl_t *ctl, snd_control_list_t *list) snd_ctl_shm_t *shm = ctl->private; volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl; size_t maxsize = CTL_SHM_DATA_MAXLEN; - size_t bytes = list->controls_request * sizeof(*list->pids); + size_t bytes = list->space * sizeof(*list->pids); int err; snd_control_id_t *pids = list->pids; if (bytes > maxsize) @@ -138,6 +137,7 @@ static int snd_ctl_shm_clist(snd_ctl_t *ctl, snd_control_list_t *list) return err; *list = ctrl->u.clist; list->pids = pids; + bytes = list->used * sizeof(*list->pids); memcpy(pids, (void *)ctrl->data, bytes); return err; } @@ -369,7 +369,7 @@ static int make_inet_socket(const char *host, int port) } #endif -int snd_ctl_shm_open(snd_ctl_t **handlep, char *name, char *socket, char *sname) +int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, const char *sname) { snd_ctl_t *ctl; snd_ctl_shm_t *shm = NULL; @@ -469,11 +469,11 @@ extern int is_local(struct hostent *hent); int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf) { snd_config_iterator_t i; - char *server = NULL; - char *sname = NULL; + const char *server = NULL; + const char *sname = NULL; snd_config_t *sconfig; - char *host = NULL; - char *socket = NULL; + const char *host = NULL; + const char *socket = NULL; long port = -1; int err; int local; diff --git a/src/control/controls.c b/src/control/controls.c index 290f8fc8..15c25822 100644 --- a/src/control/controls.c +++ b/src/control/controls.c @@ -23,17 +23,15 @@ #include #include #include -#include #include #include -#include #define __USE_GNU #include #include "control_local.h" static void snd_ctl_hfree1(snd_hcontrol_t *hcontrol); -int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t *hsort) +int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t hsort) { snd_control_list_t list; snd_hcontrol_t *hcontrol, *prev; @@ -49,21 +47,20 @@ int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t *hsort) do { if (list.pids != NULL) free(list.pids); - list.controls_offset = 0; - list.controls_request = 0; - list.controls_count = 0; + list.offset = 0; + list.space = 0; if ((err = snd_ctl_clist(handle, &list)) < 0) return err; - if (list.controls == 0) + if (list.count == 0) break; - list.pids = (snd_control_id_t *)calloc(list.controls, sizeof(snd_control_id_t)); + list.pids = (snd_control_id_t *)calloc(list.count, sizeof(snd_control_id_t)); if (list.pids == NULL) return -ENOMEM; - list.controls_request = list.controls; + list.space = list.count; if ((err = snd_ctl_clist(handle, &list)) < 0) return err; - } while (list.controls != list.controls_count); - for (idx = 0, prev = NULL; idx < list.controls_count; idx++) { + } while (list.count != list.used); + for (idx = 0, prev = NULL; idx < list.count; idx++) { hcontrol = (snd_hcontrol_t *)calloc(1, sizeof(snd_hcontrol_t)); if (hcontrol == NULL) goto __nomem; @@ -101,10 +98,10 @@ static void snd_ctl_hfree1(snd_hcontrol_t *hcontrol) handle = hcontrol->handle; assert(handle != NULL); assert(handle->hcount > 0); - if (hcontrol->event_remove) - hcontrol->event_remove(handle, hcontrol); + if (hcontrol->callback_remove) + hcontrol->callback_remove(handle, hcontrol); if (hcontrol->private_free) - hcontrol->private_free(hcontrol->private_data); + hcontrol->private_free(hcontrol); list_del(&hcontrol->list); free(hcontrol); handle->hcount--; @@ -236,7 +233,7 @@ static void snd_ctl_hresort_free(snd_hcontrol_t *hcontrol ATTRIBUTE_UNUSED) /* nothing */ } -int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t *hsort) +int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t hsort) { struct list_head *list; snd_hcontrol_t *hcontrol; @@ -336,21 +333,21 @@ int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist) unsigned int idx; assert(hlist != NULL); - if (hlist->controls_offset >= (unsigned int)handle->hcount) + if (hlist->offset >= (unsigned int)handle->hcount) return -EINVAL; - hlist->controls_count = 0; - hlist->controls = handle->hcount; - if (hlist->controls_request > 0) { + hlist->used = 0; + hlist->count = handle->hcount; + if (hlist->space > 0) { if (hlist->pids == NULL) return -EINVAL; idx = 0; list_for_each(list, &handle->hlist) { hcontrol = list_entry(list, snd_hcontrol_t, list); - if (idx >= hlist->controls_offset + hlist->controls_request) + if (idx >= hlist->offset + hlist->space) break; - if (idx >= hlist->controls_offset) { + if (idx >= hlist->offset) { hlist->pids[idx] = hcontrol->id; - hlist->controls_count++; + hlist->used++; } idx++; } @@ -358,7 +355,7 @@ int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist) return 0; } -int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t *callback, void *private_data) +int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t callback, void *private_data) { assert(handle != NULL); handle->callback_rebuild = callback; @@ -366,7 +363,7 @@ int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t *ca return 0; } -int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t *callback, void *private_data) +int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t callback, void *private_data) { assert(handle != NULL); handle->callback_add = callback; @@ -476,14 +473,31 @@ int snd_ctl_hevent(snd_ctl_t *handle) return handle->herr; list_for_each(list, &handle->hlist) { hcontrol = list_entry(list, snd_hcontrol_t, list); - if (hcontrol->change && hcontrol->event_change) { - hcontrol->event_change(hcontrol->handle, hcontrol); + if (hcontrol->change && hcontrol->callback_change) { + hcontrol->callback_change(hcontrol->handle, hcontrol); hcontrol->change = 0; } - if (hcontrol->value && hcontrol->event_value) { - hcontrol->event_value(hcontrol->handle, hcontrol); + if (hcontrol->value && hcontrol->callback_value) { + hcontrol->callback_value(hcontrol->handle, hcontrol); hcontrol->value = 0; } } return res; } + +int snd_hcontrol_list_alloc_space(snd_hcontrol_list_t *obj, unsigned int entries) +{ + obj->pids = calloc(entries, sizeof(*obj->pids)); + if (!obj->pids) { + obj->space = 0; + return -ENOMEM; + } + obj->space = entries; + return 0; +} + +void snd_hcontrol_list_free_space(snd_hcontrol_list_t *obj) +{ + free(obj->pids); + obj->pids = NULL; +} diff --git a/src/control/defaults.c b/src/control/defaults.c index 18edc170..328e7969 100644 --- a/src/control/defaults.c +++ b/src/control/defaults.c @@ -21,7 +21,6 @@ #include #include -#include #include "local.h" static int defaults_card(const char *env) diff --git a/src/hwdep/hwdep.c b/src/hwdep/hwdep.c index b1d09986..97f5fb3c 100644 --- a/src/hwdep/hwdep.c +++ b/src/hwdep/hwdep.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include "local.h" diff --git a/src/hwdep/hwdep_m4.c b/src/hwdep/hwdep_m4.c index 5d8990c4..8b5a223a 100644 --- a/src/hwdep/hwdep_m4.c +++ b/src/hwdep/hwdep_m4.c @@ -19,8 +19,6 @@ * */ -#include -#include #include "local.h" size_t snd_hwdep_info_sizeof() @@ -31,7 +29,7 @@ size_t snd_hwdep_info_sizeof() int snd_hwdep_info_malloc(snd_hwdep_info_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_hwdep_info_t)); + *ptr = calloc(1, sizeof(snd_hwdep_info_t)); if (!*ptr) return -ENOMEM; return 0; @@ -60,13 +58,13 @@ int snd_hwdep_info_get_card(const snd_hwdep_info_t *obj) return obj->card; } -const char * snd_hwdep_info_get_id(const snd_hwdep_info_t *obj) +const char *snd_hwdep_info_get_id(const snd_hwdep_info_t *obj) { assert(obj); return obj->id; } -const char * snd_hwdep_info_get_name(const snd_hwdep_info_t *obj) +const char *snd_hwdep_info_get_name(const snd_hwdep_info_t *obj) { assert(obj); return obj->name; diff --git a/src/input.c b/src/input.c index fc294f75..5d57bf6d 100644 --- a/src/input.c +++ b/src/input.c @@ -19,12 +19,10 @@ * */ -#include #include #include #include #include -#include #include "local.h" typedef struct _snd_input_ops { diff --git a/src/instr/fm.c b/src/instr/fm.c index d20be38c..a20dba64 100644 --- a/src/instr/fm.c +++ b/src/instr/fm.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include "local.h" diff --git a/src/instr/iwffff.c b/src/instr/iwffff.c index 9aa12d8b..462cadbf 100644 --- a/src/instr/iwffff.c +++ b/src/instr/iwffff.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include "local.h" diff --git a/src/instr/simple.c b/src/instr/simple.c index 8474bb44..8b78b93d 100644 --- a/src/instr/simple.c +++ b/src/instr/simple.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include "local.h" diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c index 7843a5a2..630006b2 100644 --- a/src/mixer/mixer.c +++ b/src/mixer/mixer.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include "mixer_local.h" diff --git a/src/mixer/mixer_local.h b/src/mixer/mixer_local.h index 719084b5..b2d9543f 100644 --- a/src/mixer/mixer_local.h +++ b/src/mixer/mixer_local.h @@ -19,7 +19,6 @@ * */ -#include #include "local.h" #include "list.h" diff --git a/src/mixer/simple.c b/src/mixer/simple.c index 86033edc..46795a9d 100644 --- a/src/mixer/simple.c +++ b/src/mixer/simple.c @@ -23,9 +23,9 @@ #include #include #include -#include #include #include +#include "../control/control_local.h" #include "mixer_local.h" static struct mixer_name_table { @@ -121,9 +121,9 @@ static void hcontrol_event_remove(snd_ctl_t *ctl_handle ATTRIBUTE_UNUSED, snd_hc static void hcontrol_add(snd_mixer_t *handle, void **bag, snd_hcontrol_t *hcontrol) { snd_ctl_hbag_add(bag, hcontrol); - hcontrol->event_change = hcontrol_event_change; - hcontrol->event_value = hcontrol_event_value; - hcontrol->event_remove = hcontrol_event_remove; + hcontrol->callback_change = hcontrol_event_change; + hcontrol->callback_value = hcontrol_event_value; + hcontrol->callback_remove = hcontrol_event_remove; hcontrol->private_data = handle; } @@ -489,8 +489,8 @@ static int build_input(snd_mixer_t *handle, const char *sname) return err; if (global_info.type == SNDRV_CONTROL_TYPE_BOOLEAN || global_info.type == SNDRV_CONTROL_TYPE_INTEGER) { - if (voices < global_info.values_count) - voices = global_info.values_count; + if (voices < global_info.count) + voices = global_info.count; caps |= global_info.type == SNDRV_CONTROL_TYPE_BOOLEAN ? SND_MIXER_SCTCAP_MUTE : SND_MIXER_SCTCAP_VOLUME; present |= global_info.type == SNDRV_CONTROL_TYPE_BOOLEAN ? MIXER_PRESENT_SINGLE_SWITCH : MIXER_PRESENT_SINGLE_VOLUME; if (global_info.type == SNDRV_CONTROL_TYPE_INTEGER) { @@ -507,8 +507,8 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((err = get_mixer_info(handle, str, index, &gswitch_info)) < 0) return err; if (gswitch_info.type == SNDRV_CONTROL_TYPE_BOOLEAN) { - if (voices < gswitch_info.values_count) - voices = gswitch_info.values_count; + if (voices < gswitch_info.count) + voices = gswitch_info.count; caps |= SND_MIXER_SCTCAP_MUTE; present |= MIXER_PRESENT_GLOBAL_SWITCH; hcontrol_add(handle, &bag, hcontrol); @@ -518,7 +518,7 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) { if ((err = get_mixer_info(handle, str, index, &groute_info)) < 0) return err; - if (groute_info.type == SNDRV_CONTROL_TYPE_BOOLEAN && groute_info.values_count == 4) { + if (groute_info.type == SNDRV_CONTROL_TYPE_BOOLEAN && groute_info.count == 4) { if (voices < 2) voices = 2; caps |= SND_MIXER_SCTCAP_MUTE; @@ -531,8 +531,8 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((err = get_mixer_info(handle, str, index, &gvolume_info)) < 0) return err; if (gvolume_info.type == SNDRV_CONTROL_TYPE_INTEGER) { - if (voices < gvolume_info.values_count) - voices = gvolume_info.values_count; + if (voices < gvolume_info.count) + voices = gvolume_info.count; if (min > gvolume_info.value.integer.min) min = gvolume_info.value.integer.min; if (max < gvolume_info.value.integer.max) @@ -547,8 +547,8 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((err = get_mixer_info(handle, str, index, &pswitch_info)) < 0) return err; if (pswitch_info.type == SNDRV_CONTROL_TYPE_BOOLEAN) { - if (voices < pswitch_info.values_count) - voices = pswitch_info.values_count; + if (voices < pswitch_info.count) + voices = pswitch_info.count; caps |= SND_MIXER_SCTCAP_MUTE; present |= MIXER_PRESENT_PLAYBACK_SWITCH; hcontrol_add(handle, &bag, hcontrol); @@ -558,7 +558,7 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) { if ((err = get_mixer_info(handle, str, index, &proute_info)) < 0) return err; - if (proute_info.type == SNDRV_CONTROL_TYPE_BOOLEAN && proute_info.values_count == 4) { + if (proute_info.type == SNDRV_CONTROL_TYPE_BOOLEAN && proute_info.count == 4) { if (voices < 2) voices = 2; caps |= SND_MIXER_SCTCAP_MUTE; @@ -571,8 +571,8 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((err = get_mixer_info(handle, str, index, &cswitch_info)) < 0) return err; if (cswitch_info.type == SNDRV_CONTROL_TYPE_BOOLEAN) { - if (voices < cswitch_info.values_count) - voices = cswitch_info.values_count; + if (voices < cswitch_info.count) + voices = cswitch_info.count; caps |= SND_MIXER_SCTCAP_CAPTURE; present |= MIXER_PRESENT_CAPTURE_SWITCH; hcontrol_add(handle, &bag, hcontrol); @@ -582,7 +582,7 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((hcontrol = test_mixer_id(handle, str, index)) != NULL) { if ((err = get_mixer_info(handle, str, index, &croute_info)) < 0) return err; - if (croute_info.type == SNDRV_CONTROL_TYPE_BOOLEAN && croute_info.values_count == 4) { + if (croute_info.type == SNDRV_CONTROL_TYPE_BOOLEAN && croute_info.count == 4) { if (voices < 2) voices = 2; caps |= SND_MIXER_SCTCAP_CAPTURE; @@ -595,8 +595,8 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((err = get_mixer_info(handle, str, index, &pvolume_info)) < 0) return err; if (pvolume_info.type == SNDRV_CONTROL_TYPE_INTEGER) { - if (voices < pvolume_info.values_count) - voices = pvolume_info.values_count; + if (voices < pvolume_info.count) + voices = pvolume_info.count; if (min > pvolume_info.value.integer.min) min = pvolume_info.value.integer.min; if (max < pvolume_info.value.integer.max) @@ -611,8 +611,8 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((err = get_mixer_info(handle, str, index, &cvolume_info)) < 0) return err; if (cvolume_info.type == SNDRV_CONTROL_TYPE_INTEGER) { - if (voices < cvolume_info.values_count) - voices = cvolume_info.values_count; + if (voices < cvolume_info.count) + voices = cvolume_info.count; if (min > pvolume_info.value.integer.min) min = pvolume_info.value.integer.min; if (max < pvolume_info.value.integer.max) @@ -633,8 +633,8 @@ static int build_input(snd_mixer_t *handle, const char *sname) if (csource_info.type == SNDRV_CONTROL_TYPE_ENUMERATED) { capture_item = 0; if (!strcmp(csource_info.value.enumerated.name, str)) { - if (voices < csource_info.values_count) - voices = csource_info.values_count; + if (voices < csource_info.count) + voices = csource_info.count; caps |= SND_MIXER_SCTCAP_CAPTURE; present |= MIXER_PRESENT_CAPTURE_SOURCE; hcontrol_add(handle, &bag, hcontrol); @@ -643,8 +643,8 @@ static int build_input(snd_mixer_t *handle, const char *sname) if ((err = snd_ctl_cinfo(handle->ctl_handle, &csource_info)) < 0) return err; if (!strcmp(csource_info.value.enumerated.name, str)) { - if (voices < csource_info.values_count) - voices = csource_info.values_count; + if (voices < csource_info.count) + voices = csource_info.count; caps |= SND_MIXER_SCTCAP_CAPTURE; present |= MIXER_PRESENT_CAPTURE_SOURCE; hcontrol_add(handle, &bag, hcontrol); @@ -661,39 +661,39 @@ static int build_input(snd_mixer_t *handle, const char *sname) if (present & (MIXER_PRESENT_SINGLE_VOLUME|MIXER_PRESENT_GLOBAL_VOLUME|MIXER_PRESENT_PLAYBACK_VOLUME|MIXER_PRESENT_CAPTURE_VOLUME)) caps |= SND_MIXER_SCTCAP_JOINTLY_VOLUME; if (present & MIXER_PRESENT_SINGLE_SWITCH) { - if (global_info.values_count > 1) + if (global_info.count > 1) caps &= ~SND_MIXER_SCTCAP_JOINTLY_MUTE; } if (present & MIXER_PRESENT_GLOBAL_SWITCH) { - if (gswitch_info.values_count > 1) + if (gswitch_info.count > 1) caps &= ~SND_MIXER_SCTCAP_JOINTLY_MUTE; } if (present & MIXER_PRESENT_PLAYBACK_SWITCH) { - if (pswitch_info.values_count > 1) + if (pswitch_info.count > 1) caps &= ~SND_MIXER_SCTCAP_JOINTLY_MUTE; } if (present & (MIXER_PRESENT_GLOBAL_ROUTE | MIXER_PRESENT_PLAYBACK_ROUTE)) caps &= ~SND_MIXER_SCTCAP_JOINTLY_MUTE; if (present & MIXER_PRESENT_CAPTURE_SWITCH) { - if (cswitch_info.values_count > 1) + if (cswitch_info.count > 1) caps &= ~SND_MIXER_SCTCAP_JOINTLY_CAPTURE; } if (present & MIXER_PRESENT_CAPTURE_ROUTE) caps &= ~SND_MIXER_SCTCAP_JOINTLY_CAPTURE; if (present & MIXER_PRESENT_SINGLE_VOLUME) { - if (global_info.values_count > 1) + if (global_info.count > 1) caps &= ~SND_MIXER_SCTCAP_JOINTLY_VOLUME; } if (present & MIXER_PRESENT_GLOBAL_VOLUME) { - if (gvolume_info.values_count > 1) + if (gvolume_info.count > 1) caps &= ~SND_MIXER_SCTCAP_JOINTLY_VOLUME; } if (present & MIXER_PRESENT_PLAYBACK_VOLUME) { - if (pvolume_info.values_count > 1) + if (pvolume_info.count > 1) caps &= ~SND_MIXER_SCTCAP_JOINTLY_VOLUME; } if (present & MIXER_PRESENT_CAPTURE_VOLUME) { - if (cvolume_info.values_count > 1) + if (cvolume_info.count > 1) caps &= ~SND_MIXER_SCTCAP_JOINTLY_VOLUME; } } @@ -706,17 +706,17 @@ static int build_input(snd_mixer_t *handle, const char *sname) return -ENOMEM; } simple->present = present; - simple->global_values = global_info.values_count; - simple->gswitch_values = gswitch_info.values_count; - simple->pswitch_values = pswitch_info.values_count; - simple->cswitch_values = cswitch_info.values_count; - simple->gvolume_values = gvolume_info.values_count; - simple->pvolume_values = pvolume_info.values_count; - simple->cvolume_values = cvolume_info.values_count; + simple->global_values = global_info.count; + simple->gswitch_values = gswitch_info.count; + simple->pswitch_values = pswitch_info.count; + simple->cswitch_values = cswitch_info.count; + simple->gvolume_values = gvolume_info.count; + simple->pvolume_values = pvolume_info.count; + simple->cvolume_values = cvolume_info.count; simple->groute_values = 2; simple->proute_values = 2; simple->croute_values = 2; - simple->ccapture_values = csource_info.values_count; + simple->ccapture_values = csource_info.count; simple->capture_item = capture_item; simple->caps = caps; simple->voices = voices; diff --git a/src/output.c b/src/output.c index 3dc44262..477c79ff 100644 --- a/src/output.c +++ b/src/output.c @@ -19,12 +19,10 @@ * */ -#include #include #include #include #include -#include #include "local.h" typedef struct _snd_output_ops { diff --git a/src/pcm/interval.c b/src/pcm/interval.c index 8be7d3d6..a0a687de 100644 --- a/src/pcm/interval.c +++ b/src/pcm/interval.c @@ -24,8 +24,6 @@ #include #include -#include -#include #include "pcm_local.h" static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem) diff --git a/src/pcm/mask.c b/src/pcm/mask.c index c84da00e..018a2eb0 100644 --- a/src/pcm/mask.c +++ b/src/pcm/mask.c @@ -24,7 +24,5 @@ #include #include -#include -#include #include "pcm_local.h" diff --git a/src/pcm/mask_inline.h b/src/pcm/mask_inline.h index 37eb4a77..dec674ea 100644 --- a/src/pcm/mask_inline.h +++ b/src/pcm/mask_inline.h @@ -20,7 +20,6 @@ */ #include -#include #ifdef SND_MASK_C #define MASK_INLINE inline diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 7803d153..78f01c42 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -248,12 +247,12 @@ int snd_pcm_poll_descriptor(snd_pcm_t *pcm) #define FORMATD(v, d) [SND_PCM_FORMAT_##v] = d #define SUBFORMATD(v, d) [SND_PCM_SUBFORMAT_##v] = d -char *snd_pcm_stream_names[] = { +const char *snd_pcm_stream_names[] = { STREAM(PLAYBACK), STREAM(CAPTURE), }; -char *snd_pcm_state_names[] = { +const char *snd_pcm_state_names[] = { STATE(OPEN), STATE(SETUP), STATE(PREPARED), @@ -262,7 +261,7 @@ char *snd_pcm_state_names[] = { STATE(PAUSED), }; -char *snd_pcm_hw_param_names[] = { +const char *snd_pcm_hw_param_names[] = { HW_PARAM(ACCESS), HW_PARAM(FORMAT), HW_PARAM(SUBFORMAT), @@ -280,7 +279,7 @@ char *snd_pcm_hw_param_names[] = { HW_PARAM(TICK_TIME), }; -char *snd_pcm_access_names[] = { +const char *snd_pcm_access_names[] = { ACCESS(MMAP_INTERLEAVED), ACCESS(MMAP_NONINTERLEAVED), ACCESS(MMAP_COMPLEX), @@ -288,7 +287,7 @@ char *snd_pcm_access_names[] = { ACCESS(RW_NONINTERLEAVED), }; -char *snd_pcm_format_names[] = { +const char *snd_pcm_format_names[] = { FORMAT(S8), FORMAT(U8), FORMAT(S16_LE), @@ -317,7 +316,7 @@ char *snd_pcm_format_names[] = { FORMAT(SPECIAL), }; -char *snd_pcm_format_descriptions[] = { +const char *snd_pcm_format_descriptions[] = { FORMATD(S8, "Signed 8-bit"), FORMATD(U8, "Unsigned 8-bit"), FORMATD(S16_LE, "Signed 16-bit Little Endian"), @@ -346,25 +345,25 @@ char *snd_pcm_format_descriptions[] = { FORMATD(SPECIAL, "Special"), }; -char *snd_pcm_subformat_names[] = { +const char *snd_pcm_subformat_names[] = { SUBFORMAT(STD), }; -char *snd_pcm_subformat_descriptions[] = { +const char *snd_pcm_subformat_descriptions[] = { SUBFORMATD(STD, "Standard"), }; -char *snd_pcm_start_mode_names[] = { +const char *snd_pcm_start_mode_names[] = { START(EXPLICIT), START(DATA), }; -char *snd_pcm_xrun_mode_names[] = { +const char *snd_pcm_xrun_mode_names[] = { XRUN(NONE), XRUN(STOP), }; -char *snd_pcm_tstamp_mode_names[] = { +const char *snd_pcm_tstamp_mode_names[] = { TSTAMP(NONE), TSTAMP(MMAP), }; @@ -536,15 +535,15 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, int samples) return samples * pcm->sample_bits / 8; } -int snd_pcm_open(snd_pcm_t **pcmp, char *name, +int snd_pcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode) { - char *str; + const char *str; int err; snd_config_t *pcm_conf, *conf, *type_conf; snd_config_iterator_t i; - char *lib = NULL, *open = NULL; - int (*open_func)(snd_pcm_t **pcmp, char *name, snd_config_t *conf, + const char *lib = NULL, *open = NULL; + int (*open_func)(snd_pcm_t **pcmp, const char *name, snd_config_t *conf, snd_pcm_stream_t stream, int mode); void *h; assert(pcmp && name); diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c index 02891887..7347ce60 100644 --- a/src/pcm/pcm_adpcm.c +++ b/src/pcm/pcm_adpcm.c @@ -597,7 +597,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; int err; snd_pcm_t *spcm; snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN; @@ -618,7 +618,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, continue; } if (strcmp(n->id, "sformat") == 0) { - char *f; + const char *f; err = snd_config_string_get(n, &f); if (err < 0) { ERR("Invalid type for %s", n->id); @@ -652,7 +652,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, if (!sname) return -ENOMEM; err = snd_pcm_open(&spcm, sname, stream, mode); - free(sname); + free((void *) sname); if (err < 0) return err; err = snd_pcm_adpcm_open(pcmp, name, sformat, spcm, 1); diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c index 7730cb09..1f30951f 100644 --- a/src/pcm/pcm_alaw.c +++ b/src/pcm/pcm_alaw.c @@ -470,7 +470,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; int err; snd_pcm_t *spcm; snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN; @@ -491,7 +491,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, continue; } if (strcmp(n->id, "sformat") == 0) { - char *f; + const char *f; err = snd_config_string_get(n, &f); if (err < 0) { ERR("Invalid type for %s", n->id); @@ -525,7 +525,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, if (!sname) return -ENOMEM; err = snd_pcm_open(&spcm, sname, stream, mode); - free(sname); + free((void *) sname); if (err < 0) return err; err = snd_pcm_alaw_open(pcmp, name, sformat, spcm, 1); diff --git a/src/pcm/pcm_copy.c b/src/pcm/pcm_copy.c index a4b17db6..f0e2b9ea 100644 --- a/src/pcm/pcm_copy.c +++ b/src/pcm/pcm_copy.c @@ -228,7 +228,7 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; int err; snd_pcm_t *spcm; snd_config_foreach(i, conf) { @@ -259,7 +259,7 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, if (!sname) return -ENOMEM; err = snd_pcm_open(&spcm, sname, stream, mode); - free(sname); + free((void *) sname); if (err < 0) return err; err = snd_pcm_copy_open(pcmp, name, spcm, 1); diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index 9e461b1c..10d66866 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -30,7 +30,7 @@ typedef enum _snd_pcm_file_format { typedef struct { snd_pcm_t *slave; int close_slave; - char *fname; + const char *fname; int fd; int format; snd_pcm_uframes_t appl_ptr; @@ -102,7 +102,7 @@ static int snd_pcm_file_close(snd_pcm_t *pcm) if (file->close_slave) err = snd_pcm_close(file->slave); if (file->fname) { - free(file->fname); + free((void *)file->fname); close(file->fd); } free(file); @@ -403,7 +403,7 @@ snd_pcm_fast_ops_t snd_pcm_file_fast_ops = { mmap_forward: snd_pcm_file_mmap_forward, }; -int snd_pcm_file_open(snd_pcm_t **pcmp, char *name, char *fname, int fd, char *fmt, snd_pcm_t *slave, int close_slave) +int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, const char *fname, int fd, const char *fmt, snd_pcm_t *slave, int close_slave) { snd_pcm_t *pcm; snd_pcm_file_t *file; @@ -464,11 +464,11 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; int err; snd_pcm_t *spcm; - char *fname = NULL; - char *format = NULL; + const char *fname = NULL; + const char *format = NULL; long fd = -1; snd_config_foreach(i, conf) { snd_config_t *n = snd_config_entry(i); @@ -526,7 +526,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, char *name, if (!sname) return -ENOMEM; err = snd_pcm_open(&spcm, sname, stream, mode); - free(sname); + free((void *) sname); if (err < 0) return err; err = snd_pcm_file_open(pcmp, name, fname, fd, format, spcm, 1); diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index d53c48be..edcdf9b1 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -664,7 +663,7 @@ int snd_pcm_hw_open_device(snd_pcm_t **pcmp, int card, int device, snd_pcm_strea return snd_pcm_hw_open_subdevice(pcmp, card, device, -1, stream, mode); } -int snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode) +int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode) { int err = snd_pcm_hw_open_subdevice(pcmp, card, device, subdevice, stream, mode); if (err < 0) @@ -679,7 +678,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, { snd_config_iterator_t i; long card = -1, device = 0, subdevice = -1; - char *str; + const char *str; int err; snd_config_foreach(i, conf) { snd_config_t *n = snd_config_entry(i); diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c index cd2e38cc..1e9639f2 100644 --- a/src/pcm/pcm_linear.c +++ b/src/pcm/pcm_linear.c @@ -368,7 +368,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; int err; snd_pcm_t *spcm; snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN; @@ -389,7 +389,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, continue; } if (strcmp(n->id, "sformat") == 0) { - char *f; + const char *f; err = snd_config_string_get(n, &f); if (err < 0) { ERR("Invalid type for %s", n->id); @@ -422,7 +422,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, if (!sname) return -ENOMEM; err = snd_pcm_open(&spcm, sname, stream, mode); - free(sname); + free((void *) sname); if (err < 0) return err; err = snd_pcm_linear_open(pcmp, name, sformat, spcm, 1); diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 01bb67c7..93b4dff3 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -20,12 +20,10 @@ * */ -#include #include #include #include #include -#include #define _snd_pcm_access_mask _snd_mask #define _snd_pcm_format_mask _snd_mask @@ -167,11 +165,11 @@ struct _snd_pcm { void *private; }; -int snd_pcm_hw_open(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode); -int snd_pcm_plug_open_hw(snd_pcm_t **pcm, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode); -int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, snd_pcm_stream_t stream, int mode); -int snd_pcm_file_open(snd_pcm_t **pcmp, char *name, char *fname, int fd, char *fmt, snd_pcm_t *slave, int close_slave); -int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode); +int snd_pcm_hw_open(snd_pcm_t **pcm, const char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode); +int snd_pcm_plug_open_hw(snd_pcm_t **pcm, const char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode); +int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, const char *socket, const char *sname, snd_pcm_stream_t stream, int mode); +int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, const char *fname, int fd, const char *fmt, snd_pcm_t *slave, int close_slave); +int snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode); void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, void *buf); diff --git a/src/pcm/pcm_m4.c b/src/pcm/pcm_m4.c index 6a88587c..116fb335 100644 --- a/src/pcm/pcm_m4.c +++ b/src/pcm/pcm_m4.c @@ -22,6 +22,7 @@ #include "pcm_local.h" + size_t snd_pcm_access_mask_sizeof() { return sizeof(snd_pcm_access_mask_t); @@ -30,7 +31,7 @@ size_t snd_pcm_access_mask_sizeof() int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_pcm_access_mask_t)); + *ptr = calloc(1, sizeof(snd_pcm_access_mask_t)); if (!*ptr) return -ENOMEM; return 0; @@ -81,7 +82,7 @@ size_t snd_pcm_format_mask_sizeof() int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_pcm_format_mask_t)); + *ptr = calloc(1, sizeof(snd_pcm_format_mask_t)); if (!*ptr) return -ENOMEM; return 0; @@ -132,7 +133,7 @@ size_t snd_pcm_subformat_mask_sizeof() int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_pcm_subformat_mask_t)); + *ptr = calloc(1, sizeof(snd_pcm_subformat_mask_t)); if (!*ptr) return -ENOMEM; return 0; @@ -183,7 +184,7 @@ size_t snd_pcm_hw_params_sizeof() int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_pcm_hw_params_t)); + *ptr = calloc(1, sizeof(snd_pcm_hw_params_t)); if (!*ptr) return -ENOMEM; return 0; @@ -205,9 +206,14 @@ snd_pcm_access_t snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params) return snd_int_to_enum(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_ACCESS, NULL)); } -int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_access_t val) +int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(val), 0); + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(val), 0); +} + +int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_ACCESS, snd_enum_to_int(val), 0); } snd_pcm_access_t snd_pcm_hw_params_set_access_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) @@ -220,9 +226,9 @@ snd_pcm_access_t snd_pcm_hw_params_set_access_last(snd_pcm_t *pcm, snd_pcm_hw_pa return snd_int_to_enum(snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_ACCESS, NULL)); } -int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_access_mask_t *mask) +int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask) { - return snd_pcm_hw_param_set_mask(pcm, params, mode, SND_PCM_HW_PARAM_ACCESS, (snd_mask_t *) mask); + return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_ACCESS, (snd_mask_t *) mask); } @@ -231,9 +237,14 @@ snd_pcm_format_t snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params) return snd_int_to_enum(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_FORMAT, NULL)); } -int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_format_t val) +int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_FORMAT, snd_enum_to_int(val), 0); +} + +int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_FORMAT, snd_enum_to_int(val), 0); + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_FORMAT, snd_enum_to_int(val), 0); } snd_pcm_format_t snd_pcm_hw_params_set_format_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) @@ -246,20 +257,25 @@ snd_pcm_format_t snd_pcm_hw_params_set_format_last(snd_pcm_t *pcm, snd_pcm_hw_pa return snd_int_to_enum(snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_FORMAT, NULL)); } -int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_format_mask_t *mask) +int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask) { - return snd_pcm_hw_param_set_mask(pcm, params, mode, SND_PCM_HW_PARAM_FORMAT, (snd_mask_t *) mask); + return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_FORMAT, (snd_mask_t *) mask); } +int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(val), 0); +} + snd_pcm_subformat_t snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params) { return snd_int_to_enum(snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_SUBFORMAT, NULL)); } -int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_subformat_t val) +int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t val) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(val), 0); + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_SUBFORMAT, snd_enum_to_int(val), 0); } snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) @@ -272,9 +288,9 @@ snd_pcm_subformat_t snd_pcm_hw_params_set_subformat_last(snd_pcm_t *pcm, snd_pcm return snd_int_to_enum(snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_SUBFORMAT, NULL)); } -int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_subformat_mask_t *mask) +int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask) { - return snd_pcm_hw_param_set_mask(pcm, params, mode, SND_PCM_HW_PARAM_SUBFORMAT, (snd_mask_t *) mask); + return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_SUBFORMAT, (snd_mask_t *) mask); } @@ -293,24 +309,29 @@ unsigned int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *param return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_CHANNELS, NULL); } -int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val) +int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_CHANNELS, val, 0); + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_CHANNELS, val, 0); } -int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val) +int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) { - return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_CHANNELS, val, NULL); + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, val, 0); } -int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val) +int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val) { - return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_CHANNELS, val, NULL); + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, val, NULL); } -int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, unsigned int *max) +int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val) { - return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_CHANNELS, min, NULL, max, NULL); + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, val, NULL); +} + +int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, min, NULL, max, NULL); } unsigned int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val) @@ -344,24 +365,29 @@ unsigned int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, i return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_RATE, dir); } -int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_RATE, val, dir); +} + +int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_RATE, val, dir); + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, val, dir); } -int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_RATE, val, dir); + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, val, dir); } -int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_RATE, val, dir); + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, val, dir); } -int snd_pcm_hw_params_set_rate_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +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) { - return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_RATE, min, mindir, max, maxdir); + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, min, mindir, max, maxdir); } unsigned int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) @@ -395,24 +421,29 @@ unsigned int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *pa return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIOD_TIME, dir); } -int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); } -int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) { - return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); } -int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); } -int snd_pcm_hw_params_set_period_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_TIME, min, mindir, max, maxdir); + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir); +} + +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) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, min, mindir, max, maxdir); } unsigned int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) @@ -446,32 +477,37 @@ snd_pcm_uframes_t snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_ return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIOD_SIZE, dir); } -int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t val, int dir) +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) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir); + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir); } -int snd_pcm_hw_params_set_period_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val, int *dir) +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) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir); +} + +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) { unsigned int _val = *val; - int err = snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir); + int err = snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir); *val = _val; return err; } -int snd_pcm_hw_params_set_period_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val, int *dir) +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) { unsigned int _val = *val; - int err = snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir); + int err = snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir); *val = _val; return err; } -int snd_pcm_hw_params_set_period_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *min, int *mindir, snd_pcm_uframes_t *max, int *maxdir) +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) { unsigned int _min = *min; unsigned int _max = *max; - int err = snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE, &_min, mindir, &_max, maxdir); + int err = snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, &_min, mindir, &_max, maxdir); *min = _min; *max = _max; return err; @@ -492,9 +528,9 @@ snd_pcm_uframes_t snd_pcm_hw_params_set_period_size_last(snd_pcm_t *pcm, snd_pcm return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, dir); } -int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode) +int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { - return snd_pcm_hw_param_set_integer(pcm, params, mode, SND_PCM_HW_PARAM_PERIOD_SIZE); + return snd_pcm_hw_param_set_integer(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE); } @@ -513,24 +549,29 @@ unsigned int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIODS, dir); } -int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIODS, val, dir); +} + +int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS, val, dir); + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, val, dir); } -int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS, val, dir); + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, val, dir); } -int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS, val, dir); + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, val, dir); } -int snd_pcm_hw_params_set_periods_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +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) { - return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS, min, mindir, max, maxdir); + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, min, mindir, max, maxdir); } unsigned int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) @@ -548,9 +589,9 @@ unsigned int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_param return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_PERIODS, dir); } -int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode) +int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { - return snd_pcm_hw_param_set_integer(pcm, params, mode, SND_PCM_HW_PARAM_PERIODS); + return snd_pcm_hw_param_set_integer(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS); } @@ -569,24 +610,29 @@ unsigned int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *pa return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_BUFFER_TIME, dir); } -int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); } -int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) { - return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); } -int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); } -int snd_pcm_hw_params_set_buffer_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_TIME, min, mindir, max, maxdir); + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir); +} + +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) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, min, mindir, max, maxdir); } unsigned int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) @@ -620,32 +666,37 @@ snd_pcm_uframes_t snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_ return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_BUFFER_SIZE, NULL); } -int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t val) +int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_SIZE, val, 0); + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_BUFFER_SIZE, val, 0); } -int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val) +int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val) +{ + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, val, 0); +} + +int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val) { unsigned int _val = *val; - int err = snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL); + int err = snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL); *val = _val; return err; } -int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *val) +int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val) { unsigned int _val = *val; - int err = snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL); + int err = snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL); *val = _val; return err; } -int snd_pcm_hw_params_set_buffer_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_uframes_t *min, snd_pcm_uframes_t *max) +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) { unsigned int _min = *min; unsigned int _max = *max; - int err = snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_BUFFER_SIZE, &_min, NULL, &_max, NULL); + int err = snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, &_min, NULL, &_max, NULL); *min = _min; *max = _max; return err; @@ -682,24 +733,29 @@ unsigned int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *para return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_TICK_TIME, dir); } -int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int val, int dir) +int snd_pcm_hw_params_test_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) { - return snd_pcm_hw_param_set(pcm, params, mode, SND_PCM_HW_PARAM_TICK_TIME, val, dir); + return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_TICK_TIME, val, dir); } -int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir) { - return snd_pcm_hw_param_set_min(pcm, params, mode, SND_PCM_HW_PARAM_TICK_TIME, val, dir); + return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, val, dir); } -int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *val, int *dir) +int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_max(pcm, params, mode, SND_PCM_HW_PARAM_TICK_TIME, val, dir); + return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, val, dir); } -int snd_pcm_hw_params_set_tick_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) +int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { - return snd_pcm_hw_param_set_minmax(pcm, params, mode, SND_PCM_HW_PARAM_TICK_TIME, min, mindir, max, maxdir); + return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, val, dir); +} + +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) +{ + return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, min, mindir, max, maxdir); } unsigned int snd_pcm_hw_params_set_tick_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int *dir) @@ -726,7 +782,7 @@ size_t snd_pcm_sw_params_sizeof() int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_pcm_sw_params_t)); + *ptr = calloc(1, sizeof(snd_pcm_sw_params_t)); if (!*ptr) return -ENOMEM; return 0; @@ -875,6 +931,67 @@ snd_pcm_uframes_t snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t * } +size_t snd_pcm_status_sizeof() +{ + return sizeof(snd_pcm_status_t); +} + +int snd_pcm_status_malloc(snd_pcm_status_t **ptr) +{ + assert(ptr); + *ptr = calloc(1, sizeof(snd_pcm_status_t)); + if (!*ptr) + return -ENOMEM; + return 0; +} + +void snd_pcm_status_free(snd_pcm_status_t *obj) +{ + free(obj); +} + +void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src) +{ + assert(dst && src); + *dst = *src; +} + +snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj) +{ + assert(obj); + return snd_int_to_enum(obj->state); +} + +void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->trigger_tstamp; +} + +void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr) +{ + assert(obj && ptr); + *ptr = obj->tstamp; +} + +snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj) +{ + assert(obj); + return obj->delay; +} + +snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj) +{ + assert(obj); + return obj->avail; +} + +snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj) +{ + assert(obj); + return obj->avail_max; +} + size_t snd_pcm_info_sizeof() { return sizeof(snd_pcm_info_t); @@ -883,7 +1000,7 @@ size_t snd_pcm_info_sizeof() int snd_pcm_info_malloc(snd_pcm_info_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_pcm_info_t)); + *ptr = calloc(1, sizeof(snd_pcm_info_t)); if (!*ptr) return -ENOMEM; return 0; @@ -924,19 +1041,19 @@ int snd_pcm_info_get_card(const snd_pcm_info_t *obj) return obj->card; } -const char * snd_pcm_info_get_id(const snd_pcm_info_t *obj) +const char *snd_pcm_info_get_id(const snd_pcm_info_t *obj) { assert(obj); return obj->id; } -const char * snd_pcm_info_get_name(const snd_pcm_info_t *obj) +const char *snd_pcm_info_get_name(const snd_pcm_info_t *obj) { assert(obj); return obj->name; } -const char * snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj) +const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj) { assert(obj); return obj->subname; @@ -984,64 +1101,3 @@ void snd_pcm_info_set_stream(snd_pcm_info_t *obj, snd_pcm_stream_t val) obj->stream = snd_enum_to_int(val); } -size_t snd_pcm_status_sizeof() -{ - return sizeof(snd_pcm_status_t); -} - -int snd_pcm_status_malloc(snd_pcm_status_t **ptr) -{ - assert(ptr); - *ptr = malloc(sizeof(snd_pcm_status_t)); - if (!*ptr) - return -ENOMEM; - return 0; -} - -void snd_pcm_status_free(snd_pcm_status_t *obj) -{ - free(obj); -} - -void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src) -{ - assert(dst && src); - *dst = *src; -} - -snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj) -{ - assert(obj); - return snd_int_to_enum(obj->state); -} - -void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr) -{ - assert(obj && ptr); - *ptr = obj->trigger_tstamp; -} - -void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr) -{ - assert(obj && ptr); - *ptr = obj->tstamp; -} - -snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj) -{ - assert(obj); - return obj->delay; -} - -snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj) -{ - assert(obj); - return obj->avail; -} - -snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj) -{ - assert(obj); - return obj->avail_max; -} - diff --git a/src/pcm/pcm_misc.c b/src/pcm/pcm_misc.c index d2a51dce..e5bd581b 100644 --- a/src/pcm/pcm_misc.c +++ b/src/pcm/pcm_misc.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include "pcm_local.h" #endif diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c index fcbffbe0..81af0438 100644 --- a/src/pcm/pcm_mmap.c +++ b/src/pcm/pcm_mmap.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c index 0138e36d..5e9c2874 100644 --- a/src/pcm/pcm_mulaw.c +++ b/src/pcm/pcm_mulaw.c @@ -485,7 +485,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; int err; snd_pcm_t *spcm; snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN; @@ -506,7 +506,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, continue; } if (strcmp(n->id, "sformat") == 0) { - char *f; + const char *f; err = snd_config_string_get(n, &f); if (err < 0) { ERR("Invalid type for %s", n->id); @@ -540,7 +540,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, if (!sname) return -ENOMEM; err = snd_pcm_open(&spcm, sname, stream, mode); - free(sname); + free((void *) sname); if (err < 0) return err; err = snd_pcm_mulaw_open(pcmp, name, sformat, spcm, 1); diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c index caffd93f..551b0ea8 100644 --- a/src/pcm/pcm_multi.c +++ b/src/pcm/pcm_multi.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "pcm_local.h" @@ -664,7 +663,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, idx = 0; snd_config_foreach(i, slave) { snd_config_t *m = snd_config_entry(i); - char *name = NULL; + const char *name = NULL; long channels = -1; slaves_id[idx] = m->id; snd_config_foreach(j, m) { @@ -712,7 +711,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, long schannel = -1; int slave = -1; long val; - char *str; + const char *str; cchannel = strtol(m->id, 0, 10); if (cchannel < 0) { ERR("Invalid channel number: %s", m->id); diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c index 59997b50..e45c9164 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -319,7 +319,7 @@ snd_pcm_fast_ops_t snd_pcm_null_fast_ops = { mmap_forward: snd_pcm_null_mmap_forward, }; -int snd_pcm_null_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) +int snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode) { snd_pcm_t *pcm; snd_pcm_null_t *null; diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index 14aa8871..5de07a18 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -902,7 +902,7 @@ void snd_pcm_hw_param_refine_near(snd_pcm_t *pcm, min = snd_pcm_hw_param_get_min(src, var, &mindir); max = snd_pcm_hw_param_get_max(src, var, &maxdir); snd_pcm_hw_param_set_near_minmax(pcm, params, var, - min, &mindir, max, &maxdir); + min, &mindir, max, &maxdir); } /* ---- end of refinement functions ---- */ @@ -968,14 +968,6 @@ int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params) return params->msbits; } -/* Return info for configuration space defined by PARAMS */ -int snd_pcm_hw_params_get_flags(const snd_pcm_hw_params_t *params) -{ - if (params->info == ~0U) - return -EINVAL; - return params->info; -} - /* Return fifo size for configuration space defined by PARAMS */ int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params) { diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index 398f2717..c32260e6 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -574,8 +574,8 @@ static int snd_pcm_plug_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) if (!(clt_params.format == slv_params.format && clt_params.channels == slv_params.channels && clt_params.rate == slv_params.rate && - snd_pcm_hw_params_set_access(slave, &sparams, SND_TEST, - clt_params.access) >= 0)) { + snd_pcm_hw_params_test_access(slave, &sparams, + clt_params.access) >= 0)) { slv_params.access = snd_pcm_hw_params_set_access_first(slave, &sparams); err = snd_pcm_plug_insert_plugins(pcm, &clt_params, &slv_params); if (err < 0) @@ -646,7 +646,7 @@ snd_pcm_ops_t snd_pcm_plug_ops = { }; int snd_pcm_plug_open(snd_pcm_t **pcmp, - char *name, + const char *name, snd_pcm_route_ttable_entry_t *ttable, unsigned int tt_ssize, unsigned int tt_cused, unsigned int tt_sused, @@ -688,7 +688,7 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp, return 0; } -int snd_pcm_plug_open_hw(snd_pcm_t **pcmp, char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode) +int snd_pcm_plug_open_hw(snd_pcm_t **pcmp, const char *name, int card, int device, int subdevice, snd_pcm_stream_t stream, int mode) { snd_pcm_t *slave; int err; @@ -700,12 +700,12 @@ int snd_pcm_plug_open_hw(snd_pcm_t **pcmp, char *name, int card, int device, int #define MAX_CHANNELS 32 -int _snd_pcm_plug_open(snd_pcm_t **pcmp, char *name, +int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; int err; snd_pcm_t *spcm; snd_config_t *tt = NULL; @@ -755,7 +755,7 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, char *name, if (!sname) return -ENOMEM; err = snd_pcm_open(&spcm, sname, stream, mode); - free(sname); + free((void *) sname); if (err < 0) return err; err = snd_pcm_plug_open(pcmp, name, ttable, MAX_CHANNELS, cused, sused, spcm, 1); diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index 8b47ddd8..b72f5525 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -622,7 +622,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; int err; snd_pcm_t *spcm; snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN; @@ -644,7 +644,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, continue; } if (strcmp(n->id, "sformat") == 0) { - char *f; + const char *f; err = snd_config_string_get(n, &f); if (err < 0) { ERR("Invalid type for %s", n->id); @@ -685,7 +685,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, if (!sname) return -ENOMEM; err = snd_pcm_open(&spcm, sname, stream, mode); - free(sname); + free((void *) sname); if (err < 0) return err; err = snd_pcm_rate_open(pcmp, name, sformat, srate, spcm, 1); diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 4e7b0623..49f56f6f 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -883,7 +883,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; int err; snd_pcm_t *spcm; snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN; @@ -908,7 +908,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name, continue; } if (strcmp(n->id, "sformat") == 0) { - char *f; + const char *f; err = snd_config_string_get(n, &f); if (err < 0) { ERR("Invalid type for %s", n->id); @@ -963,7 +963,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name, if (!sname) return -ENOMEM; err = snd_pcm_open(&spcm, sname, stream, mode); - free(sname); + free((void *) sname); if (err < 0) return err; err = snd_pcm_route_open(pcmp, name, sformat, schannels, diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c index f247a4de..1e806c02 100644 --- a/src/pcm/pcm_share.c +++ b/src/pcm/pcm_share.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -1181,7 +1180,7 @@ snd_pcm_fast_ops_t snd_pcm_share_fast_ops = { mmap_forward: snd_pcm_share_mmap_forward, }; -int snd_pcm_share_open(snd_pcm_t **pcmp, char *name, char *sname, +int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname, snd_pcm_format_t sformat, int srate, unsigned int schannels_count, unsigned int channels_count, int *channels_map, @@ -1363,7 +1362,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *sname = NULL; + const char *sname = NULL; snd_config_t *binding = NULL; int err; unsigned int idx; @@ -1391,7 +1390,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, continue; } if (strcmp(n->id, "sformat") == 0) { - char *f; + const char *f; err = snd_config_string_get(n, &f); if (err < 0) { ERR("Invalid type for %s", n->id); diff --git a/src/pcm/pcm_shm.c b/src/pcm/pcm_shm.c index b1f595b3..5fe9d5a1 100644 --- a/src/pcm/pcm_shm.c +++ b/src/pcm/pcm_shm.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -564,7 +563,7 @@ static int make_inet_socket(const char *host, int port) } #endif -int snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, char *socket, char *sname, snd_pcm_stream_t stream, int mode) +int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, const char *socket, const char *sname, snd_pcm_stream_t stream, int mode) { snd_pcm_t *pcm; snd_pcm_shm_t *shm = NULL; @@ -721,11 +720,11 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i; - char *server = NULL; - char *sname = NULL; + const char *server = NULL; + const char *sname = NULL; snd_config_t *sconfig; - char *host = NULL; - char *socket = NULL; + const char *host = NULL; + const char *socket = NULL; long port = -1; int err; int local; diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 6e3b78ea..db8caf48 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include "rawmidi_local.h" @@ -162,13 +161,13 @@ int snd_rawmidi_params_default(snd_rawmidi_t *rmidi, snd_rawmidi_stream_t stream int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name, int streams, int mode) { - char *str; + const char *str; int err; snd_config_t *rawmidi_conf, *conf, *type_conf; snd_config_iterator_t i; snd_rawmidi_params_t params; unsigned int stream; - char *lib = NULL, *open = NULL; + const char *lib = NULL, *open = NULL; int (*open_func)(snd_rawmidi_t **rawmidip, char *name, snd_config_t *conf, int streams, int mode); void *h; diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c index 561d5cdc..46777757 100644 --- a/src/rawmidi/rawmidi_hw.c +++ b/src/rawmidi/rawmidi_hw.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include "../control/control_local.h" @@ -276,7 +275,7 @@ int _snd_rawmidi_hw_open(snd_rawmidi_t **handlep, char *name, snd_config_t *conf { snd_config_iterator_t i; long card = -1, device = 0, subdevice = -1; - char *str; + const char *str; int err; snd_config_foreach(i, conf) { snd_config_t *n = snd_config_entry(i); diff --git a/src/rawmidi/rawmidi_local.h b/src/rawmidi/rawmidi_local.h index 8904fadf..2e987458 100644 --- a/src/rawmidi/rawmidi_local.h +++ b/src/rawmidi/rawmidi_local.h @@ -19,11 +19,9 @@ * */ -#include #include #include #include -#include #include "local.h" typedef struct { diff --git a/src/rawmidi/rawmidi_m4.c b/src/rawmidi/rawmidi_m4.c index 2d484d87..e88c8721 100644 --- a/src/rawmidi/rawmidi_m4.c +++ b/src/rawmidi/rawmidi_m4.c @@ -29,7 +29,7 @@ size_t snd_rawmidi_params_sizeof() int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_rawmidi_params_t)); + *ptr = calloc(1, sizeof(snd_rawmidi_params_t)); if (!*ptr) return -ENOMEM; return 0; @@ -98,7 +98,7 @@ size_t snd_rawmidi_info_sizeof() int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_rawmidi_info_t)); + *ptr = calloc(1, sizeof(snd_rawmidi_info_t)); if (!*ptr) return -ENOMEM; return 0; @@ -145,19 +145,19 @@ unsigned int snd_rawmidi_info_get_flags(const snd_rawmidi_info_t *obj) return obj->flags; } -const char * snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj) +const char *snd_rawmidi_info_get_id(const snd_rawmidi_info_t *obj) { assert(obj); return obj->id; } -const char * snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj) +const char *snd_rawmidi_info_get_name(const snd_rawmidi_info_t *obj) { assert(obj); return obj->name; } -const char * snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj) +const char *snd_rawmidi_info_get_subdevice_name(const snd_rawmidi_info_t *obj) { assert(obj); return obj->subname; @@ -201,7 +201,7 @@ size_t snd_rawmidi_status_sizeof() int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr) { assert(ptr); - *ptr = malloc(sizeof(snd_rawmidi_status_t)); + *ptr = calloc(1, sizeof(snd_rawmidi_status_t)); if (!*ptr) return -ENOMEM; return 0; diff --git a/src/seq/seq.c b/src/seq/seq.c index dbae1619..3e7e2413 100644 --- a/src/seq/seq.c +++ b/src/seq/seq.c @@ -27,11 +27,11 @@ int snd_seq_open(snd_seq_t **seqp, char *name, int streams, int mode) { - char *str; + const char *str; int err; snd_config_t *seq_conf, *conf, *type_conf; snd_config_iterator_t i; - char *lib = NULL, *open = NULL; + const char *lib = NULL, *open = NULL; int (*open_func)(snd_seq_t **seqp, char *name, snd_config_t *conf, int streams, int mode); void *h; diff --git a/src/seq/seq_local.h b/src/seq/seq_local.h index 02a67882..ee515f7f 100644 --- a/src/seq/seq_local.h +++ b/src/seq/seq_local.h @@ -23,11 +23,9 @@ #ifndef __SEQ_LOCAL_H #define __SEQ_LOCAL_H -#include #include #include #include -#include #include "local.h" #define SND_SEQ_OBUF_SIZE (16*1024) /* default size */ diff --git a/src/seq/seq_midi_event.c b/src/seq/seq_midi_event.c index eb4513b1..59cd165e 100644 --- a/src/seq/seq_midi_event.c +++ b/src/seq/seq_midi_event.c @@ -20,7 +20,6 @@ */ #include -#include #include "local.h" diff --git a/src/seq/seqmid.c b/src/seq/seqmid.c index 965b8c2e..64e79c59 100644 --- a/src/seq/seqmid.c +++ b/src/seq/seqmid.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include "seq_local.h" diff --git a/src/timer/timer.c b/src/timer/timer.c index 5861b2fe..45b701d1 100644 --- a/src/timer/timer.c +++ b/src/timer/timer.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include "local.h" diff --git a/test/control.c b/test/control.c index 24e4d78d..506ec802 100644 --- a/test/control.c +++ b/test/control.c @@ -6,7 +6,7 @@ int main(void) { int idx, idx1, cards, err; snd_ctl_t *handle; - snd_ctl_hw_info_t info; + snd_ctl_info_t info; snd_pcm_info_t pcminfo; snd_mixer_info_t mixerinfo; snd_rawmidi_info_t rawmidiinfo; @@ -23,7 +23,7 @@ int main(void) printf("Open error: %s\n", snd_strerror(err)); continue; } - if ((err = snd_ctl_hw_info(handle, &info)) < 0) { + if ((err = snd_ctl_info(handle, &info)) < 0) { printf("HW info error: %s\n", snd_strerror(err)); continue; } diff --git a/test/mixer.c b/test/mixer.c index 9cdd82be..b60e1445 100644 --- a/test/mixer.c +++ b/test/mixer.c @@ -32,7 +32,7 @@ int main(void) { int idx, idx1, cards, err; snd_ctl_t *handle; - snd_ctl_hw_info_t info; + snd_ctl_info_t info; cards = snd_cards(); printf("Detected %i soundcard%s...\n", cards, cards > 1 ? "s" : ""); @@ -45,7 +45,7 @@ int main(void) printf("Open error: %s\n", snd_strerror(err)); continue; } - if ((err = snd_ctl_hw_info(handle, &info)) < 0) { + if ((err = snd_ctl_info(handle, &info)) < 0) { printf("HW info error: %s\n", snd_strerror(err)); continue; } diff --git a/test/switches.c b/test/switches.c index e3744c97..140899a2 100644 --- a/test/switches.c +++ b/test/switches.c @@ -108,7 +108,7 @@ int main(void) { snd_ctl_t *ctl_handle; int cards, card, err, idx; - snd_ctl_hw_info_t info; + snd_ctl_info_t info; cards = snd_cards(); printf("Detected %i soundcard%s...\n", cards, cards > 1 ? "s" : ""); @@ -122,7 +122,7 @@ int main(void) printf("CTL open error: %s\n", snd_strerror(err)); continue; } - if ((err = snd_ctl_hw_info(ctl_handle, &info)) < 0) { + if ((err = snd_ctl_info(ctl_handle, &info)) < 0) { printf("HWINFO error: %s\n", snd_strerror(err)); continue; } -- 2.47.3