summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo@alsa-project.org>2001-02-11 15:45:35 +0000
committerAbramo Bagnara <abramo@alsa-project.org>2001-02-11 15:45:35 +0000
commita2d34349619fd652a15219f4239794ef87d78236 (patch)
tree21ec219a5a0971e89045483e9718466e68310cb7
parent38033b49dd969cd65a39174cc8554380df30152b (diff)
downloadalsa-lib-a2d34349619fd652a15219f4239794ef87d78236.tar.gz
Completed mixer API. Improved iterators. Renamed control values struct. Rewritten simple elements implementation
-rw-r--r--aserver/aserver.c8
-rw-r--r--include/aserver.h4
-rw-r--r--include/conf.h8
-rw-r--r--include/control.h41
-rw-r--r--include/control_m4.h66
-rw-r--r--include/list.h5
-rw-r--r--include/local.h2
-rw-r--r--include/mixer.h100
-rw-r--r--include/mixer_m4.h36
-rw-r--r--include/pcm.h2
-rw-r--r--include/rawmidi.h4
-rw-r--r--include/seq.h10
-rw-r--r--include/seqmid.h6
-rw-r--r--src/conf.c14
-rw-r--r--src/control/control.c30
-rw-r--r--src/control/control_hw.c46
-rw-r--r--src/control/control_local.h16
-rw-r--r--src/control/control_m4.c87
-rw-r--r--src/control/control_shm.c50
-rw-r--r--src/control/hcontrol.c203
-rw-r--r--src/input.c26
-rw-r--r--src/mixer/bag.c76
-rw-r--r--src/mixer/mixer.c327
-rw-r--r--src/mixer/mixer_local.h90
-rw-r--r--src/mixer/mixer_m4.c71
-rw-r--r--src/mixer/simple.c1387
-rw-r--r--src/output.c30
-rw-r--r--src/pcm/pcm.c25
-rw-r--r--src/pcm/pcm_adpcm.c30
-rw-r--r--src/pcm/pcm_alaw.c26
-rw-r--r--src/pcm/pcm_copy.c16
-rw-r--r--src/pcm/pcm_file.c64
-rw-r--r--src/pcm/pcm_hw.c68
-rw-r--r--src/pcm/pcm_linear.c22
-rw-r--r--src/pcm/pcm_local.h2
-rw-r--r--src/pcm/pcm_mmap.c2
-rw-r--r--src/pcm/pcm_mulaw.c26
-rw-r--r--src/pcm/pcm_multi.c76
-rw-r--r--src/pcm/pcm_null.c44
-rw-r--r--src/pcm/pcm_params.c80
-rw-r--r--src/pcm/pcm_plug.c42
-rw-r--r--src/pcm/pcm_plugin.c56
-rw-r--r--src/pcm/pcm_plugin.h14
-rw-r--r--src/pcm/pcm_rate.c40
-rw-r--r--src/pcm/pcm_route.c41
-rw-r--r--src/pcm/pcm_share.c68
-rw-r--r--src/pcm/pcm_shm.c56
-rw-r--r--src/rawmidi/rawmidi.c20
-rw-r--r--src/rawmidi/rawmidi_hw.c28
-rw-r--r--src/rawmidi/rawmidi_local.h4
-rw-r--r--src/seq/seq.c24
-rw-r--r--src/seq/seq_hw.c78
-rw-r--r--src/seq/seq_local.h4
-rw-r--r--src/seq/seqmid.c6
54 files changed, 2038 insertions, 1669 deletions
diff --git a/aserver/aserver.c b/aserver/aserver.c
index 90f18650..d9663d9c 100644
--- a/aserver/aserver.c
+++ b/aserver/aserver.c
@@ -753,7 +753,7 @@ int inet_pending_handler(waiter_t *waiter, unsigned short events)
inet_pending_t *pdata;
client_t *client;
uint32_t cookie;
- struct list_head *item;
+ struct list_head *item, *next;
int remove = 0;
if (events & POLLHUP)
remove = 1;
@@ -775,7 +775,7 @@ int inet_pending_handler(waiter_t *waiter, unsigned short events)
return 0;
}
- list_for_each(item, &inet_pendings) {
+ list_for_each(item, next, &inet_pendings) {
pdata = list_entry(item, inet_pending_t, list);
if (pdata->cookie == cookie)
goto found;
@@ -937,7 +937,7 @@ int main(int argc, char **argv)
};
int c;
snd_config_t *conf;
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *socket = NULL;
const char *host = NULL;
long port = -1;
@@ -970,7 +970,7 @@ int main(int argc, char **argv)
ERROR("Missing definition for server %s", srvname);
return 1;
}
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/include/aserver.h b/include/aserver.h
index b564ecc0..05242117 100644
--- a/include/aserver.h
+++ b/include/aserver.h
@@ -97,8 +97,8 @@ typedef struct {
snd_ctl_card_info_t hw_info;
snd_ctl_elem_list_t element_list;
snd_ctl_elem_info_t element_info;
- snd_ctl_elem_t element_read;
- snd_ctl_elem_t element_write;
+ snd_ctl_elem_value_t element_read;
+ snd_ctl_elem_value_t element_write;
snd_hwdep_info_t hwdep_info;
snd_pcm_info_t pcm_info;
int pcm_prefer_subdevice;
diff --git a/include/conf.h b/include/conf.h
index 8ad0d24d..139ebfef 100644
--- a/include/conf.h
+++ b/include/conf.h
@@ -25,7 +25,7 @@ extern "C" {
#endif
snd_config_type_t snd_config_get_type(snd_config_t *config);
-char *snd_config_get_id(snd_config_t *config);
+const char *snd_config_get_id(snd_config_t *config);
int snd_config_top(snd_config_t **config);
@@ -59,11 +59,11 @@ snd_config_iterator_t snd_config_iterator_next(snd_config_iterator_t iterator);
snd_config_iterator_t snd_config_iterator_end(snd_config_t *node);
snd_config_t *snd_config_iterator_entry(snd_config_iterator_t iterator);
-#define snd_config_foreach(iterator, node) \
- for (iterator = snd_config_iterator_first(node); iterator != snd_config_iterator_end(node); iterator = snd_config_iterator_next(iterator))
+#define snd_config_for_each(pos, next, node) \
+ for (pos = snd_config_iterator_first(node), next = snd_config_iterator_next(pos); pos != snd_config_iterator_end(node); pos = next, next = snd_config_iterator_next(pos))
snd_config_type_t snd_config_get_type(snd_config_t *config);
-char *snd_config_get_id(snd_config_t *config);
+const char *snd_config_get_id(snd_config_t *config);
extern snd_config_t *snd_config;
int snd_config_update();
diff --git a/include/control.h b/include/control.h
index abba2828..35e934c8 100644
--- a/include/control.h
+++ b/include/control.h
@@ -10,7 +10,7 @@ typedef struct _snd_ctl_card_info snd_ctl_card_info_t;
typedef struct _snd_ctl_elem_id snd_ctl_elem_id_t;
typedef struct _snd_ctl_elem_list snd_ctl_elem_list_t;
typedef struct _snd_ctl_elem_info snd_ctl_elem_info_t;
-typedef struct _snd_ctl_elem snd_ctl_elem_t;
+typedef struct _snd_ctl_elem_value snd_ctl_elem_value_t;
typedef struct _snd_ctl_event snd_ctl_event_t;
#ifdef SND_ENUM_TYPECHECK
@@ -114,7 +114,7 @@ typedef enum sndrv_ctl_event_type snd_ctl_event_type_t;
#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_INFO ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_INFO)
#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_CTL_EVENT_LAST ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_LAST)
@@ -155,7 +155,7 @@ int snd_defaults_rawmidi_card(void);
int snd_defaults_rawmidi_device(void);
snd_ctl_type_t snd_ctl_type(snd_ctl_t *ctl);
-int snd_ctl_open(snd_ctl_t **ctl, char *name);
+int snd_ctl_open(snd_ctl_t **ctl, const char *name);
int snd_ctl_close(snd_ctl_t *ctl);
int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock);
int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid);
@@ -163,8 +163,8 @@ int snd_ctl_poll_descriptor(snd_ctl_t *ctl);
int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info);
int snd_ctl_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t * list);
int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info);
-int snd_ctl_elem_read(snd_ctl_t *ctl, snd_ctl_elem_t *value);
-int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_t *value);
+int snd_ctl_elem_read(snd_ctl_t *ctl, snd_ctl_elem_value_t *value);
+int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *value);
int snd_ctl_hwdep_next_device(snd_ctl_t *ctl, int * device);
int snd_ctl_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info);
int snd_ctl_pcm_next_device(snd_ctl_t *ctl, int *device);
@@ -176,9 +176,10 @@ int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev);
int snd_ctl_read(snd_ctl_t *ctl, snd_ctl_event_t *event);
int snd_ctl_wait(snd_ctl_t *ctl, int timeout);
+const char *snd_ctl_name(snd_ctl_t *ctl);
+snd_ctl_type_t snd_ctl_type(snd_ctl_t *ctl);
-void snd_ctl_elem_set_bytes(snd_ctl_elem_t *obj, void *data, size_t size);
-
+void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t *obj, void *data, size_t size);
const char *snd_ctl_elem_type_name(snd_ctl_elem_type_t type);
const char *snd_ctl_elem_iface_name(snd_ctl_elem_iface_t iface);
const char *snd_ctl_event_type_name(snd_ctl_event_type_t type);
@@ -210,25 +211,31 @@ typedef int (*snd_hctl_callback_t)(snd_hctl_t *hctl,
typedef int (*snd_hctl_elem_callback_t)(snd_hctl_elem_t *elem,
snd_ctl_event_type_t event);
-int snd_hctl_open(snd_hctl_t **hctl, char *name);
+int snd_hctl_open(snd_hctl_t **hctl, const char *name);
int snd_hctl_close(snd_hctl_t *hctl);
int snd_hctl_nonblock(snd_hctl_t *hctl, int nonblock);
int snd_hctl_async(snd_hctl_t *hctl, int sig, pid_t pid);
int snd_hctl_poll_descriptor(snd_hctl_t *hctl);
+unsigned int snd_hctl_get_count(snd_hctl_t *ctl);
+void snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t hsort);
snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl);
snd_hctl_elem_t *snd_hctl_last_elem(snd_hctl_t *hctl);
-snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem);
-snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem);
-int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t * info);
-int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_t * value);
-int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_t * value);
-unsigned int snd_hctl_get_count(snd_hctl_t *ctl);
snd_hctl_elem_t *snd_hctl_find_elem(snd_hctl_t *ctl, const snd_ctl_elem_id_t *id);
void snd_hctl_set_callback(snd_hctl_t *ctl, snd_hctl_callback_t callback);
-void snd_hctl_set_callback_private(snd_hctl_t *ctl, void *private);
+void snd_hctl_set_callback_private(snd_hctl_t *ctl, void *data);
void *snd_hctl_get_callback_private(snd_hctl_t *ctl);
-int snd_hctl_event(snd_hctl_t *ctl, snd_ctl_event_t *event);
-int snd_hctl_events(snd_hctl_t *ctl);
+int snd_hctl_load(snd_hctl_t *ctl);
+int snd_hctl_free(snd_hctl_t *ctl);
+int snd_hctl_handle_event(snd_hctl_t *ctl, snd_ctl_event_t *event);
+int snd_hctl_handle_events(snd_hctl_t *ctl);
+const char *snd_hctl_name(snd_hctl_t *hctl);
+snd_ctl_type_t snd_hctl_type(snd_hctl_t *hctl);
+
+snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem);
+snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem);
+int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t * info);
+int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value);
+int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value);
#ifdef __cplusplus
}
diff --git a/include/control_m4.h b/include/control_m4.h
index c9abc114..0a911bf4 100644
--- a/include/control_m4.h
+++ b/include/control_m4.h
@@ -164,67 +164,61 @@ void snd_ctl_elem_info_set_name(snd_ctl_elem_info_t *obj, const char *val);
void snd_ctl_elem_info_set_index(snd_ctl_elem_info_t *obj, unsigned int val);
-size_t snd_ctl_elem_sizeof();
-#define snd_ctl_elem_alloca(ptr) ({ assert(ptr); *ptr = (snd_ctl_elem_t *) alloca(snd_ctl_elem_sizeof()); memset(*ptr, 0, snd_ctl_elem_sizeof()); 0; })
-int snd_ctl_elem_malloc(snd_ctl_elem_t **ptr);
-void snd_ctl_elem_free(snd_ctl_elem_t *obj);
-void snd_ctl_elem_copy(snd_ctl_elem_t *dst, const snd_ctl_elem_t *src);
+size_t snd_ctl_elem_value_sizeof();
+#define snd_ctl_elem_value_alloca(ptr) ({ assert(ptr); *ptr = (snd_ctl_elem_value_t *) alloca(snd_ctl_elem_value_sizeof()); memset(*ptr, 0, snd_ctl_elem_value_sizeof()); 0; })
+int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr);
+void snd_ctl_elem_value_free(snd_ctl_elem_value_t *obj);
+void snd_ctl_elem_value_copy(snd_ctl_elem_value_t *dst, const snd_ctl_elem_value_t *src);
-void snd_ctl_elem_get_id(const snd_ctl_elem_t *obj, snd_ctl_elem_id_t *ptr);
+void snd_ctl_elem_value_get_id(const snd_ctl_elem_value_t *obj, snd_ctl_elem_id_t *ptr);
-unsigned int snd_ctl_elem_get_numid(const snd_ctl_elem_t *obj);
+unsigned int snd_ctl_elem_value_get_numid(const snd_ctl_elem_value_t *obj);
-snd_ctl_elem_iface_t snd_ctl_elem_get_interface(const snd_ctl_elem_t *obj);
+snd_ctl_elem_iface_t snd_ctl_elem_value_get_interface(const snd_ctl_elem_value_t *obj);
-unsigned int snd_ctl_elem_get_device(const snd_ctl_elem_t *obj);
+unsigned int snd_ctl_elem_value_get_device(const snd_ctl_elem_value_t *obj);
-unsigned int snd_ctl_elem_get_subdevice(const snd_ctl_elem_t *obj);
+unsigned int snd_ctl_elem_value_get_subdevice(const snd_ctl_elem_value_t *obj);
-const char *snd_ctl_elem_get_name(const snd_ctl_elem_t *obj);
+const char *snd_ctl_elem_value_get_name(const snd_ctl_elem_value_t *obj);
-unsigned int snd_ctl_elem_get_index(const snd_ctl_elem_t *obj);
+unsigned int snd_ctl_elem_value_get_index(const snd_ctl_elem_value_t *obj);
-void snd_ctl_elem_set_id(snd_ctl_elem_t *obj, const snd_ctl_elem_id_t *ptr);
+void snd_ctl_elem_value_set_id(snd_ctl_elem_value_t *obj, const snd_ctl_elem_id_t *ptr);
-void snd_ctl_elem_set_numid(snd_ctl_elem_t *obj, unsigned int val);
+void snd_ctl_elem_value_set_numid(snd_ctl_elem_value_t *obj, unsigned int val);
-void snd_ctl_elem_set_interface(snd_ctl_elem_t *obj, snd_ctl_elem_iface_t val);
+void snd_ctl_elem_value_set_interface(snd_ctl_elem_value_t *obj, snd_ctl_elem_iface_t val);
-void snd_ctl_elem_set_device(snd_ctl_elem_t *obj, unsigned int val);
+void snd_ctl_elem_value_set_device(snd_ctl_elem_value_t *obj, unsigned int val);
-void snd_ctl_elem_set_subdevice(snd_ctl_elem_t *obj, unsigned int val);
+void snd_ctl_elem_value_set_subdevice(snd_ctl_elem_value_t *obj, unsigned int val);
-void snd_ctl_elem_set_name(snd_ctl_elem_t *obj, const char *val);
+void snd_ctl_elem_value_set_name(snd_ctl_elem_value_t *obj, const char *val);
-void snd_ctl_elem_set_index(snd_ctl_elem_t *obj, unsigned int val);
+void snd_ctl_elem_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val);
-long snd_ctl_elem_get_boolean(const snd_ctl_elem_t *obj, unsigned int idx);
+long snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int idx);
-long snd_ctl_elem_get_integer(const snd_ctl_elem_t *obj, unsigned int idx);
+long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_t *obj, unsigned int idx);
-unsigned int snd_ctl_elem_get_enumerated(const snd_ctl_elem_t *obj, unsigned int idx);
+unsigned int snd_ctl_elem_value_get_enumerated(const snd_ctl_elem_value_t *obj, unsigned int idx);
-unsigned char snd_ctl_elem_get_byte(const snd_ctl_elem_t *obj, unsigned int idx);
+unsigned char snd_ctl_elem_value_get_byte(const snd_ctl_elem_value_t *obj, unsigned int idx);
-void snd_ctl_elem_set_boolean(snd_ctl_elem_t *obj, unsigned int idx, long val);
+void snd_ctl_elem_value_set_boolean(snd_ctl_elem_value_t *obj, unsigned int idx, long val);
-void snd_ctl_elem_set_integer(snd_ctl_elem_t *obj, unsigned int idx, long val);
+void snd_ctl_elem_value_set_integer(snd_ctl_elem_value_t *obj, unsigned int idx, long val);
-void snd_ctl_elem_set_enumerated(snd_ctl_elem_t *obj, unsigned int idx, unsigned int val);
+void snd_ctl_elem_value_set_enumerated(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned int val);
-void snd_ctl_elem_set_byte(snd_ctl_elem_t *obj, unsigned int idx, unsigned char val);
+void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned char val);
-const void * snd_ctl_elem_get_bytes(const snd_ctl_elem_t *obj);
+const void * snd_ctl_elem_value_get_bytes(const snd_ctl_elem_value_t *obj);
-void snd_ctl_elem_get_iec958(const snd_ctl_elem_t *obj, snd_aes_iec958_t *ptr);
+void snd_ctl_elem_value_get_iec958(const snd_ctl_elem_value_t *obj, snd_aes_iec958_t *ptr);
-void snd_ctl_elem_set_iec958(snd_ctl_elem_t *obj, const snd_aes_iec958_t *ptr);
-
-size_t snd_hctl_elem_sizeof();
-#define snd_hctl_elem_alloca(ptr) ({ assert(ptr); *ptr = (snd_hctl_elem_t *) alloca(snd_hctl_elem_sizeof()); memset(*ptr, 0, snd_hctl_elem_sizeof()); 0; })
-int snd_hctl_elem_malloc(snd_hctl_elem_t **ptr);
-void snd_hctl_elem_free(snd_hctl_elem_t *obj);
-void snd_hctl_elem_copy(snd_hctl_elem_t *dst, const snd_hctl_elem_t *src);
+void snd_ctl_elem_value_set_iec958(snd_ctl_elem_value_t *obj, const snd_aes_iec958_t *ptr);
void snd_hctl_elem_get_id(const snd_hctl_elem_t *obj, snd_ctl_elem_id_t *ptr);
diff --git a/include/list.h b/include/list.h
index 5f4da883..90f54951 100644
--- a/include/list.h
+++ b/include/list.h
@@ -139,10 +139,11 @@ static __inline__ void list_splice(struct list_head *list, struct list_head *hea
/**
* list_for_each - iterate over a list
* @pos: the &struct list_head to use as a loop counter.
+ * @next: the &struct list_head to use to save next.
* @head: the head for your list.
*/
-#define list_for_each(pos, head) \
- for (pos = (head)->next; pos != (head); pos = pos->next)
+#define list_for_each(pos, npos, head) \
+ for (pos = (head)->next, npos = pos->next ; pos != (head); pos = npos, npos = pos->next)
/**
* list_entry - get the struct for this entry
diff --git a/include/local.h b/include/local.h
index 667fa7ae..38b1b22e 100644
--- a/include/local.h
+++ b/include/local.h
@@ -32,7 +32,7 @@
#define _snd_ctl_elem_id sndrv_ctl_elem_id
#define _snd_ctl_elem_list sndrv_ctl_elem_list
#define _snd_ctl_elem_info sndrv_ctl_elem_info
-#define _snd_ctl_elem sndrv_ctl_elem
+#define _snd_ctl_elem_value sndrv_ctl_elem_value
#define _snd_ctl_event sndrv_ctl_event
#define _snd_rawmidi_info sndrv_rawmidi_info
diff --git a/include/mixer.h b/include/mixer.h
index d97df68c..3b023139 100644
--- a/include/mixer.h
+++ b/include/mixer.h
@@ -6,6 +6,7 @@
****************************************************************************/
typedef struct _snd_mixer snd_mixer_t;
+typedef struct _snd_mixer_class snd_mixer_class_t;
typedef struct _snd_mixer_info snd_mixer_info_t;
typedef struct _snd_mixer_elem snd_mixer_elem_t;
typedef int (*snd_mixer_callback_t)(snd_mixer_t *ctl,
@@ -13,6 +14,8 @@ typedef int (*snd_mixer_callback_t)(snd_mixer_t *ctl,
snd_mixer_elem_t *elem);
typedef int (*snd_mixer_elem_callback_t)(snd_mixer_elem_t *elem,
snd_ctl_event_type_t event);
+typedef int (*snd_mixer_compare_t)(const snd_mixer_elem_t *e1,
+ const snd_mixer_elem_t *e2);
enum _snd_mixer_elem_type {
SND_MIXER_ELEM_SIMPLE,
@@ -33,15 +36,22 @@ typedef enum _snd_mixer_elem_type snd_mixer_elem_type_t;
extern "C" {
#endif
-int snd_mixer_open(snd_mixer_t **mixer, char *name);
+int snd_mixer_open(snd_mixer_t **mixer);
int snd_mixer_close(snd_mixer_t *mixer);
-int snd_mixer_poll_descriptor(snd_mixer_t *mixer);
int snd_mixer_info(snd_mixer_t *mixer, snd_mixer_info_t *info);
snd_mixer_elem_t *snd_mixer_first_elem(snd_mixer_t *mixer);
snd_mixer_elem_t *snd_mixer_last_elem(snd_mixer_t *mixer);
+int snd_mixer_handle_events(snd_mixer_t *mixer);
+int snd_mixer_attach(snd_mixer_t *mixer, const char *name);
+int snd_mixer_detach(snd_mixer_t *mixer, const char *name);
+int snd_mixer_poll_descriptor(snd_mixer_t *mixer, const char *name);
+int snd_mixer_load(snd_mixer_t *mixer);
+void snd_mixer_set_compare(snd_hctl_t *hctl, snd_mixer_compare_t hsort);
+
snd_mixer_elem_t *snd_mixer_elem_next(snd_mixer_elem_t *elem);
snd_mixer_elem_t *snd_mixer_elem_prev(snd_mixer_elem_t *helem);
-int snd_mixer_events(snd_mixer_t *mixer);
+
+int snd_mixer_class_unregister(snd_mixer_class_t *clss);
#ifdef __cplusplus
}
@@ -51,65 +61,69 @@ int snd_mixer_events(snd_mixer_t *mixer);
* Simple (legacy) mixer API
*/
-enum _snd_mixer_channel_id {
- SND_MIXER_CHN_UNKNOWN = -1,
- SND_MIXER_CHN_FRONT_LEFT = 0,
- SND_MIXER_CHN_FRONT_RIGHT,
- SND_MIXER_CHN_FRONT_CENTER,
- SND_MIXER_CHN_REAR_LEFT,
- SND_MIXER_CHN_REAR_RIGHT,
- SND_MIXER_CHN_WOOFER,
- SND_MIXER_CHN_LAST = 31,
- SND_MIXER_CHN_MONO = SND_MIXER_CHN_FRONT_LEFT
+enum _snd_mixer_selem_channel_id {
+ SND_MIXER_SCHN_UNKNOWN = -1,
+ SND_MIXER_SCHN_FRONT_LEFT = 0,
+ SND_MIXER_SCHN_FRONT_RIGHT,
+ SND_MIXER_SCHN_FRONT_CENTER,
+ SND_MIXER_SCHN_REAR_LEFT,
+ SND_MIXER_SCHN_REAR_RIGHT,
+ SND_MIXER_SCHN_WOOFER,
+ SND_MIXER_SCHN_LAST = 31,
+ SND_MIXER_SCHN_MONO = SND_MIXER_SCHN_FRONT_LEFT
};
/* Simple mixer */
-typedef struct _snd_mixer_selem snd_mixer_selem_t;
+typedef struct _snd_mixer_selem_info snd_mixer_selem_info_t;
+typedef struct _snd_mixer_selem_value snd_mixer_selem_value_t;
typedef struct _snd_mixer_selem_id snd_mixer_selem_id_t;
#ifdef SND_ENUM_TYPECHECK
-typedef struct __snd_mixer_channel_id *snd_mixer_channel_id_t;
+typedef struct __snd_mixer_selem_channel_id *snd_mixer_selem_channel_id_t;
#else
-typedef enum _snd_mixer_channel_id snd_mixer_channel_id_t;
+typedef enum _snd_mixer_selem_channel_id snd_mixer_selem_channel_id_t;
#endif
-#define SND_MIXER_CHN_UNKNOWN ((snd_mixer_channel_id_t) SND_MIXER_CHN_UNKNOWN)
-#define SND_MIXER_CHN_FRONT_LEFT ((snd_mixer_channel_id_t) SND_MIXER_CHN_FRONT_LEFT)
-#define SND_MIXER_CHN_FRONT_RIGHT ((snd_mixer_channel_id_t) SND_MIXER_CHN_FRONT_RIGHT)
-#define SND_MIXER_CHN_FRONT_CENTER ((snd_mixer_channel_id_t) SND_MIXER_CHN_FRONT_CENTER)
-#define SND_MIXER_CHN_REAR_LEFT ((snd_mixer_channel_id_t) SND_MIXER_CHN_REAR_LEFT)
-#define SND_MIXER_CHN_REAR_RIGHT ((snd_mixer_channel_id_t) SND_MIXER_CHN_REAR_RIGHT)
-#define SND_MIXER_CHN_WOOFER ((snd_mixer_channel_id_t) SND_MIXER_CHN_WOOFER)
-#define SND_MIXER_CHN_LAST ((snd_mixer_channel_id_t) SND_MIXER_CHN_LAST)
-#define SND_MIXER_CHN_MONO ((snd_mixer_channel_id_t) SND_MIXER_CHN_MONO)
+#define SND_MIXER_SCHN_UNKNOWN ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_UNKNOWN)
+#define SND_MIXER_SCHN_FRONT_LEFT ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_FRONT_LEFT)
+#define SND_MIXER_SCHN_FRONT_RIGHT ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_FRONT_RIGHT)
+#define SND_MIXER_SCHN_FRONT_CENTER ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_FRONT_CENTER)
+#define SND_MIXER_SCHN_REAR_LEFT ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_REAR_LEFT)
+#define SND_MIXER_SCHN_REAR_RIGHT ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_REAR_RIGHT)
+#define SND_MIXER_SCHN_WOOFER ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_WOOFER)
+#define SND_MIXER_SCHN_LAST ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_LAST)
+#define SND_MIXER_SCHN_MONO ((snd_mixer_selem_channel_id_t) SND_MIXER_SCHN_MONO)
#ifdef __cplusplus
extern "C" {
#endif
-const char *snd_mixer_channel_name(snd_mixer_channel_id_t channel);
-int snd_mixer_simple_build(snd_mixer_t *mixer);
-snd_mixer_elem_t *snd_mixer_find_selem(snd_mixer_t *mixer,
- const snd_mixer_selem_id_t *id);
+const char *snd_mixer_selem_channel_name(snd_mixer_selem_channel_id_t channel);
+
+int snd_mixer_selem_register(snd_mixer_t *mixer, snd_mixer_class_t **classp);
void snd_mixer_selem_get_id(snd_mixer_elem_t *element,
snd_mixer_selem_id_t *id);
+snd_mixer_elem_t *snd_mixer_find_selem(snd_mixer_t *mixer,
+ const snd_mixer_selem_id_t *id);
+int snd_mixer_selem_info(snd_mixer_elem_t *element,
+ snd_mixer_selem_info_t *info);
int snd_mixer_selem_read(snd_mixer_elem_t *element,
- snd_mixer_selem_t *simple);
+ snd_mixer_selem_value_t *value);
int snd_mixer_selem_write(snd_mixer_elem_t *element,
- const snd_mixer_selem_t *simple);
-
-int snd_mixer_selem_is_mono(const snd_mixer_selem_t *obj);
-int snd_mixer_selem_has_channel(const snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel);
-long snd_mixer_selem_get_volume(const snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel);
-void snd_mixer_selem_set_volume(snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel, long value);
-int snd_mixer_selem_get_mute(const snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel);
-int snd_mixer_selem_get_capture(const snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel);
-void snd_mixer_selem_set_mute(snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel, int mute);
-void snd_mixer_selem_set_capture(snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel, int capture);
-void snd_mixer_selem_set_mute_all(snd_mixer_selem_t *obj, int mute);
-void snd_mixer_selem_set_capture_all(snd_mixer_selem_t *obj, int capture);
-void snd_mixer_selem_set_volume_all(snd_mixer_selem_t *obj, long value);
+ const snd_mixer_selem_value_t *value);
+
+int snd_mixer_selem_info_is_mono(const snd_mixer_selem_info_t *info);
+int snd_mixer_selem_info_has_channel(const snd_mixer_selem_info_t *obj, snd_mixer_selem_channel_id_t channel);
+long snd_mixer_selem_value_get_volume(const snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel);
+void snd_mixer_selem_value_set_volume(snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel, long value);
+int snd_mixer_selem_value_get_mute(const snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel);
+int snd_mixer_selem_value_get_capture(const snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel);
+void snd_mixer_selem_value_set_mute(snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel, int mute);
+void snd_mixer_selem_value_set_capture(snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel, int capture);
+void snd_mixer_selem_value_set_mute_all(snd_mixer_selem_value_t *obj, int mute);
+void snd_mixer_selem_value_set_capture_all(snd_mixer_selem_value_t *obj, int capture);
+void snd_mixer_selem_value_set_volume_all(snd_mixer_selem_value_t *obj, long value);
#ifdef __cplusplus
}
diff --git a/include/mixer_m4.h b/include/mixer_m4.h
index 99252fd3..d759adc9 100644
--- a/include/mixer_m4.h
+++ b/include/mixer_m4.h
@@ -32,31 +32,37 @@ void snd_mixer_elem_set_callback_private(snd_mixer_elem_t *obj, void * val);
snd_mixer_elem_type_t snd_mixer_elem_get_type(const snd_mixer_elem_t *obj);
-size_t snd_mixer_selem_sizeof();
-#define snd_mixer_selem_alloca(ptr) ({ assert(ptr); *ptr = (snd_mixer_selem_t *) alloca(snd_mixer_selem_sizeof()); memset(*ptr, 0, snd_mixer_selem_sizeof()); 0; })
-int snd_mixer_selem_malloc(snd_mixer_selem_t **ptr);
-void snd_mixer_selem_free(snd_mixer_selem_t *obj);
-void snd_mixer_selem_copy(snd_mixer_selem_t *dst, const snd_mixer_selem_t *src);
+size_t snd_mixer_selem_info_sizeof();
+#define snd_mixer_selem_info_alloca(ptr) ({ assert(ptr); *ptr = (snd_mixer_selem_info_t *) alloca(snd_mixer_selem_info_sizeof()); memset(*ptr, 0, snd_mixer_selem_info_sizeof()); 0; })
+int snd_mixer_selem_info_malloc(snd_mixer_selem_info_t **ptr);
+void snd_mixer_selem_info_free(snd_mixer_selem_info_t *obj);
+void snd_mixer_selem_info_copy(snd_mixer_selem_info_t *dst, const snd_mixer_selem_info_t *src);
-long snd_mixer_selem_get_min(const snd_mixer_selem_t *obj);
+long snd_mixer_selem_info_get_min(const snd_mixer_selem_info_t *obj);
-long snd_mixer_selem_get_max(const snd_mixer_selem_t *obj);
+long snd_mixer_selem_info_get_max(const snd_mixer_selem_info_t *obj);
-int snd_mixer_selem_get_capture_group(const snd_mixer_selem_t *obj);
+int snd_mixer_selem_info_get_capture_group(const snd_mixer_selem_info_t *obj);
-int snd_mixer_selem_has_volume(const snd_mixer_selem_t *obj);
+int snd_mixer_selem_info_has_volume(const snd_mixer_selem_info_t *obj);
-int snd_mixer_selem_has_joined_volume(const snd_mixer_selem_t *obj);
+int snd_mixer_selem_info_has_joined_volume(const snd_mixer_selem_info_t *obj);
-int snd_mixer_selem_has_mute(const snd_mixer_selem_t *obj);
+int snd_mixer_selem_info_has_mute(const snd_mixer_selem_info_t *obj);
-int snd_mixer_selem_has_joined_mute(const snd_mixer_selem_t *obj);
+int snd_mixer_selem_info_has_joined_mute(const snd_mixer_selem_info_t *obj);
-int snd_mixer_selem_has_capture(const snd_mixer_selem_t *obj);
+int snd_mixer_selem_info_has_capture(const snd_mixer_selem_info_t *obj);
-int snd_mixer_selem_has_joined_capture(const snd_mixer_selem_t *obj);
+int snd_mixer_selem_info_has_joined_capture(const snd_mixer_selem_info_t *obj);
-int snd_mixer_selem_has_exclusive_capture(const snd_mixer_selem_t *obj);
+int snd_mixer_selem_info_has_exclusive_capture(const snd_mixer_selem_info_t *obj);
+
+size_t snd_mixer_selem_value_sizeof();
+#define snd_mixer_selem_value_alloca(ptr) ({ assert(ptr); *ptr = (snd_mixer_selem_value_t *) alloca(snd_mixer_selem_value_sizeof()); memset(*ptr, 0, snd_mixer_selem_value_sizeof()); 0; })
+int snd_mixer_selem_value_malloc(snd_mixer_selem_value_t **ptr);
+void snd_mixer_selem_value_free(snd_mixer_selem_value_t *obj);
+void snd_mixer_selem_value_copy(snd_mixer_selem_value_t *dst, const snd_mixer_selem_value_t *src);
#ifdef __cplusplus
diff --git a/include/pcm.h b/include/pcm.h
index 6d27aa9b..5707aeaf 100644
--- a/include/pcm.h
+++ b/include/pcm.h
@@ -247,6 +247,8 @@ int snd_pcm_unlink(snd_pcm_t *pcm);
int snd_pcm_wait(snd_pcm_t *pcm, int timeout);
snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm);
+const char *snd_pcm_name(snd_pcm_t *pcm);
+snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm);
/* HW params */
int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
diff --git a/include/rawmidi.h b/include/rawmidi.h
index 22c0bda8..582bb9ed 100644
--- a/include/rawmidi.h
+++ b/include/rawmidi.h
@@ -45,7 +45,7 @@ extern "C" {
#endif
int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi,
- char *name, int mode);
+ const char *name, int mode);
int snd_rawmidi_close(snd_rawmidi_t *rmidi);
int snd_rawmidi_poll_descriptor(snd_rawmidi_t *rmidi);
int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock);
@@ -56,6 +56,8 @@ int snd_rawmidi_drain(snd_rawmidi_t *rmidi);
int snd_rawmidi_drop(snd_rawmidi_t *rmidi);
ssize_t snd_rawmidi_write(snd_rawmidi_t *rmidi, const void *buffer, size_t size);
ssize_t snd_rawmidi_read(snd_rawmidi_t *rmidi, void *buffer, size_t size);
+const char *snd_rawmidi_name(snd_rawmidi_t *rmidi);
+snd_rawmidi_type_t snd_rawmidi_type(snd_rawmidi_t *rmidi);
int snd_rawmidi_params_current(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *params);
diff --git a/include/seq.h b/include/seq.h
index 80b2e3a8..312b9e23 100644
--- a/include/seq.h
+++ b/include/seq.h
@@ -322,7 +322,7 @@ typedef struct _snd_seq snd_seq_t;
extern "C" {
#endif
-int snd_seq_open(snd_seq_t **handle, char *name, int streams, int mode);
+int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode);
int snd_seq_close(snd_seq_t *handle);
int snd_seq_poll_descriptor(snd_seq_t *handle);
int snd_seq_nonblock(snd_seq_t *handle, int nonblock);
@@ -354,15 +354,15 @@ int snd_seq_set_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *tim
int snd_seq_get_queue_client(snd_seq_t *handle, int q, snd_seq_queue_client_t *queue);
int snd_seq_set_queue_client(snd_seq_t *handle, int q, snd_seq_queue_client_t *queue);
int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info);
-int snd_seq_alloc_named_queue(snd_seq_t *seq, char *name);
+int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name);
int snd_seq_alloc_queue(snd_seq_t *handle);
#ifdef SND_SEQ_SYNC_SUPPORT
-int snd_seq_alloc_sync_queue(snd_seq_t *seq, char *name);
+int snd_seq_alloc_sync_queue(snd_seq_t *seq, const char *name);
#endif
int snd_seq_free_queue(snd_seq_t *handle, int q);
int snd_seq_get_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
int snd_seq_set_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
-int snd_seq_get_named_queue(snd_seq_t *seq, char *name);
+int snd_seq_get_named_queue(snd_seq_t *seq, const char *name);
int snd_seq_get_client_pool(snd_seq_t *handle, snd_seq_client_pool_t * info);
int snd_seq_set_client_pool(snd_seq_t *handle, snd_seq_client_pool_t * info);
int snd_seq_query_next_client(snd_seq_t *handle, snd_seq_client_info_t * info);
@@ -376,6 +376,8 @@ int snd_seq_add_sync_std_master(snd_seq_t *seq, int queue, snd_seq_addr_t *dest,
int snd_seq_set_sync_slave(snd_seq_t *seq, int queue, snd_seq_addr_t *src, snd_seq_queue_sync_t *info);
int snd_seq_reset_sync_slave(snd_seq_t *seq, int queue, snd_seq_addr_t *src);
+const char *snd_seq_name(snd_seq_t *seq);
+snd_seq_type_t snd_seq_type(snd_seq_t *seq);
#endif
diff --git a/include/seqmid.h b/include/seqmid.h
index d47d3646..cc8a123b 100644
--- a/include/seqmid.h
+++ b/include/seqmid.h
@@ -72,7 +72,7 @@ int snd_seq_change_queue_tempo(snd_seq_t *seq, int q, int tempo, snd_seq_event_t
int snd_seq_setpos_queue(snd_seq_t *seq, int q, snd_seq_timestamp_t *rtime, snd_seq_event_t *ev);
/* create a port - simple version - return the port number */
-int snd_seq_create_simple_port(snd_seq_t *seq, char *name,
+int snd_seq_create_simple_port(snd_seq_t *seq, const char *name,
unsigned int caps, unsigned int type);
/* delete the port */
int snd_seq_delete_simple_port(snd_seq_t *seq, int port);
@@ -88,8 +88,8 @@ int snd_seq_disconnect_to(snd_seq_t *seq, int my_port, int dest_client, int dest
/*
* set client information
*/
-int snd_seq_set_client_name(snd_seq_t *seq, char *name);
-int snd_seq_set_client_group(snd_seq_t *seq, char *name);
+int snd_seq_set_client_name(snd_seq_t *seq, const char *name);
+int snd_seq_set_client_group(snd_seq_t *seq, const char *name);
int snd_seq_set_client_filter(snd_seq_t *seq, unsigned int filter);
int snd_seq_set_client_event_filter(snd_seq_t *seq, int event_type);
int snd_seq_set_client_pool_output(snd_seq_t *seq, int size);
diff --git a/src/conf.c b/src/conf.c
index 20d6ab0b..95c40b6a 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -342,7 +342,7 @@ snd_config_type_t snd_config_get_type(snd_config_t *config)
return config->type;
}
-char *snd_config_get_id(snd_config_t *config)
+const char *snd_config_get_id(snd_config_t *config)
{
return config->id;
}
@@ -383,8 +383,8 @@ static int _snd_config_make_add(snd_config_t **config, char *id,
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) {
+ snd_config_iterator_t i, next;
+ snd_config_for_each(i, next, config) {
snd_config_t *n = snd_config_iterator_entry(i);
if (len < 0) {
if (strcmp(n->id, id) == 0) {
@@ -662,9 +662,9 @@ int snd_config_load(snd_config_t *config, snd_input_t *in)
int snd_config_add(snd_config_t *father, snd_config_t *leaf)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
assert(father && leaf);
- snd_config_foreach(i, father) {
+ snd_config_for_each(i, next, father) {
snd_config_t *n = snd_config_iterator_entry(i);
if (strcmp(leaf->id, n->id) == 0)
return -EEXIST;
@@ -937,9 +937,9 @@ static int _snd_config_save_leaves(snd_config_t *config, snd_output_t *out, unsi
{
unsigned int k;
int err;
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
assert(config && out);
- snd_config_foreach(i, config) {
+ snd_config_for_each(i, next, config) {
snd_config_t *n = snd_config_iterator_entry(i);
if (n->type == SND_CONFIG_TYPE_COMPOUND &&
n->u.compound.join) {
diff --git a/src/control/control.c b/src/control/control.c
index 5f10b9bc..b9c76075 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -29,16 +29,24 @@
#include <sys/poll.h>
#include "control_local.h"
+const char *snd_ctl_name(snd_ctl_t *ctl)
+{
+ assert(ctl);
+ return ctl->name;
+}
+
snd_ctl_type_t snd_ctl_type(snd_ctl_t *ctl)
{
+ assert(ctl);
return ctl->type;
}
int snd_ctl_close(snd_ctl_t *ctl)
{
int res;
- assert(ctl);
res = ctl->ops->close(ctl);
+ if (ctl->name)
+ free(ctl->name);
free(ctl);
return res;
}
@@ -85,13 +93,13 @@ int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
return ctl->ops->element_info(ctl, info);
}
-int snd_ctl_elem_read(snd_ctl_t *ctl, snd_ctl_elem_t *control)
+int snd_ctl_elem_read(snd_ctl_t *ctl, snd_ctl_elem_value_t *control)
{
assert(ctl && control && (control->id.name[0] || control->id.numid));
return ctl->ops->element_read(ctl, control);
}
-int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_t *control)
+int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *control)
{
assert(ctl && control && (control->id.name[0] || control->id.numid));
return ctl->ops->element_write(ctl, control);
@@ -163,14 +171,14 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
return 0;
}
-int snd_ctl_open(snd_ctl_t **ctlp, char *name)
+int snd_ctl_open(snd_ctl_t **ctlp, const char *name)
{
const char *str;
int err;
snd_config_t *ctl_conf, *conf, *type_conf;
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *lib = NULL, *open = NULL;
- int (*open_func)(snd_ctl_t **ctlp, char *name, snd_config_t *conf);
+ int (*open_func)(snd_ctl_t **ctlp, const char *name, snd_config_t *conf);
void *h;
assert(ctlp && name);
err = snd_config_update();
@@ -182,10 +190,10 @@ int snd_ctl_open(snd_ctl_t **ctlp, char *name)
char socket[256], sname[256];
err = sscanf(name, "hw:%d", &card);
if (err == 1)
- return snd_ctl_hw_open(ctlp, NULL, card);
+ return snd_ctl_hw_open(ctlp, name, card);
err = sscanf(name, "shm:%256[^,],%256[^,]", socket, sname);
if (err == 2)
- return snd_ctl_shm_open(ctlp, NULL, socket, sname);
+ return snd_ctl_shm_open(ctlp, name, socket, sname);
ERR("Unknown control %s", name);
return -ENOENT;
}
@@ -198,7 +206,7 @@ int snd_ctl_open(snd_ctl_t **ctlp, char *name)
if (err < 0)
return err;
err = snd_config_searchv(snd_config, &type_conf, "ctltype", str, 0);
- snd_config_foreach(i, type_conf) {
+ snd_config_for_each(i, next, type_conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
@@ -231,7 +239,7 @@ int snd_ctl_open(snd_ctl_t **ctlp, char *name)
return open_func(ctlp, name, ctl_conf);
}
-void snd_ctl_elem_set_bytes(snd_ctl_elem_t *obj, void *data, size_t size)
+void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t *obj, void *data, size_t size)
{
assert(obj);
assert(size <= sizeof(obj->value.bytes.data));
@@ -264,7 +272,7 @@ const char *snd_ctl_elem_iface_names[] = {
const char *snd_ctl_event_type_names[] = {
EVENT(REBUILD),
EVENT(VALUE),
- EVENT(CHANGE),
+ EVENT(INFO),
EVENT(ADD),
EVENT(REMOVE),
};
diff --git a/src/control/control_hw.c b/src/control/control_hw.c
index c9b9ada0..81af011a 100644
--- a/src/control/control_hw.c
+++ b/src/control/control_hw.c
@@ -43,7 +43,7 @@ typedef struct {
static int snd_ctl_hw_close(snd_ctl_t *handle)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
int res;
res = close(hw->fd) < 0 ? -errno : 0;
free(hw);
@@ -52,7 +52,7 @@ static int snd_ctl_hw_close(snd_ctl_t *handle)
static int snd_ctl_hw_nonblock(snd_ctl_t *handle, int nonblock)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
long flags;
int fd = hw->fd;
if ((flags = fcntl(fd, F_GETFL)) < 0) {
@@ -73,7 +73,7 @@ static int snd_ctl_hw_nonblock(snd_ctl_t *handle, int nonblock)
static int snd_ctl_hw_async(snd_ctl_t *ctl, int sig, pid_t pid)
{
long flags;
- snd_ctl_hw_t *hw = ctl->private;
+ snd_ctl_hw_t *hw = ctl->private_data;
int fd = hw->fd;
if ((flags = fcntl(fd, F_GETFL)) < 0) {
@@ -107,13 +107,13 @@ static int snd_ctl_hw_async(snd_ctl_t *ctl, int sig, pid_t pid)
static int snd_ctl_hw_poll_descriptor(snd_ctl_t *handle)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
return hw->fd;
}
static int snd_ctl_hw_hw_info(snd_ctl_t *handle, snd_ctl_card_info_t *info)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_INFO, info) < 0)
return -errno;
return 0;
@@ -121,7 +121,7 @@ static int snd_ctl_hw_hw_info(snd_ctl_t *handle, snd_ctl_card_info_t *info)
static int snd_ctl_hw_elem_list(snd_ctl_t *handle, snd_ctl_elem_list_t *list)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_LIST, list) < 0)
return -errno;
return 0;
@@ -129,23 +129,23 @@ static int snd_ctl_hw_elem_list(snd_ctl_t *handle, snd_ctl_elem_list_t *list)
static int snd_ctl_hw_elem_info(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_INFO, info) < 0)
return -errno;
return 0;
}
-static int snd_ctl_hw_elem_read(snd_ctl_t *handle, snd_ctl_elem_t *control)
+static int snd_ctl_hw_elem_read(snd_ctl_t *handle, snd_ctl_elem_value_t *control)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_READ, control) < 0)
return -errno;
return 0;
}
-static int snd_ctl_hw_elem_write(snd_ctl_t *handle, snd_ctl_elem_t *control)
+static int snd_ctl_hw_elem_write(snd_ctl_t *handle, snd_ctl_elem_value_t *control)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, control) < 0)
return -errno;
return 0;
@@ -153,7 +153,7 @@ static int snd_ctl_hw_elem_write(snd_ctl_t *handle, snd_ctl_elem_t *control)
static int snd_ctl_hw_hwdep_next_device(snd_ctl_t *handle, int * device)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE, device) < 0)
return -errno;
return 0;
@@ -161,7 +161,7 @@ static int snd_ctl_hw_hwdep_next_device(snd_ctl_t *handle, int * device)
static int snd_ctl_hw_hwdep_info(snd_ctl_t *handle, snd_hwdep_info_t * info)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_HWDEP_INFO, info) < 0)
return -errno;
return 0;
@@ -169,7 +169,7 @@ static int snd_ctl_hw_hwdep_info(snd_ctl_t *handle, snd_hwdep_info_t * info)
static int snd_ctl_hw_pcm_next_device(snd_ctl_t *handle, int * device)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE, device) < 0)
return -errno;
return 0;
@@ -177,7 +177,7 @@ static int snd_ctl_hw_pcm_next_device(snd_ctl_t *handle, int * device)
static int snd_ctl_hw_pcm_info(snd_ctl_t *handle, snd_pcm_info_t * info)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_PCM_INFO, info) < 0)
return -errno;
return 0;
@@ -185,7 +185,7 @@ static int snd_ctl_hw_pcm_info(snd_ctl_t *handle, snd_pcm_info_t * info)
static int snd_ctl_hw_pcm_prefer_subdevice(snd_ctl_t *handle, int subdev)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE, &subdev) < 0)
return -errno;
return 0;
@@ -193,7 +193,7 @@ static int snd_ctl_hw_pcm_prefer_subdevice(snd_ctl_t *handle, int subdev)
static int snd_ctl_hw_rawmidi_next_device(snd_ctl_t *handle, int * device)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE, device) < 0)
return -errno;
return 0;
@@ -201,7 +201,7 @@ static int snd_ctl_hw_rawmidi_next_device(snd_ctl_t *handle, int * device)
static int snd_ctl_hw_rawmidi_info(snd_ctl_t *handle, snd_rawmidi_info_t * info)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_RAWMIDI_INFO, info) < 0)
return -errno;
return 0;
@@ -209,7 +209,7 @@ static int snd_ctl_hw_rawmidi_info(snd_ctl_t *handle, snd_rawmidi_info_t * info)
static int snd_ctl_hw_rawmidi_prefer_subdevice(snd_ctl_t *handle, int subdev)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE, &subdev) < 0)
return -errno;
return 0;
@@ -217,7 +217,7 @@ static int snd_ctl_hw_rawmidi_prefer_subdevice(snd_ctl_t *handle, int subdev)
static int snd_ctl_hw_read(snd_ctl_t *handle, snd_ctl_event_t *event)
{
- snd_ctl_hw_t *hw = handle->private;
+ snd_ctl_hw_t *hw = handle->private_data;
ssize_t res = read(hw->fd, event, sizeof(*event));
if (res <= 0)
return res;
@@ -288,18 +288,18 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card)
ctl->name = strdup(name);
ctl->type = SND_CTL_TYPE_HW;
ctl->ops = &snd_ctl_hw_ops;
- ctl->private = hw;
+ ctl->private_data = hw;
*handle = ctl;
return 0;
}
int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
long card = -1;
const char *str;
int err;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/control/control_local.h b/src/control/control_local.h
index 8af24084..5e545349 100644
--- a/src/control/control_local.h
+++ b/src/control/control_local.h
@@ -30,8 +30,8 @@ typedef struct _snd_ctl_ops {
int (*hw_info)(snd_ctl_t *handle, snd_ctl_card_info_t *info);
int (*element_list)(snd_ctl_t *handle, snd_ctl_elem_list_t *list);
int (*element_info)(snd_ctl_t *handle, snd_ctl_elem_info_t *info);
- int (*element_read)(snd_ctl_t *handle, snd_ctl_elem_t *control);
- int (*element_write)(snd_ctl_t *handle, snd_ctl_elem_t *control);
+ int (*element_read)(snd_ctl_t *handle, snd_ctl_elem_value_t *control);
+ int (*element_write)(snd_ctl_t *handle, snd_ctl_elem_value_t *control);
int (*hwdep_next_device)(snd_ctl_t *handle, int *device);
int (*hwdep_info)(snd_ctl_t *handle, snd_hwdep_info_t * info);
int (*pcm_next_device)(snd_ctl_t *handle, int *device);
@@ -48,7 +48,7 @@ struct _snd_ctl {
char *name;
snd_ctl_type_t type;
snd_ctl_ops_t *ops;
- void *private;
+ void *private_data;
int nonblock;
};
@@ -64,11 +64,11 @@ struct _snd_hctl_elem {
struct _snd_hctl {
snd_ctl_t *ctl;
- struct list_head hlist; /* list of all controls */
- unsigned int halloc;
- unsigned int hcount;
- snd_hctl_elem_t **helems;
- snd_hctl_compare_t hcompare;
+ struct list_head elems; /* list of all controls */
+ unsigned int alloc;
+ unsigned int count;
+ snd_hctl_elem_t **pelems;
+ snd_hctl_compare_t compare;
snd_hctl_callback_t callback;
void *callback_private;
};
diff --git a/src/control/control_m4.c b/src/control/control_m4.c
index fbc1b45b..ad40e6cc 100644
--- a/src/control/control_m4.c
+++ b/src/control/control_m4.c
@@ -561,210 +561,185 @@ void snd_ctl_elem_info_set_index(snd_ctl_elem_info_t *obj, unsigned int val)
obj->id.index = val;
}
-size_t snd_ctl_elem_sizeof()
+size_t snd_ctl_elem_value_sizeof()
{
- return sizeof(snd_ctl_elem_t);
+ return sizeof(snd_ctl_elem_value_t);
}
-int snd_ctl_elem_malloc(snd_ctl_elem_t **ptr)
+int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr)
{
assert(ptr);
- *ptr = calloc(1, sizeof(snd_ctl_elem_t));
+ *ptr = calloc(1, sizeof(snd_ctl_elem_value_t));
if (!*ptr)
return -ENOMEM;
return 0;
}
-void snd_ctl_elem_free(snd_ctl_elem_t *obj)
+void snd_ctl_elem_value_free(snd_ctl_elem_value_t *obj)
{
free(obj);
}
-void snd_ctl_elem_copy(snd_ctl_elem_t *dst, const snd_ctl_elem_t *src)
+void snd_ctl_elem_value_copy(snd_ctl_elem_value_t *dst, const snd_ctl_elem_value_t *src)
{
assert(dst && src);
*dst = *src;
}
-void snd_ctl_elem_get_id(const snd_ctl_elem_t *obj, snd_ctl_elem_id_t *ptr)
+void snd_ctl_elem_value_get_id(const snd_ctl_elem_value_t *obj, snd_ctl_elem_id_t *ptr)
{
assert(obj && ptr);
*ptr = obj->id;
}
-unsigned int snd_ctl_elem_get_numid(const snd_ctl_elem_t *obj)
+unsigned int snd_ctl_elem_value_get_numid(const snd_ctl_elem_value_t *obj)
{
assert(obj);
return obj->id.numid;
}
-snd_ctl_elem_iface_t snd_ctl_elem_get_interface(const snd_ctl_elem_t *obj)
+snd_ctl_elem_iface_t snd_ctl_elem_value_get_interface(const snd_ctl_elem_value_t *obj)
{
assert(obj);
return snd_int_to_enum(obj->id.iface);
}
-unsigned int snd_ctl_elem_get_device(const snd_ctl_elem_t *obj)
+unsigned int snd_ctl_elem_value_get_device(const snd_ctl_elem_value_t *obj)
{
assert(obj);
return obj->id.device;
}
-unsigned int snd_ctl_elem_get_subdevice(const snd_ctl_elem_t *obj)
+unsigned int snd_ctl_elem_value_get_subdevice(const snd_ctl_elem_value_t *obj)
{
assert(obj);
return obj->id.subdevice;
}
-const char *snd_ctl_elem_get_name(const snd_ctl_elem_t *obj)
+const char *snd_ctl_elem_value_get_name(const snd_ctl_elem_value_t *obj)
{
assert(obj);
return obj->id.name;
}
-unsigned int snd_ctl_elem_get_index(const snd_ctl_elem_t *obj)
+unsigned int snd_ctl_elem_value_get_index(const snd_ctl_elem_value_t *obj)
{
assert(obj);
return obj->id.index;
}
-void snd_ctl_elem_set_id(snd_ctl_elem_t *obj, const snd_ctl_elem_id_t *ptr)
+void snd_ctl_elem_value_set_id(snd_ctl_elem_value_t *obj, const snd_ctl_elem_id_t *ptr)
{
assert(obj && ptr);
obj->id = *ptr;
}
-void snd_ctl_elem_set_numid(snd_ctl_elem_t *obj, unsigned int val)
+void snd_ctl_elem_value_set_numid(snd_ctl_elem_value_t *obj, unsigned int val)
{
assert(obj);
obj->id.numid = val;
}
-void snd_ctl_elem_set_interface(snd_ctl_elem_t *obj, snd_ctl_elem_iface_t val)
+void snd_ctl_elem_value_set_interface(snd_ctl_elem_value_t *obj, snd_ctl_elem_iface_t val)
{
assert(obj);
obj->id.iface = snd_enum_to_int(val);
}
-void snd_ctl_elem_set_device(snd_ctl_elem_t *obj, unsigned int val)
+void snd_ctl_elem_value_set_device(snd_ctl_elem_value_t *obj, unsigned int val)
{
assert(obj);
obj->id.device = val;
}
-void snd_ctl_elem_set_subdevice(snd_ctl_elem_t *obj, unsigned int val)
+void snd_ctl_elem_value_set_subdevice(snd_ctl_elem_value_t *obj, unsigned int val)
{
assert(obj);
obj->id.subdevice = val;
}
-void snd_ctl_elem_set_name(snd_ctl_elem_t *obj, const char *val)
+void snd_ctl_elem_value_set_name(snd_ctl_elem_value_t *obj, const char *val)
{
assert(obj);
strncpy(obj->id.name, val, sizeof(obj->id.name));
}
-void snd_ctl_elem_set_index(snd_ctl_elem_t *obj, unsigned int val)
+void snd_ctl_elem_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val)
{
assert(obj);
obj->id.index = val;
}
-long snd_ctl_elem_get_boolean(const snd_ctl_elem_t *obj, unsigned int idx)
+long snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_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_ctl_elem_get_integer(const snd_ctl_elem_t *obj, unsigned int idx)
+long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_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_ctl_elem_get_enumerated(const snd_ctl_elem_t *obj, unsigned int idx)
+unsigned int snd_ctl_elem_value_get_enumerated(const snd_ctl_elem_value_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_ctl_elem_get_byte(const snd_ctl_elem_t *obj, unsigned int idx)
+unsigned char snd_ctl_elem_value_get_byte(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
assert(obj);
assert(idx < sizeof(obj->value.bytes.data));
return obj->value.bytes.data[idx];
}
-void snd_ctl_elem_set_boolean(snd_ctl_elem_t *obj, unsigned int idx, long val)
+void snd_ctl_elem_value_set_boolean(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
{
assert(obj);
obj->value.integer.value[idx] = val;
}
-void snd_ctl_elem_set_integer(snd_ctl_elem_t *obj, unsigned int idx, long val)
+void snd_ctl_elem_value_set_integer(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
{
assert(obj);
obj->value.integer.value[idx] = val;
}
-void snd_ctl_elem_set_enumerated(snd_ctl_elem_t *obj, unsigned int idx, unsigned int val)
+void snd_ctl_elem_value_set_enumerated(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned int val)
{
assert(obj);
obj->value.enumerated.item[idx] = val;
}
-void snd_ctl_elem_set_byte(snd_ctl_elem_t *obj, unsigned int idx, unsigned char val)
+void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned char val)
{
assert(obj);
obj->value.bytes.data[idx] = val;
}
-const void * snd_ctl_elem_get_bytes(const snd_ctl_elem_t *obj)
+const void * snd_ctl_elem_value_get_bytes(const snd_ctl_elem_value_t *obj)
{
assert(obj);
return obj->value.bytes.data;
}
-void snd_ctl_elem_get_iec958(const snd_ctl_elem_t *obj, snd_aes_iec958_t *ptr)
+void snd_ctl_elem_value_get_iec958(const snd_ctl_elem_value_t *obj, snd_aes_iec958_t *ptr)
{
assert(obj && ptr);
*ptr = obj->value.iec958;
}
-void snd_ctl_elem_set_iec958(snd_ctl_elem_t *obj, const snd_aes_iec958_t *ptr)
+void snd_ctl_elem_value_set_iec958(snd_ctl_elem_value_t *obj, const snd_aes_iec958_t *ptr)
{
assert(obj && ptr);
obj->value.iec958 = *ptr;
}
-size_t snd_hctl_elem_sizeof()
-{
- return sizeof(snd_hctl_elem_t);
-}
-
-int snd_hctl_elem_malloc(snd_hctl_elem_t **ptr)
-{
- assert(ptr);
- *ptr = calloc(1, sizeof(snd_hctl_elem_t));
- if (!*ptr)
- return -ENOMEM;
- return 0;
-}
-
-void snd_hctl_elem_free(snd_hctl_elem_t *obj)
-{
- free(obj);
-}
-
-void snd_hctl_elem_copy(snd_hctl_elem_t *dst, const snd_hctl_elem_t *src)
-{
- assert(dst && src);
- *dst = *src;
-}
-
void snd_hctl_elem_get_id(const snd_hctl_elem_t *obj, snd_ctl_elem_id_t *ptr)
{
assert(obj && ptr);
diff --git a/src/control/control_shm.c b/src/control/control_shm.c
index b99c843d..496b1371 100644
--- a/src/control/control_shm.c
+++ b/src/control/control_shm.c
@@ -45,7 +45,7 @@ extern int receive_fd(int socket, void *data, size_t len, int *fd);
static int snd_ctl_shm_action(snd_ctl_t *ctl)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
int err;
char buf[1];
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
@@ -64,7 +64,7 @@ static int snd_ctl_shm_action(snd_ctl_t *ctl)
static int snd_ctl_shm_action_fd(snd_ctl_t *ctl, int *fd)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
int err;
char buf[1];
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
@@ -83,7 +83,7 @@ static int snd_ctl_shm_action_fd(snd_ctl_t *ctl, int *fd)
static int snd_ctl_shm_close(snd_ctl_t *ctl)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int result;
ctrl->cmd = SND_CTL_IOCTL_CLOSE;
@@ -101,7 +101,7 @@ static int snd_ctl_shm_nonblock(snd_ctl_t *handle ATTRIBUTE_UNUSED, int nonblock
static int snd_ctl_shm_async(snd_ctl_t *ctl, int sig, pid_t pid)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SND_CTL_IOCTL_ASYNC;
ctrl->u.async.sig = sig;
@@ -113,7 +113,7 @@ static int snd_ctl_shm_async(snd_ctl_t *ctl, int sig, pid_t pid)
static int snd_ctl_shm_poll_descriptor(snd_ctl_t *ctl)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int fd, err;
ctrl->cmd = SND_CTL_IOCTL_POLL_DESCRIPTOR;
@@ -125,7 +125,7 @@ static int snd_ctl_shm_poll_descriptor(snd_ctl_t *ctl)
static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
// ctrl->u.hw_info = *info;
@@ -139,7 +139,7 @@ static int snd_ctl_shm_hw_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
static int snd_ctl_shm_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t *list)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
size_t maxsize = CTL_SHM_DATA_MAXLEN;
size_t bytes = list->space * sizeof(*list->pids);
@@ -161,7 +161,7 @@ static int snd_ctl_shm_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t *list)
static int snd_ctl_shm_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.element_info = *info;
@@ -173,9 +173,9 @@ static int snd_ctl_shm_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
return err;
}
-static int snd_ctl_shm_elem_read(snd_ctl_t *ctl, snd_ctl_elem_t *control)
+static int snd_ctl_shm_elem_read(snd_ctl_t *ctl, snd_ctl_elem_value_t *control)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.element_read = *control;
@@ -187,9 +187,9 @@ static int snd_ctl_shm_elem_read(snd_ctl_t *ctl, snd_ctl_elem_t *control)
return err;
}
-static int snd_ctl_shm_elem_write(snd_ctl_t *ctl, snd_ctl_elem_t *control)
+static int snd_ctl_shm_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *control)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.element_write = *control;
@@ -203,7 +203,7 @@ static int snd_ctl_shm_elem_write(snd_ctl_t *ctl, snd_ctl_elem_t *control)
static int snd_ctl_shm_hwdep_next_device(snd_ctl_t *ctl, int * device)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
@@ -217,7 +217,7 @@ static int snd_ctl_shm_hwdep_next_device(snd_ctl_t *ctl, int * device)
static int snd_ctl_shm_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.hwdep_info = *info;
@@ -231,7 +231,7 @@ static int snd_ctl_shm_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info)
static int snd_ctl_shm_pcm_next_device(snd_ctl_t *ctl, int * device)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
@@ -245,7 +245,7 @@ static int snd_ctl_shm_pcm_next_device(snd_ctl_t *ctl, int * device)
static int snd_ctl_shm_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.pcm_info = *info;
@@ -259,7 +259,7 @@ static int snd_ctl_shm_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info)
static int snd_ctl_shm_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.pcm_prefer_subdevice = subdev;
@@ -272,7 +272,7 @@ static int snd_ctl_shm_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev)
static int snd_ctl_shm_rawmidi_next_device(snd_ctl_t *ctl, int * device)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
@@ -286,7 +286,7 @@ static int snd_ctl_shm_rawmidi_next_device(snd_ctl_t *ctl, int * device)
static int snd_ctl_shm_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.rawmidi_info = *info;
@@ -300,7 +300,7 @@ static int snd_ctl_shm_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info)
static int snd_ctl_shm_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev)
{
- snd_ctl_shm_t *shm = ctl->private;
+ snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.rawmidi_prefer_subdevice = subdev;
@@ -319,7 +319,7 @@ static int snd_ctl_shm_read(snd_ctl_t *ctl, snd_ctl_event_t *event)
err = snd_ctl_wait(ctl, -1);
if (err < 0)
return 0;
- shm = ctl->private;
+ shm = ctl->private_data;
ctrl = shm->ctrl;
ctrl->u.read = *event;
ctrl->cmd = SND_CTL_IOCTL_READ;
@@ -474,7 +474,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket,
ctl->name = strdup(name);
ctl->type = SND_CTL_TYPE_SHM;
ctl->ops = &snd_ctl_shm_ops;
- ctl->private = shm;
+ ctl->private_data = shm;
*handlep = ctl;
return 0;
@@ -491,7 +491,7 @@ 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;
+ snd_config_iterator_t i, next;
const char *server = NULL;
const char *sname = NULL;
snd_config_t *sconfig;
@@ -501,7 +501,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
int err;
int local;
struct hostent *h;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
@@ -540,7 +540,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
ERR("Unknown server %s", server);
return -EINVAL;
}
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/control/hcontrol.c b/src/control/hcontrol.c
index f20afbe5..55748e2e 100644
--- a/src/control/hcontrol.c
+++ b/src/control/hcontrol.c
@@ -29,12 +29,10 @@
#define __USE_GNU
#include "control_local.h"
-static int snd_hctl_build(snd_hctl_t *hctl);
-static int snd_hctl_free(snd_hctl_t *hctl);
static int snd_hctl_compare_default(const snd_hctl_elem_t *c1,
const snd_hctl_elem_t *c2);
-int snd_hctl_open(snd_hctl_t **hctlp, char *name)
+int snd_hctl_open(snd_hctl_t **hctlp, const char *name)
{
snd_hctl_t *hctl;
snd_ctl_t *ctl;
@@ -48,12 +46,8 @@ int snd_hctl_open(snd_hctl_t **hctlp, char *name)
snd_ctl_close(ctl);
return -ENOMEM;
}
- INIT_LIST_HEAD(&hctl->hlist);
+ INIT_LIST_HEAD(&hctl->elems);
hctl->ctl = ctl;
- if ((err = snd_hctl_build(hctl)) < 0) {
- snd_hctl_close(hctl);
- return err;
- }
*hctlp = hctl;
return 0;
}
@@ -63,28 +57,33 @@ int snd_hctl_close(snd_hctl_t *hctl)
int err;
assert(hctl);
- assert(hctl->ctl);
err = snd_ctl_close(hctl->ctl);
snd_hctl_free(hctl);
free(hctl);
return err;
}
+const char *snd_hctl_name(snd_hctl_t *hctl)
+{
+ assert(hctl);
+ return snd_ctl_name(hctl->ctl);
+}
+
int snd_hctl_nonblock(snd_hctl_t *hctl, int nonblock)
{
- assert(hctl && hctl->ctl);
+ assert(hctl);
return snd_ctl_nonblock(hctl->ctl, nonblock);
}
int snd_hctl_async(snd_hctl_t *hctl, int sig, pid_t pid)
{
- assert(hctl && hctl->ctl);
+ assert(hctl);
return snd_ctl_async(hctl->ctl, sig, pid);
}
int snd_hctl_poll_descriptor(snd_hctl_t *hctl)
{
- assert(hctl && hctl->ctl);
+ assert(hctl);
return snd_ctl_poll_descriptor(hctl->ctl);
}
@@ -94,12 +93,12 @@ static int _snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id, in
int c = 0;
int idx = -1;
assert(hctl && id);
- assert(hctl->hcompare);
+ assert(hctl->compare);
l = 0;
- u = hctl->hcount;
+ u = hctl->count;
while (l < u) {
idx = (l + u) / 2;
- c = hctl->hcompare((snd_hctl_elem_t *) id, hctl->helems[idx]);
+ c = hctl->compare((snd_hctl_elem_t *) id, hctl->pelems[idx]);
if (c < 0)
u = idx;
else if (c > 0)
@@ -111,65 +110,75 @@ static int _snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id, in
return idx;
}
+int snd_hctl_throw_event(snd_hctl_t *hctl, snd_ctl_event_type_t event,
+ snd_hctl_elem_t *elem)
+{
+ if (hctl->callback)
+ return hctl->callback(hctl, event, elem);
+ return 0;
+}
+
+int snd_hctl_elem_throw_event(snd_hctl_elem_t *elem,
+ snd_ctl_event_type_t event)
+{
+ if (elem->callback)
+ return elem->callback(elem, event);
+ return 0;
+}
+
static int snd_hctl_elem_add(snd_hctl_t *hctl, snd_hctl_elem_t *elem)
{
int dir;
int idx;
- if (hctl->hcount == hctl->halloc) {
+ if (hctl->count == hctl->alloc) {
snd_hctl_elem_t **h;
- hctl->halloc += 32;
- h = realloc(hctl->helems, sizeof(*h) * hctl->halloc);
+ hctl->alloc += 32;
+ h = realloc(hctl->pelems, sizeof(*h) * hctl->alloc);
if (!h)
return -ENOMEM;
- hctl->helems = h;
+ hctl->pelems = h;
}
- if (hctl->hcount == 0) {
- list_add_tail(&elem->list, &hctl->hlist);
- hctl->helems[0] = elem;
+ if (hctl->count == 0) {
+ list_add_tail(&elem->list, &hctl->elems);
+ hctl->pelems[0] = elem;
} else {
idx = _snd_hctl_find_elem(hctl, &elem->id, &dir);
assert(dir != 0);
if (dir > 0) {
- list_add(&elem->list, &hctl->helems[idx]->list);
+ list_add(&elem->list, &hctl->pelems[idx]->list);
} else {
- list_add_tail(&elem->list, &hctl->helems[idx]->list);
+ list_add_tail(&elem->list, &hctl->pelems[idx]->list);
idx++;
}
- memmove(hctl->helems + idx + 1,
- hctl->helems + idx,
- hctl->hcount - idx);
- }
- hctl->hcount++;
- if (hctl->callback) {
- int res = hctl->callback(hctl, SND_CTL_EVENT_ADD, elem);
- if (res < 0)
- return res;
+ memmove(hctl->pelems + idx + 1,
+ hctl->pelems + idx,
+ hctl->count - idx);
}
- return 0;
+ hctl->count++;
+ return snd_hctl_throw_event(hctl, SND_CTL_EVENT_ADD, elem);
}
static void snd_hctl_elem_remove(snd_hctl_t *hctl, unsigned int idx)
{
- snd_hctl_elem_t *elem = hctl->helems[idx];
+ snd_hctl_elem_t *elem = hctl->pelems[idx];
unsigned int m;
- if (elem->callback)
- elem->callback(elem, SND_CTL_EVENT_REMOVE);
+ snd_hctl_elem_throw_event(elem, SND_CTL_EVENT_REMOVE);
list_del(&elem->list);
free(elem);
- hctl->hcount--;
- m = hctl->hcount - idx;
+ hctl->count--;
+ m = hctl->count - idx;
if (m > 0)
- memmove(hctl->helems + idx, hctl->helems + idx + 1, m);
+ memmove(hctl->pelems + idx, hctl->pelems + idx + 1, m);
}
-static int snd_hctl_free(snd_hctl_t *hctl)
+int snd_hctl_free(snd_hctl_t *hctl)
{
- while (hctl->hcount > 0)
- snd_hctl_elem_remove(hctl, hctl->hcount - 1);
- free(hctl->helems);
- hctl->helems = 0;
- hctl->halloc = 0;
- INIT_LIST_HEAD(&hctl->hlist);
+ while (hctl->count > 0)
+ snd_hctl_elem_remove(hctl, hctl->count - 1);
+ free(hctl->pelems);
+ hctl->pelems = 0;
+ hctl->alloc = 0;
+ INIT_LIST_HEAD(&hctl->elems);
return 0;
}
@@ -177,21 +186,21 @@ static void snd_hctl_sort(snd_hctl_t *hctl)
{
unsigned int k;
int compar(const void *a, const void *b) {
- return hctl->hcompare(*(const snd_hctl_elem_t **) a,
+ return hctl->compare(*(const snd_hctl_elem_t **) a,
*(const snd_hctl_elem_t **) b);
}
assert(hctl);
- assert(hctl->hcompare);
- INIT_LIST_HEAD(&hctl->hlist);
- qsort(hctl->helems, hctl->hcount, sizeof(*hctl->helems), compar);
- for (k = 0; k < hctl->hcount; k++)
- list_add_tail(&hctl->helems[k]->list, &hctl->hlist);
+ assert(hctl->compare);
+ INIT_LIST_HEAD(&hctl->elems);
+ qsort(hctl->pelems, hctl->count, sizeof(*hctl->pelems), compar);
+ for (k = 0; k < hctl->count; k++)
+ list_add_tail(&hctl->pelems[k]->list, &hctl->elems);
}
void snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t hsort)
{
assert(hctl);
- hctl->hcompare = hsort == NULL ? snd_hctl_compare_default : hsort;
+ hctl->compare = hsort == NULL ? snd_hctl_compare_default : hsort;
snd_hctl_sort(hctl);
}
@@ -307,23 +316,23 @@ static int snd_hctl_compare_default(const snd_hctl_elem_t *c1,
snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl)
{
assert(hctl);
- if (list_empty(&hctl->hlist))
+ if (list_empty(&hctl->elems))
return NULL;
- return list_entry(hctl->hlist.next, snd_hctl_elem_t, list);
+ return list_entry(hctl->elems.next, snd_hctl_elem_t, list);
}
snd_hctl_elem_t *snd_hctl_last_elem(snd_hctl_t *hctl)
{
assert(hctl);
- if (list_empty(&hctl->hlist))
+ if (list_empty(&hctl->elems))
return NULL;
- return list_entry(hctl->hlist.prev, snd_hctl_elem_t, list);
+ return list_entry(hctl->elems.prev, snd_hctl_elem_t, list);
}
snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem)
{
assert(elem);
- if (elem->list.next == &elem->hctl->hlist)
+ if (elem->list.next == &elem->hctl->elems)
return NULL;
return list_entry(elem->list.next, snd_hctl_elem_t, list);
}
@@ -331,7 +340,7 @@ snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem)
snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem)
{
assert(elem);
- if (elem->list.prev == &elem->hctl->hlist)
+ if (elem->list.prev == &elem->hctl->elems)
return NULL;
return list_entry(elem->list.prev, snd_hctl_elem_t, list);
}
@@ -342,10 +351,10 @@ snd_hctl_elem_t *snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *i
int res = _snd_hctl_find_elem(hctl, id, &dir);
if (res < 0 || dir != 0)
return NULL;
- return hctl->helems[res];
+ return hctl->pelems[res];
}
-static int snd_hctl_build(snd_hctl_t *hctl)
+int snd_hctl_load(snd_hctl_t *hctl)
{
snd_ctl_elem_list_t list;
int err = 0;
@@ -353,8 +362,8 @@ static int snd_hctl_build(snd_hctl_t *hctl)
assert(hctl);
assert(hctl->ctl);
- assert(hctl->hcount == 0);
- assert(list_empty(&hctl->hlist));
+ assert(hctl->count == 0);
+ assert(list_empty(&hctl->elems));
memset(&list, 0, sizeof(list));
if ((err = snd_ctl_elem_list(hctl->ctl, &list)) < 0)
goto _end;
@@ -365,11 +374,11 @@ static int snd_hctl_build(snd_hctl_t *hctl)
if ((err = snd_ctl_elem_list(hctl->ctl, &list)) < 0)
goto _end;
}
- if (hctl->halloc < list.count) {
- hctl->halloc = list.count;
- free(hctl->helems);
- hctl->helems = malloc(hctl->halloc * sizeof(*hctl->helems));
- if (!hctl->helems) {
+ if (hctl->alloc < list.count) {
+ hctl->alloc = list.count;
+ free(hctl->pelems);
+ hctl->pelems = malloc(hctl->alloc * sizeof(*hctl->pelems));
+ if (!hctl->pelems) {
err = -ENOMEM;
goto _end;
}
@@ -384,20 +393,18 @@ static int snd_hctl_build(snd_hctl_t *hctl)
}
elem->id = list.pids[idx];
elem->hctl = hctl;
- hctl->helems[idx] = elem;
- list_add_tail(&elem->list, &hctl->hlist);
- hctl->hcount++;
+ hctl->pelems[idx] = elem;
+ list_add_tail(&elem->list, &hctl->elems);
+ hctl->count++;
}
- if (!hctl->hcompare)
- hctl->hcompare = snd_hctl_compare_default;
+ if (!hctl->compare)
+ hctl->compare = snd_hctl_compare_default;
snd_hctl_sort(hctl);
- if (hctl->callback) {
- for (idx = 0; idx < hctl->hcount; idx++) {
- int res = hctl->callback(hctl, SND_CTL_EVENT_ADD,
- hctl->helems[idx]);
- if (res < 0)
- return res;
- }
+ for (idx = 0; idx < hctl->count; idx++) {
+ int res = snd_hctl_throw_event(hctl, SND_CTL_EVENT_ADD,
+ hctl->pelems[idx]);
+ if (res < 0)
+ return res;
}
_end:
if (list.pids)
@@ -425,10 +432,10 @@ void *snd_hctl_get_callback_private(snd_hctl_t *hctl)
unsigned int snd_hctl_get_count(snd_hctl_t *hctl)
{
- return hctl->hcount;
+ return hctl->count;
}
-int snd_hctl_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
+int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
{
snd_hctl_elem_t *elem;
int res;
@@ -447,17 +454,12 @@ int snd_hctl_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
break;
}
case SND_CTL_EVENT_VALUE:
- case SND_CTL_EVENT_CHANGE:
+ case SND_CTL_EVENT_INFO:
elem = snd_hctl_find_elem(hctl, &event->data.id);
assert(elem);
if (!elem)
return -ENOENT;
- if (elem->callback) {
- res = elem->callback(elem, event->type);
- if (res < 0)
- return res;
- }
- break;
+ return snd_hctl_elem_throw_event(elem, event->type);
case SND_CTL_EVENT_ADD:
elem = calloc(1, sizeof(snd_hctl_elem_t));
if (elem == NULL)
@@ -470,12 +472,13 @@ int snd_hctl_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
break;
case SND_CTL_EVENT_REBUILD:
snd_hctl_free(hctl);
- res = snd_hctl_build(hctl);
- if (hctl->callback) {
- res = hctl->callback(hctl, event->type, NULL);
- if (res < 0)
- return res;
- }
+ res = snd_hctl_load(hctl);
+ if (res < 0)
+ return res;
+#if 0
+ /* I don't think this have to be passed to higher level */
+ return hctl_event(hctl, event->type, NULL);
+#endif
break;
default:
assert(0);
@@ -484,7 +487,7 @@ int snd_hctl_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
return 0;
}
-int snd_hctl_events(snd_hctl_t *hctl)
+int snd_hctl_handle_events(snd_hctl_t *hctl)
{
snd_ctl_event_t event;
int res;
@@ -494,7 +497,7 @@ int snd_hctl_events(snd_hctl_t *hctl)
while ((res = snd_ctl_read(hctl->ctl, &event)) != 0) {
if (res < 0)
return res;
- res = snd_hctl_event(hctl, &event);
+ res = snd_hctl_handle_event(hctl, &event);
if (res < 0)
return res;
}
@@ -510,7 +513,7 @@ int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t *info)
return snd_ctl_elem_info(elem->hctl->ctl, info);
}
-int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_t * value)
+int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
{
assert(elem);
assert(elem->hctl);
@@ -519,7 +522,7 @@ int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_t * value)
return snd_ctl_elem_read(elem->hctl->ctl, value);
}
-int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_t * value)
+int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
{
assert(elem);
assert(elem->hctl);
diff --git a/src/input.c b/src/input.c
index 5d57bf6d..b8f0244b 100644
--- a/src/input.c
+++ b/src/input.c
@@ -36,7 +36,7 @@ typedef struct _snd_input_ops {
struct _snd_input {
snd_input_type_t type;
snd_input_ops_t *ops;
- void *private;
+ void *private_data;
};
int snd_input_close(snd_input_t *input)
@@ -78,7 +78,7 @@ typedef struct _snd_input_stdio {
int snd_input_stdio_close(snd_input_t *input ATTRIBUTE_UNUSED)
{
- snd_input_stdio_t *stdio = input->private;
+ snd_input_stdio_t *stdio = input->private_data;
if (close)
fclose(stdio->fp);
free(stdio);
@@ -87,26 +87,26 @@ int snd_input_stdio_close(snd_input_t *input ATTRIBUTE_UNUSED)
int snd_input_stdio_scanf(snd_input_t *input, const char *format, va_list args)
{
- snd_input_stdio_t *stdio = input->private;
+ snd_input_stdio_t *stdio = input->private_data;
extern int vfscanf(FILE *fp, const char *format, va_list args);
return vfscanf(stdio->fp, format, args);
}
char *snd_input_stdio_gets(snd_input_t *input, char *str, size_t size)
{
- snd_input_stdio_t *stdio = input->private;
+ snd_input_stdio_t *stdio = input->private_data;
return fgets(str, size, stdio->fp);
}
int snd_input_stdio_getc(snd_input_t *input)
{
- snd_input_stdio_t *stdio = input->private;
+ snd_input_stdio_t *stdio = input->private_data;
return getc(stdio->fp);
}
int snd_input_stdio_ungetc(snd_input_t *input, int c)
{
- snd_input_stdio_t *stdio = input->private;
+ snd_input_stdio_t *stdio = input->private_data;
return ungetc(c, stdio->fp);
}
@@ -135,7 +135,7 @@ int snd_input_stdio_attach(snd_input_t **inputp, FILE *fp, int close)
stdio->close = close;
input->type = SND_INPUT_STDIO;
input->ops = &snd_input_stdio_ops;
- input->private = stdio;
+ input->private_data = stdio;
*inputp = input;
return 0;
}
@@ -162,7 +162,7 @@ typedef struct _snd_input_buffer {
int snd_input_buffer_close(snd_input_t *input)
{
- snd_input_buffer_t *buffer = input->private;
+ snd_input_buffer_t *buffer = input->private_data;
free(buffer->buf);
free(buffer);
return 0;
@@ -170,7 +170,7 @@ int snd_input_buffer_close(snd_input_t *input)
int snd_input_buffer_scanf(snd_input_t *input, const char *format, va_list args)
{
- snd_input_buffer_t *buffer = input->private;
+ snd_input_buffer_t *buffer = input->private_data;
extern int vsscanf(const char *buf, const char *format, va_list args);
/* FIXME: how can I obtain consumed chars count? */
assert(0);
@@ -179,7 +179,7 @@ int snd_input_buffer_scanf(snd_input_t *input, const char *format, va_list args)
char *snd_input_buffer_gets(snd_input_t *input, char *str, size_t size)
{
- snd_input_buffer_t *buffer = input->private;
+ snd_input_buffer_t *buffer = input->private_data;
size_t bsize = buffer->size;
while (--size > 0 && bsize > 0) {
unsigned char c = *buffer->ptr++;
@@ -197,7 +197,7 @@ char *snd_input_buffer_gets(snd_input_t *input, char *str, size_t size)
int snd_input_buffer_getc(snd_input_t *input)
{
- snd_input_buffer_t *buffer = input->private;
+ snd_input_buffer_t *buffer = input->private_data;
if (buffer->size == 0)
return EOF;
buffer->size--;
@@ -206,7 +206,7 @@ int snd_input_buffer_getc(snd_input_t *input)
int snd_input_buffer_ungetc(snd_input_t *input, int c)
{
- snd_input_buffer_t *buffer = input->private;
+ snd_input_buffer_t *buffer = input->private_data;
if (buffer->ptr == buffer->buf)
return EOF;
buffer->ptr--;
@@ -250,7 +250,7 @@ int snd_input_buffer_open(snd_input_t **inputp, const char *buf, int size)
buffer->size = size;
input->type = SND_INPUT_BUFFER;
input->ops = &snd_input_buffer_ops;
- input->private = buffer;
+ input->private_data = buffer;
*inputp = input;
return 0;
}
diff --git a/src/mixer/bag.c b/src/mixer/bag.c
index c941f84f..d1c5c544 100644
--- a/src/mixer/bag.c
+++ b/src/mixer/bag.c
@@ -1,6 +1,5 @@
/*
- * Control Interface - highlevel API - helem bag operations
- * Copyright (c) 2000 by Jaroslav Kysela <perex@suse.cz>
+ * Bag of pointers
* Copyright (c) 2001 by Abramo Bagnara <abramo@alsa-project.org>
*
*
@@ -20,61 +19,54 @@
*
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#define __USE_GNU
-#include <search.h>
#include "mixer_local.h"
-int snd_hctl_compare_fast(const snd_hctl_elem_t *c1,
- const snd_hctl_elem_t *c2);
-
-static void _free(void *ptr ATTRIBUTE_UNUSED) { };
-
-int snd_hctl_bag_destroy(snd_hctl_bag_t *bag)
+int bag_new(bag_t **bag)
{
- assert(bag != NULL);
- tdestroy(bag->root, _free);
- bag->root = NULL;
+ bag_t *b = malloc(sizeof(*b));
+ if (!b)
+ return -ENOMEM;
+ INIT_LIST_HEAD(b);
+ *bag = b;
return 0;
}
-int snd_hctl_bag_add(snd_hctl_bag_t *bag, snd_hctl_elem_t *helem)
+void bag_free(bag_t *bag)
{
- void *res;
- assert(bag != NULL && helem != NULL);
- res = tsearch(helem, &bag->root, (__compar_fn_t)snd_hctl_compare_fast);
- if (res == NULL)
- return -ENOMEM;
- if ((snd_hctl_elem_t *)res == helem)
- return -EALREADY;
- return 0;
+ assert(list_empty(bag));
+ free(bag);
}
-int snd_hctl_bag_del(snd_hctl_bag_t *bag, snd_hctl_elem_t *helem)
+int bag_empty(bag_t *bag)
{
- assert(bag != NULL && helem != NULL);
- if (tdelete(helem, &bag->root, (__compar_fn_t)snd_hctl_compare_fast) == NULL)
- return -ENOENT;
+ return list_empty(bag);
+}
+
+int bag_add(bag_t *bag, void *ptr)
+{
+ bag1_t *b = malloc(sizeof(*b));
+ if (!b)
+ return -ENOMEM;
+ b->ptr = ptr;
+ list_add_tail(&b->list, bag);
return 0;
}
-snd_hctl_elem_t *snd_hctl_bag_find(snd_hctl_bag_t *bag, snd_ctl_elem_id_t *id)
+int bag_del(bag_t *bag, void *ptr)
{
- void *res;
- assert(bag != NULL && id != NULL);
- if (bag->root == NULL)
- return NULL;
- res = tfind(id, &bag->root, (__compar_fn_t)snd_hctl_compare_fast);
- return res == NULL ? NULL : *(snd_hctl_elem_t **)res;
+ struct list_head *pos, *next;
+ list_for_each(pos, next, bag) {
+ bag1_t *b = list_entry(pos, bag1_t, list);
+ if (b->ptr == ptr) {
+ list_del(&b->list);
+ return 0;
+ }
+ }
+ return -ENOENT;
}
-int snd_hctl_bag_empty(snd_hctl_bag_t *bag)
+void bag_del_all(bag_t *bag)
{
- assert(bag != NULL);
- return bag->root == NULL;
+ while (!list_empty(bag))
+ list_del(bag->next);
}
diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c
index ee2db3fe..c99ff686 100644
--- a/src/mixer/mixer.c
+++ b/src/mixer/mixer.c
@@ -28,68 +28,319 @@
#include <sys/ioctl.h>
#include "mixer_local.h"
-int snd_mixer_open(snd_mixer_t **mixerp, char *name)
+typedef struct _snd_mixer_slave {
+ snd_hctl_t *hctl;
+ struct list_head list;
+} snd_mixer_slave_t;
+
+
+typedef struct _snd_mixer_elem_bag {
+
+} snd_mixer_elem_bag_t;
+
+int snd_mixer_open(snd_mixer_t **mixerp)
{
snd_mixer_t *mixer;
- snd_hctl_t *hctl;
- int err;
assert(mixerp);
- if ((err = snd_hctl_open(&hctl, name)) < 0)
- return err;
- mixer = calloc(1, sizeof(snd_mixer_t));
- if (mixer == NULL) {
- snd_hctl_close(hctl);
+ mixer = calloc(1, sizeof(*mixer));
+ if (mixer == NULL)
return -ENOMEM;
- }
- mixer->hctl = hctl;
+ INIT_LIST_HEAD(&mixer->slaves);
+ INIT_LIST_HEAD(&mixer->classes);
INIT_LIST_HEAD(&mixer->elems);
*mixerp = mixer;
return 0;
}
-int snd_mixer_add_elem(snd_mixer_t *mixer, snd_mixer_elem_t *elem)
+int snd_mixer_elem_attach(snd_mixer_elem_t *melem,
+ snd_hctl_elem_t *helem)
{
- elem->mixer = mixer;
- list_add_tail(&elem->list, &mixer->elems);
- mixer->count++;
- if (mixer->callback) {
- int err = mixer->callback(mixer, SND_CTL_EVENT_ADD, elem);
+ bag_t *bag = snd_hctl_elem_get_callback_private(helem);
+ int err;
+ err = bag_add(bag, melem);
+ if (err < 0)
+ return err;
+ return bag_add(&melem->helems, helem);
+}
+
+int snd_mixer_elem_detach(snd_mixer_elem_t *melem,
+ snd_hctl_elem_t *helem)
+{
+ bag_t *bag = snd_hctl_elem_get_callback_private(helem);
+ int err;
+ err = bag_del(bag, melem);
+ assert(err >= 0);
+ err = bag_del(&melem->helems, helem);
+ assert(err >= 0);
+ return 0;
+}
+
+int snd_mixer_elem_empty(snd_mixer_elem_t *melem)
+{
+ return bag_empty(&melem->helems);
+}
+
+static int hctl_elem_event_handler(snd_hctl_elem_t *helem,
+ snd_ctl_event_type_t event)
+{
+ bag_t *bag = snd_hctl_elem_get_callback_private(helem);
+ int res = 0;
+ switch (event) {
+ case SND_CTL_EVENT_VALUE:
+ case SND_CTL_EVENT_INFO:
+ {
+ int err = 0;
+ bag_iterator_t i, n;
+ bag_for_each(i, n, bag) {
+ snd_mixer_elem_t *melem = bag_iterator_entry(i);
+ snd_mixer_class_t *class = melem->class;
+ err = class->event(class, event, helem, melem);
+ if (err < 0)
+ break;
+ }
+ break;
+ }
+ case SND_CTL_EVENT_REMOVE:
+ {
+ int err;
+ bag_iterator_t i, n;
+ bag_for_each(i, n, bag) {
+ snd_mixer_elem_t *melem = bag_iterator_entry(i);
+ snd_mixer_class_t *class = melem->class;
+ err = class->event(class, event, helem, melem);
+ if (err < 0)
+ res = err;
+ }
+ assert(bag_empty(bag));
+ bag_free(bag);
+ break;
+
+ }
+ default:
+ assert(0);
+ break;
+ }
+ return res;
+}
+
+static int hctl_event_handler(snd_hctl_t *hctl, snd_ctl_event_type_t event,
+ snd_hctl_elem_t *elem)
+{
+ snd_mixer_t *mixer = snd_hctl_get_callback_private(hctl);
+ int res = 0;
+ switch (event) {
+ case SND_CTL_EVENT_ADD:
+ {
+ struct list_head *pos, *next;
+ bag_t *bag;
+ int err = bag_new(&bag);
if (err < 0)
return err;
+ snd_hctl_elem_set_callback(elem, hctl_elem_event_handler);
+ snd_hctl_elem_set_callback_private(elem, bag);
+ list_for_each(pos, next, &mixer->classes) {
+ snd_mixer_class_t *c;
+ c = list_entry(pos, snd_mixer_class_t, list);
+ err = c->event(c, event, elem, NULL);
+ if (err < 0)
+ res = err;
+ }
+ break;
+ }
+ default:
+ assert(0);
+ break;
+ }
+ return res;
+}
+
+
+int snd_mixer_attach(snd_mixer_t *mixer, const char *name)
+{
+ snd_mixer_slave_t *slave;
+ snd_hctl_t *hctl;
+ int err;
+ slave = calloc(1, sizeof(*slave));
+ if (slave == NULL)
+ return -ENOMEM;
+ err = snd_hctl_open(&hctl, name);
+ if (err < 0) {
+ free(slave);
+ return err;
+ }
+ err = snd_hctl_nonblock(hctl, 1);
+ if (err < 0) {
+ snd_hctl_close(hctl);
+ free(slave);
+ return err;
+ }
+ snd_hctl_set_callback(hctl, hctl_event_handler);
+ snd_hctl_set_callback_private(hctl, mixer);
+ slave->hctl = hctl;
+ list_add_tail(&slave->list, &mixer->slaves);
+ return 0;
+}
+
+int snd_mixer_detach(snd_mixer_t *mixer, const char *name)
+{
+ struct list_head *pos, *next;
+ list_for_each(pos, next, &mixer->slaves) {
+ snd_mixer_slave_t *s;
+ s = list_entry(pos, snd_mixer_slave_t, list);
+ if (strcmp(name, snd_hctl_name(s->hctl)) == 0) {
+ snd_hctl_close(s->hctl);
+ list_del(pos);
+ free(s);
+ return 0;
+ }
}
+ return -ENOENT;
+}
+
+int snd_mixer_throw_event(snd_mixer_t *mixer, snd_ctl_event_type_t event,
+ snd_mixer_elem_t *elem)
+{
+ if (mixer->callback)
+ return mixer->callback(mixer, event, elem);
return 0;
}
-void snd_mixer_remove_elem(snd_mixer_elem_t *elem)
+int snd_mixer_elem_throw_event(snd_mixer_elem_t *elem,
+ snd_ctl_event_type_t event)
{
- snd_mixer_t *mixer = elem->mixer;
- if (elem->private_free)
- elem->private_free(elem);
if (elem->callback)
- elem->callback(elem, SND_CTL_EVENT_REMOVE);
+ return elem->callback(elem, event);
+ return 0;
+}
+
+int snd_mixer_elem_add(snd_mixer_elem_t *elem, snd_mixer_class_t *class)
+{
+ snd_mixer_t *mixer = class->mixer;
+ elem->class = class;
+ list_add_tail(&elem->list, &mixer->elems);
+ mixer->count++;
+ return snd_mixer_throw_event(mixer, SND_CTL_EVENT_ADD, elem);
+}
+
+int snd_mixer_elem_remove(snd_mixer_elem_t *elem)
+{
+ snd_mixer_t *mixer = elem->class->mixer;
+ int err;
+ err = snd_mixer_elem_throw_event(elem, SND_CTL_EVENT_REMOVE);
list_del(&elem->list);
free(elem);
mixer->count--;
+ return err;
+}
+
+int snd_mixer_elem_change(snd_mixer_elem_t *elem)
+{
+ return snd_mixer_elem_throw_event(elem, SND_CTL_EVENT_INFO);
+}
+
+
+int snd_mixer_class_register(snd_mixer_class_t *class, snd_mixer_t *mixer)
+{
+ struct list_head *pos, *next;
+ class->mixer = mixer;
+ list_add_tail(&class->list, &mixer->classes);
+ if (!class->event)
+ return 0;
+ list_for_each(pos, next, &mixer->slaves) {
+ int err;
+ snd_mixer_slave_t *slave;
+ snd_hctl_elem_t *elem;
+ slave = list_entry(pos, snd_mixer_slave_t, list);
+ elem = snd_hctl_first_elem(slave->hctl);
+ while (elem) {
+ err = class->event(class, SND_CTL_EVENT_ADD, elem, NULL);
+ if (err < 0)
+ return err;
+ elem = snd_hctl_elem_next(elem);
+ }
+ }
+ return 0;
+}
+
+int snd_mixer_class_unregister(snd_mixer_class_t *class)
+{
+ struct list_head *pos, *next;
+ snd_mixer_t *mixer = class->mixer;
+ list_for_each(pos, next, &mixer->elems) {
+ snd_mixer_elem_t *e;
+ e = list_entry(pos, snd_mixer_elem_t, list);
+ if (e->class == class && e->private_free)
+ e->private_free(e);
+ snd_mixer_elem_remove(e);
+ }
+ if (class->private_free)
+ class->private_free(class);
+ list_del(&class->list);
+ free(class);
+ return 0;
+}
+
+int snd_mixer_load(snd_mixer_t *mixer)
+{
+ struct list_head *pos, *next;
+ list_for_each(pos, next, &mixer->slaves) {
+ int err;
+ snd_mixer_slave_t *s;
+ s = list_entry(pos, snd_mixer_slave_t, list);
+ err = snd_hctl_load(s->hctl);
+ if (err < 0)
+ return err;
+ }
+ return 0;
}
void snd_mixer_free(snd_mixer_t *mixer)
{
- while (!list_empty(&mixer->elems))
- snd_mixer_remove_elem(list_entry(mixer->elems.next, snd_mixer_elem_t, list));
+ struct list_head *pos, *next;
+ list_for_each(pos, next, &mixer->slaves) {
+ snd_mixer_slave_t *s;
+ s = list_entry(pos, snd_mixer_slave_t, list);
+ snd_hctl_free(s->hctl);
+ }
}
int snd_mixer_close(snd_mixer_t *mixer)
{
+ int res = 0;
assert(mixer);
- snd_mixer_free(mixer);
- return snd_hctl_close(mixer->hctl);
+ while (!list_empty(&mixer->classes)) {
+ snd_mixer_class_t *c;
+ c = list_entry(mixer->classes.next, snd_mixer_class_t, list);
+ snd_mixer_class_unregister(c);
+ }
+ assert(list_empty(&mixer->elems));
+ while (!list_empty(&mixer->slaves)) {
+ int err;
+ snd_mixer_slave_t *s;
+ s = list_entry(mixer->slaves.next, snd_mixer_slave_t, list);
+ err = snd_hctl_close(s->hctl);
+ if (err < 0)
+ res = err;
+ list_del(&s->list);
+ free(s);
+ }
+ free(mixer);
+ return res;
}
-int snd_mixer_poll_descriptor(snd_mixer_t *mixer)
+int snd_mixer_poll_descriptor(snd_mixer_t *mixer, const char *name)
{
- if (mixer == NULL || mixer->hctl == NULL)
- return -EIO;
- return snd_hctl_poll_descriptor(mixer->hctl);
+ struct list_head *pos, *next;
+ assert(mixer && name);
+ list_for_each(pos, next, &mixer->slaves) {
+ snd_mixer_slave_t *s;
+ const char *n;
+ s = list_entry(pos, snd_mixer_slave_t, list);
+ n = snd_hctl_name(s->hctl);
+ if (n && strcmp(name, n) == 0)
+ return snd_hctl_poll_descriptor(s->hctl);
+ }
+ return -ENOENT;
}
snd_mixer_elem_t *snd_mixer_first_elem(snd_mixer_t *mixer)
@@ -111,7 +362,7 @@ snd_mixer_elem_t *snd_mixer_last_elem(snd_mixer_t *mixer)
snd_mixer_elem_t *snd_mixer_elem_next(snd_mixer_elem_t *elem)
{
assert(elem);
- if (elem->list.next == &elem->mixer->elems)
+ if (elem->list.next == &elem->class->mixer->elems)
return NULL;
return list_entry(elem->list.next, snd_mixer_elem_t, list);
}
@@ -119,13 +370,23 @@ snd_mixer_elem_t *snd_mixer_elem_next(snd_mixer_elem_t *elem)
snd_mixer_elem_t *snd_mixer_elem_prev(snd_mixer_elem_t *elem)
{
assert(elem);
- if (elem->list.prev == &elem->mixer->elems)
+ if (elem->list.prev == &elem->class->mixer->elems)
return NULL;
return list_entry(elem->list.prev, snd_mixer_elem_t, list);
}
-int snd_mixer_events(snd_mixer_t *mixer)
+int snd_mixer_handle_events(snd_mixer_t *mixer)
{
- return snd_hctl_events(mixer->hctl);
+ struct list_head *pos, *next;
+ assert(mixer);
+ list_for_each(pos, next, &mixer->slaves) {
+ int err;
+ snd_mixer_slave_t *s;
+ s = list_entry(pos, snd_mixer_slave_t, list);
+ err = snd_hctl_handle_events(s->hctl);
+ if (err < 0)
+ return err;
+ }
+ return 0;
}
diff --git a/src/mixer/mixer_local.h b/src/mixer/mixer_local.h
index 53447991..f779476b 100644
--- a/src/mixer/mixer_local.h
+++ b/src/mixer/mixer_local.h
@@ -20,62 +20,94 @@
*
*/
-//#include "../control/control_local.h"
#include "list.h"
#include "local.h"
-typedef struct _snd_hctl_bag {
- void *root;
- void *private;
-} snd_hctl_bag_t;
+typedef struct _bag1 {
+ void *ptr;
+ struct list_head list;
+} bag1_t;
-int snd_hctl_bag_destroy(snd_hctl_bag_t *bag);
-int snd_hctl_bag_add(snd_hctl_bag_t *bag, snd_hctl_elem_t *helem);
-int snd_hctl_bag_del(snd_hctl_bag_t *bag, snd_hctl_elem_t *helem);
-snd_hctl_elem_t *snd_hctl_bag_find(snd_hctl_bag_t *bag, snd_ctl_elem_id_t *id);
-int snd_hctl_bag_empty(snd_hctl_bag_t *bag);
+typedef struct list_head bag_t;
+
+int bag_new(bag_t **bag);
+void bag_free(bag_t *bag);
+int bag_add(bag_t *bag, void *ptr);
+int bag_del(bag_t *bag, void *ptr);
+int bag_empty(bag_t *bag);
+
+typedef struct list_head *bag_iterator_t;
+
+#define bag_iterator_entry(i) (list_entry((i), bag1_t, list)->ptr)
+#define bag_for_each(pos, next, bag) list_for_each(pos, next, bag)
+
+struct _snd_mixer_class {
+ struct list_head list;
+ snd_mixer_t *mixer;
+ int (*event)(snd_mixer_class_t *class, snd_ctl_event_type_t event,
+ snd_hctl_elem_t *helem, snd_mixer_elem_t *melem);
+ void *private_data;
+ void (*private_free)(snd_mixer_class_t *class);
+};
struct _snd_mixer_elem {
snd_mixer_elem_type_t type;
struct list_head list; /* links for list of all elems */
- void *private;
+ snd_mixer_class_t *class;
+ void *private_data;
void (*private_free)(snd_mixer_elem_t *elem);
snd_mixer_elem_callback_t callback;
void *callback_private;
- snd_mixer_t *mixer;
+ bag_t helems;
};
struct _snd_mixer {
- snd_hctl_t *hctl;
- struct list_head elems; /* list of all elemss */
+ struct list_head slaves; /* list of all slaves */
+ struct list_head classes; /* list of all elem classes */
+ struct list_head elems; /* list of all elems */
+
unsigned int count;
snd_mixer_callback_t callback;
void *callback_private;
};
-#define SND_MIXER_SCTCAP_VOLUME (1<<0)
-#define SND_MIXER_SCTCAP_JOIN_VOLUME (1<<1)
-#define SND_MIXER_SCTCAP_MUTE (1<<2)
-#define SND_MIXER_SCTCAP_JOIN_MUTE (1<<3)
-#define SND_MIXER_SCTCAP_CAPTURE (1<<4)
-#define SND_MIXER_SCTCAP_JOIN_CAPTURE (1<<5)
-#define SND_MIXER_SCTCAP_EXCL_CAPTURE (1<<6)
-
struct _snd_mixer_selem_id {
unsigned char name[60];
unsigned int index;
};
-struct _snd_mixer_selem {
- unsigned int caps; /* RO: capabilities */
- unsigned int channels; /* RO: bitmap of active channels */
+#define CAP_VOLUME (1<<0)
+#define CAP_JOIN_VOLUME (1<<1)
+#define CAP_MUTE (1<<2)
+#define CAP_JOIN_MUTE (1<<3)
+#define CAP_CAPTURE (1<<4)
+#define CAP_JOIN_CAPTURE (1<<5)
+#define CAP_EXCL_CAPTURE (1<<6)
+
+struct _snd_mixer_selem_info {
+ unsigned int caps; /* capabilities */
+ unsigned int channels; /* bitmap of active channels */
+ int capture_group; /* capture group (for exclusive capture) */
+ long min; /* minimum value */
+ long max; /* maximum value */
+};
+
+struct _snd_mixer_selem_value {
unsigned int mute; /* RW: bitmap of muted channels */
unsigned int capture; /* RW: bitmap of capture channels */
- int capture_group; /* RO: capture group (for exclusive capture) */
- long min; /* RO: minimum value */
- long max; /* RO: maximum value */
long volume[32];
};
+int snd_mixer_class_register(snd_mixer_class_t *class, snd_mixer_t *mixer);
int snd_mixer_add_elem(snd_mixer_t *mixer, snd_mixer_elem_t *elem);
-void snd_mixer_free(snd_mixer_t *mixer);
+int snd_mixer_remove_elem(snd_mixer_t *mixer, snd_mixer_elem_t *elem);
+int snd_mixer_elem_throw_event(snd_mixer_elem_t *elem,
+ snd_ctl_event_type_t event);
+int snd_mixer_elem_add(snd_mixer_elem_t *elem, snd_mixer_class_t *class);
+int snd_mixer_elem_remove(snd_mixer_elem_t *elem);
+int snd_mixer_elem_change(snd_mixer_elem_t *elem);
+int snd_mixer_elem_attach(snd_mixer_elem_t *melem,
+ snd_hctl_elem_t *helem);
+int snd_mixer_elem_detach(snd_mixer_elem_t *melem,
+ snd_hctl_elem_t *helem);
+int snd_mixer_elem_empty(snd_mixer_elem_t *melem);
diff --git a/src/mixer/mixer_m4.c b/src/mixer/mixer_m4.c
index acfbaa61..2df7a180 100644
--- a/src/mixer/mixer_m4.c
+++ b/src/mixer/mixer_m4.c
@@ -118,88 +118,113 @@ snd_mixer_elem_type_t snd_mixer_elem_get_type(const snd_mixer_elem_t *obj)
return obj->type;
}
-size_t snd_mixer_selem_sizeof()
+size_t snd_mixer_selem_info_sizeof()
{
- return sizeof(snd_mixer_selem_t);
+ return sizeof(snd_mixer_selem_info_t);
}
-int snd_mixer_selem_malloc(snd_mixer_selem_t **ptr)
+int snd_mixer_selem_info_malloc(snd_mixer_selem_info_t **ptr)
{
assert(ptr);
- *ptr = calloc(1, sizeof(snd_mixer_selem_t));
+ *ptr = calloc(1, sizeof(snd_mixer_selem_info_t));
if (!*ptr)
return -ENOMEM;
return 0;
}
-void snd_mixer_selem_free(snd_mixer_selem_t *obj)
+void snd_mixer_selem_info_free(snd_mixer_selem_info_t *obj)
{
free(obj);
}
-void snd_mixer_selem_copy(snd_mixer_selem_t *dst, const snd_mixer_selem_t *src)
+void snd_mixer_selem_info_copy(snd_mixer_selem_info_t *dst, const snd_mixer_selem_info_t *src)
{
assert(dst && src);
*dst = *src;
}
-long snd_mixer_selem_get_min(const snd_mixer_selem_t *obj)
+long snd_mixer_selem_info_get_min(const snd_mixer_selem_info_t *obj)
{
assert(obj);
return obj->min;
}
-long snd_mixer_selem_get_max(const snd_mixer_selem_t *obj)
+long snd_mixer_selem_info_get_max(const snd_mixer_selem_info_t *obj)
{
assert(obj);
return obj->max;
}
-int snd_mixer_selem_get_capture_group(const snd_mixer_selem_t *obj)
+int snd_mixer_selem_info_get_capture_group(const snd_mixer_selem_info_t *obj)
{
assert(obj);
return obj->capture_group;
}
-int snd_mixer_selem_has_volume(const snd_mixer_selem_t *obj)
+int snd_mixer_selem_info_has_volume(const snd_mixer_selem_info_t *obj)
{
assert(obj);
- return !!(obj->caps & SND_MIXER_SCTCAP_VOLUME);
+ return !!(obj->caps & CAP_VOLUME);
}
-int snd_mixer_selem_has_joined_volume(const snd_mixer_selem_t *obj)
+int snd_mixer_selem_info_has_joined_volume(const snd_mixer_selem_info_t *obj)
{
assert(obj);
- return !!(obj->caps & SND_MIXER_SCTCAP_JOIN_VOLUME);
+ return !!(obj->caps & CAP_JOIN_VOLUME);
}
-int snd_mixer_selem_has_mute(const snd_mixer_selem_t *obj)
+int snd_mixer_selem_info_has_mute(const snd_mixer_selem_info_t *obj)
{
assert(obj);
- return !!(obj->caps & SND_MIXER_SCTCAP_MUTE);
+ return !!(obj->caps & CAP_MUTE);
}
-int snd_mixer_selem_has_joined_mute(const snd_mixer_selem_t *obj)
+int snd_mixer_selem_info_has_joined_mute(const snd_mixer_selem_info_t *obj)
{
assert(obj);
- return !!(obj->caps & SND_MIXER_SCTCAP_JOIN_MUTE);
+ return !!(obj->caps & CAP_JOIN_MUTE);
}
-int snd_mixer_selem_has_capture(const snd_mixer_selem_t *obj)
+int snd_mixer_selem_info_has_capture(const snd_mixer_selem_info_t *obj)
{
assert(obj);
- return !!(obj->caps & SND_MIXER_SCTCAP_CAPTURE);
+ return !!(obj->caps & CAP_CAPTURE);
}
-int snd_mixer_selem_has_joined_capture(const snd_mixer_selem_t *obj)
+int snd_mixer_selem_info_has_joined_capture(const snd_mixer_selem_info_t *obj)
{
assert(obj);
- return !!(obj->caps & SND_MIXER_SCTCAP_JOIN_CAPTURE);
+ return !!(obj->caps & CAP_JOIN_CAPTURE);
}
-int snd_mixer_selem_has_exclusive_capture(const snd_mixer_selem_t *obj)
+int snd_mixer_selem_info_has_exclusive_capture(const snd_mixer_selem_info_t *obj)
{
assert(obj);
- return !!(obj->caps & SND_MIXER_SCTCAP_EXCL_CAPTURE);
+ return !!(obj->caps & CAP_EXCL_CAPTURE);
+}
+
+size_t snd_mixer_selem_value_sizeof()
+{
+ return sizeof(snd_mixer_selem_value_t);
+}
+
+int snd_mixer_selem_value_malloc(snd_mixer_selem_value_t **ptr)
+{
+ assert(ptr);
+ *ptr = calloc(1, sizeof(snd_mixer_selem_value_t));
+ if (!*ptr)
+ return -ENOMEM;
+ return 0;
+}
+
+void snd_mixer_selem_value_free(snd_mixer_selem_value_t *obj)
+{
+ free(obj);
+}
+
+void snd_mixer_selem_value_copy(snd_mixer_selem_value_t *dst, const snd_mixer_selem_value_t *src)
+{
+ assert(dst && src);
+ *dst = *src;
}
diff --git a/src/mixer/simple.c b/src/mixer/simple.c
index 0e955586..baeb0e38 100644
--- a/src/mixer/simple.c
+++ b/src/mixer/simple.c
@@ -31,47 +31,46 @@
typedef struct _mixer_simple mixer_simple_t;
typedef int (mixer_simple_read_t)(snd_mixer_elem_t *elem,
- snd_mixer_selem_t *value);
+ snd_mixer_selem_value_t *value);
typedef int (mixer_simple_write_t)(snd_mixer_elem_t *elem,
- const snd_mixer_selem_t *control);
-
-#define MIXER_PRESENT_SINGLE_SWITCH (1<<0)
-#define MIXER_PRESENT_SINGLE_VOLUME (1<<1)
-#define MIXER_PRESENT_GLOBAL_SWITCH (1<<2)
-#define MIXER_PRESENT_GLOBAL_VOLUME (1<<3)
-#define MIXER_PRESENT_GLOBAL_ROUTE (1<<4)
-#define MIXER_PRESENT_PLAYBACK_SWITCH (1<<5)
-#define MIXER_PRESENT_PLAYBACK_VOLUME (1<<6)
-#define MIXER_PRESENT_PLAYBACK_ROUTE (1<<7)
-#define MIXER_PRESENT_CAPTURE_SWITCH (1<<8)
-#define MIXER_PRESENT_CAPTURE_VOLUME (1<<9)
-#define MIXER_PRESENT_CAPTURE_ROUTE (1<<10)
-#define MIXER_PRESENT_CAPTURE_SOURCE (1<<11)
+ const snd_mixer_selem_value_t *control);
+typedef int (mixer_simple_info_t)(snd_mixer_elem_t *elem,
+ snd_mixer_selem_info_t *info);
+
+typedef enum _selem_ctl_type {
+ CTL_SINGLE,
+ CTL_GLOBAL_SWITCH,
+ CTL_GLOBAL_VOLUME,
+ CTL_GLOBAL_ROUTE,
+ CTL_PLAYBACK_SWITCH,
+ CTL_PLAYBACK_VOLUME,
+ CTL_PLAYBACK_ROUTE,
+ CTL_CAPTURE_SWITCH,
+ CTL_CAPTURE_VOLUME,
+ CTL_CAPTURE_ROUTE,
+ CTL_CAPTURE_SOURCE,
+ CTL_LAST = CTL_CAPTURE_SOURCE,
+} selem_ctl_type_t;
+
+typedef struct _selem_ctl {
+ snd_hctl_elem_t *elem;
+ snd_ctl_elem_type_t type;
+ unsigned int values;
+ long min, max;
+} selem_ctl_t;
typedef struct _selem {
snd_mixer_selem_id_t id;
- unsigned int present; /* present controls */
- unsigned int global_values;
- unsigned int gswitch_values;
- unsigned int pswitch_values;
- unsigned int cswitch_values;
- unsigned int gvolume_values;
- unsigned int pvolume_values;
- unsigned int cvolume_values;
- unsigned int groute_values;
- unsigned int proute_values;
- unsigned int croute_values;
- unsigned int ccapture_values;
+ selem_ctl_t ctls[CTL_LAST + 1];
unsigned int capture_item;
unsigned int caps;
long min;
long max;
- int voices;
+ unsigned int channels;
/* -- */
mixer_simple_read_t *read;
mixer_simple_write_t *write;
- snd_hctl_bag_t elems; /* bag of associated elems */
- unsigned long private_value;
+ mixer_simple_info_t *info;
} selem_t;
static struct mixer_name_table {
@@ -85,104 +84,18 @@ static struct mixer_name_table {
{0, 0},
};
-const char *snd_mixer_channel_name(snd_mixer_channel_id_t channel)
-{
- static char *array[snd_enum_to_int(SND_MIXER_CHN_LAST) + 1] = {
- [SND_MIXER_CHN_FRONT_LEFT] = "Front Left",
- [SND_MIXER_CHN_FRONT_RIGHT] = "Front Right",
- [SND_MIXER_CHN_FRONT_CENTER] = "Front Center",
- [SND_MIXER_CHN_REAR_LEFT] = "Rear Left",
- [SND_MIXER_CHN_REAR_RIGHT] = "Rear Right",
- [SND_MIXER_CHN_WOOFER] = "Woofer"
- };
- char *p;
- assert(channel <= SND_MIXER_CHN_LAST);
- p = array[snd_enum_to_int(channel)];
- if (!p)
- return "?";
- return p;
-}
-
-static snd_hctl_elem_t *test_mixer_id(snd_mixer_t *mixer, const char *name, int index)
-{
- snd_ctl_elem_id_t id;
- snd_hctl_elem_t *helem;
-
- memset(&id, 0, sizeof(id));
- id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
- strcpy(id.name, name);
- id.index = index;
- helem = snd_hctl_find_elem(mixer->hctl, &id);
- // fprintf(stderr, "Looking for control: '%s', %i (0x%lx)\n", name, index, (long)helem);
- return helem;
-}
-
-static int get_mixer_info(snd_mixer_t *mixer, const char *name, int index, snd_ctl_elem_info_t *info)
-{
- snd_hctl_elem_t *helem = test_mixer_id(mixer, name, index);
- if (helem == NULL)
- return -EINVAL;
- return snd_hctl_elem_info(helem, info);
-}
-
-static int get_mixer_read(snd_mixer_t *mixer, const char *name, int index, snd_ctl_elem_t *control)
-{
- snd_hctl_elem_t *helem = test_mixer_id(mixer, name, index);
- if (helem == NULL)
- return -EINVAL;
- return snd_hctl_elem_read(helem, control);
-}
-
-static int put_mixer_write(snd_mixer_t *mixer, const char *name, int index, snd_ctl_elem_t *control)
-{
- snd_hctl_elem_t *helem = test_mixer_id(mixer, name, index);
- if (helem == NULL)
- return -EINVAL;
- control->id.numid = 0;
- control->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
- strcpy(control->id.name, name);
- control->id.device = control->id.subdevice = 0;
- control->id.index = index;
- control->indirect = 0;
- return snd_hctl_elem_write(helem, control);
-}
-
-static int hctl_elem_event(snd_hctl_elem_t *helem,
- snd_ctl_event_type_t type)
+static const char *get_short_name(const char *lname)
{
- switch (type) {
- case SND_CTL_EVENT_CHANGE:
- case SND_CTL_EVENT_REMOVE:
- /* ignore at this moment */
- break;
- case SND_CTL_EVENT_VALUE:
- {
- snd_hctl_bag_t *bag = snd_hctl_elem_get_callback_private(helem);
- snd_mixer_elem_t *e = bag->private;
- if (e->callback) {
- int res = e->callback(e, type);
- if (res < 0)
- return res;
- }
- break;
- }
- default:
- assert(0);
- break;
+ struct mixer_name_table *p;
+ for (p = name_table; p->longname; p++) {
+ if (!strcmp(lname, p->longname))
+ return p->shortname;
}
- return 0;
-}
-
-static void hctl_elem_add(selem_t *s, snd_hctl_elem_t *helem)
-{
- int err;
- err = snd_hctl_bag_add(&s->elems, helem);
- assert(err >= 0);
- snd_hctl_elem_set_callback(helem, hctl_elem_event);
- snd_hctl_elem_set_callback_private(helem, &s->elems);
+ return lname;
}
-static const char *get_full_name(const char *sname)
+#if 0
+static const char *get_long_name(const char *sname)
{
struct mixer_name_table *p;
for (p = name_table; p->longname; p++) {
@@ -192,288 +105,320 @@ static const char *get_full_name(const char *sname)
return sname;
}
-static const char *get_short_name(const char *lname)
+static const char *simple_elems[] = {
+ "Master Mono",
+ "Master Digital",
+ "Master",
+ "Tone Control - Bass",
+ "Tone Control - Treble",
+ "Synth Tone Control - Bass",
+ "Synth Tone Control - Treble",
+ "PCM",
+ "Surround",
+ "Synth",
+ "FM",
+ "Wave",
+ "Music",
+ "DSP",
+ "Line",
+ "CD",
+ "Mic",
+ "Video",
+ "Phone",
+ "PC Speaker",
+ "Aux",
+ "Mono Output",
+ "Mono",
+ "Playback",
+ "Capture Boost",
+ "Capture",
+ NULL
+};
+#endif
+
+static int selem_info(snd_mixer_elem_t *elem,
+ snd_mixer_selem_info_t *info)
{
- struct mixer_name_table *p;
- for (p = name_table; p->longname; p++) {
- if (!strcmp(lname, p->longname))
- return p->shortname;
- }
- return lname;
+ selem_t *simple;
+
+ assert(elem->type == SND_MIXER_ELEM_SIMPLE);
+ simple = elem->private_data;
+
+ info->caps = simple->caps;
+ info->channels |= (1 << (simple->channels + 1)) - 1;
+ info->capture_group = 0;
+ info->min = simple->min;
+ info->max = simple->max;
+ return 0;
}
-static int elem_read_volume(snd_mixer_t *mixer, selem_t *simple, snd_mixer_selem_t *control, const char *direction, const char *postfix, int voices)
+static int elem_read_volume(selem_t *simple, selem_ctl_type_t type,
+ snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s%s%s", get_full_name(simple->id.name), direction, postfix);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < simple->voices && idx < 32; idx++)
- control->volume[idx] = ctl.value.integer.value[voices == 1 ? 0 : idx];
+ for (idx = 0; idx < simple->channels; idx++)
+ control->volume[idx] = ctl.value.integer.value[simple->ctls[type].values == 1 ? 0 : idx];
return 0;
}
-static int elem_read_mute_switch(snd_mixer_t *mixer, selem_t *simple, snd_mixer_selem_t *control, const char *direction, const char *postfix, int voices)
+static int elem_read_mute_switch(selem_t *simple, selem_ctl_type_t type,
+ snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s%s%s", get_full_name(simple->id.name), direction, postfix);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < simple->voices && idx < 32; idx++)
- if (ctl.value.integer.value[voices == 1 ? 0 : idx] == 0)
+ for (idx = 0; idx < simple->channels; idx++)
+ if (ctl.value.integer.value[simple->ctls[type].values == 1 ? 0 : idx] == 0)
control->mute |= 1 << idx;
return 0;
}
-static int elem_read_mute_route(snd_mixer_t *mixer, selem_t *simple, snd_mixer_selem_t *control, const char *direction, int voices)
+static int elem_read_mute_route(selem_t *simple, selem_ctl_type_t type,
+ snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s %sRoute", get_full_name(simple->id.name), direction);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < simple->voices && idx < 32; idx++)
- if (ctl.value.integer.value[(idx * voices) + idx] == 0)
+ for (idx = 0; idx < simple->channels; idx++)
+ if (ctl.value.integer.value[(idx * simple->ctls[type].values) + idx] == 0)
control->mute |= 1 << idx;
return 0;
}
-static int elem_read_capture_switch(snd_mixer_t *mixer, selem_t *simple, snd_mixer_selem_t *control, const char *direction, int voices)
+static int elem_read_capture_switch(selem_t *simple, selem_ctl_type_t type,
+ snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s %sSwitch", get_full_name(simple->id.name), direction);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < simple->voices && idx < 32; idx++)
- if (ctl.value.integer.value[voices == 1 ? 0 : idx])
+ for (idx = 0; idx < simple->channels; idx++)
+ if (ctl.value.integer.value[simple->ctls[type].values == 1 ? 0 : idx])
control->capture |= 1 << idx;
return 0;
}
-static int elem_read_capture_route(snd_mixer_t *mixer, selem_t *simple, snd_mixer_selem_t *control, const char *direction, int voices)
+static int elem_read_capture_route(selem_t *simple, selem_ctl_type_t type,
+ snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s %sRoute", get_full_name(simple->id.name), direction);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < simple->voices && idx < 32; idx++)
- if (ctl.value.integer.value[(idx * voices) + idx])
+ for (idx = 0; idx < simple->channels; idx++)
+ if (ctl.value.integer.value[(idx * simple->ctls[type].values) + idx])
control->capture |= 1 << idx;
return 0;
}
-static int elem_read(snd_mixer_elem_t *elem,
- snd_mixer_selem_t *control)
+static int selem_read(snd_mixer_elem_t *elem,
+ snd_mixer_selem_value_t *control)
{
- snd_mixer_t *mixer;
selem_t *simple;
- int idx, err;
+ unsigned int idx;
+ int err;
assert(elem->type == SND_MIXER_ELEM_SIMPLE);
- simple = elem->private;
- mixer = elem->mixer;
+ simple = elem->private_data;
- control->caps = simple->caps;
- control->channels = 0;
control->mute = 0;
control->capture = 0;
- control->capture_group = 0;
- control->min = simple->min;
- control->max = simple->max;
for (idx = 0; idx < 32; idx++)
control->volume[idx] = 0;
- for (idx = 0; idx < simple->voices && idx < 32; idx++)
- control->channels |= 1 << idx;
- if (simple->caps & SND_MIXER_SCTCAP_VOLUME) {
- if (simple->present & MIXER_PRESENT_PLAYBACK_VOLUME) {
- elem_read_volume(mixer, simple, control, " Playback", " Volume", simple->pvolume_values);
- } else if (simple->present & MIXER_PRESENT_GLOBAL_VOLUME) {
- elem_read_volume(mixer, simple, control, "", " Volume", simple->gvolume_values);
- } else if (simple->present & MIXER_PRESENT_SINGLE_VOLUME) {
- elem_read_volume(mixer, simple, control, "", "", simple->global_values);
+ if (simple->caps & CAP_VOLUME) {
+ if (simple->ctls[CTL_PLAYBACK_VOLUME].elem) {
+ elem_read_volume(simple, CTL_PLAYBACK_VOLUME, control);
+ } else if (simple->ctls[CTL_GLOBAL_VOLUME].elem) {
+ elem_read_volume(simple, CTL_GLOBAL_VOLUME, control);
+ } else if (simple->ctls[CTL_SINGLE].elem &&
+ simple->ctls[CTL_SINGLE].type == SND_CTL_ELEM_TYPE_INTEGER) {
+ elem_read_volume(simple, CTL_SINGLE, control);
}
}
- if (simple->caps & SND_MIXER_SCTCAP_MUTE) {
- if (simple->present & MIXER_PRESENT_PLAYBACK_SWITCH) {
- elem_read_mute_switch(mixer, simple, control, " Playback", " Switch", simple->pswitch_values);
- } else if (simple->present & MIXER_PRESENT_GLOBAL_SWITCH) {
- elem_read_mute_switch(mixer, simple, control, "", " Switch", simple->gswitch_values);
- } else if (simple->present & MIXER_PRESENT_SINGLE_SWITCH) {
- elem_read_mute_switch(mixer, simple, control, "", "", simple->global_values);
- } else if (simple->present & MIXER_PRESENT_PLAYBACK_ROUTE) {
- elem_read_mute_route(mixer, simple, control, "Playback ", simple->proute_values);
- } else if (simple->present & MIXER_PRESENT_GLOBAL_ROUTE) {
- elem_read_mute_route(mixer, simple, control, "", simple->groute_values);
+ if (simple->caps & CAP_MUTE) {
+ if (simple->ctls[CTL_PLAYBACK_SWITCH].elem) {
+ elem_read_mute_switch(simple, CTL_PLAYBACK_SWITCH, control);
+ } else if (simple->ctls[CTL_GLOBAL_SWITCH].elem) {
+ elem_read_mute_switch(simple, CTL_GLOBAL_SWITCH, control);
+ } else if (simple->ctls[CTL_SINGLE].elem &&
+ simple->ctls[CTL_SINGLE].type == SND_CTL_ELEM_TYPE_BOOLEAN) {
+ elem_read_mute_switch(simple, CTL_SINGLE, control);
+ } else if (simple->ctls[CTL_PLAYBACK_ROUTE].elem) {
+ elem_read_mute_route(simple, CTL_PLAYBACK_ROUTE, control);
+ } else if (simple->ctls[CTL_GLOBAL_ROUTE].elem) {
+ elem_read_mute_route(simple, CTL_GLOBAL_ROUTE, control);
}
}
- if (simple->caps & SND_MIXER_SCTCAP_CAPTURE) {
- if (simple->present & MIXER_PRESENT_CAPTURE_SWITCH) {
- elem_read_capture_switch(mixer, simple, control, "Capture ", simple->cswitch_values);
- } else if (simple->present & MIXER_PRESENT_CAPTURE_ROUTE) {
- elem_read_capture_route(mixer, simple, control, "Capture ", simple->croute_values);
- } else if (simple->present & MIXER_PRESENT_CAPTURE_SOURCE) {
- snd_ctl_elem_t ctl;
- if ((err = get_mixer_read(mixer, "Capture Source", 0, &ctl)) < 0)
- return err;
- for (idx = 0; idx < simple->voices && idx < 32; idx++)
- if (ctl.value.enumerated.item[simple->ccapture_values == 1 ? 0 : idx] == simple->capture_item)
+ if (simple->caps & CAP_CAPTURE) {
+ if (simple->ctls[CTL_CAPTURE_SWITCH].elem) {
+ elem_read_capture_switch(simple, CTL_CAPTURE_SWITCH, control);
+ } else if (simple->ctls[CTL_CAPTURE_ROUTE].elem) {
+ elem_read_capture_route(simple, CTL_CAPTURE_ROUTE, control);
+ } else if (simple->ctls[CTL_CAPTURE_SOURCE].elem) {
+ snd_ctl_elem_value_t ctl;
+ memset(&ctl, 0, sizeof(ctl));
+ err = snd_hctl_elem_read(simple->ctls[CTL_CAPTURE_SOURCE].elem, &ctl);
+ assert(err >= 0);
+ for (idx = 0; idx < simple->channels; idx++)
+ if (snd_ctl_elem_value_get_enumerated(&ctl, simple->ctls[CTL_CAPTURE_SOURCE].values == 1 ? 0 : idx) == simple->capture_item)
control->capture |= 1 << idx;
}
}
return 0;
}
-static int elem_write_volume(snd_mixer_t *mixer, selem_t *simple, const snd_mixer_selem_t *control, const char *direction, const char *postfix, int voices)
+static int elem_write_volume(selem_t *simple, selem_ctl_type_t type,
+ const snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s%s%s", get_full_name(simple->id.name), direction, postfix);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < voices && idx < 32; idx++) {
+ for (idx = 0; idx < simple->ctls[type].values && idx < 32; idx++) {
ctl.value.integer.value[idx] = control->volume[idx];
// fprintf(stderr, "ctl.id.name = '%s', volume = %i [%i]\n", ctl.id.name, ctl.value.integer.value[idx], idx);
}
- if ((err = put_mixer_write(mixer, str, simple->id.index, &ctl)) < 0)
+ if ((err = snd_hctl_elem_write(simple->ctls[type].elem, &ctl)) < 0)
return err;
return 0;
}
-static int elem_write_mute_switch(snd_mixer_t *mixer, selem_t *simple, const snd_mixer_selem_t *control, const char *direction, const char *postfix, int voices)
+static int elem_write_mute_switch(selem_t *simple, selem_ctl_type_t type,
+ const snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s%s%s", get_full_name(simple->id.name), direction, postfix);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < voices && idx < 32; idx++)
+ for (idx = 0; idx < simple->ctls[type].values && idx < 32; idx++)
ctl.value.integer.value[idx] = (control->mute & (1 << idx)) ? 0 : 1;
- if ((err = put_mixer_write(mixer, str, simple->id.index, &ctl)) < 0)
+ if ((err = snd_hctl_elem_write(simple->ctls[type].elem, &ctl)) < 0)
return err;
return 0;
}
-static int elem_write_mute_route(snd_mixer_t *mixer, selem_t *simple, const snd_mixer_selem_t *control, const char *direction, int voices)
+static int elem_write_mute_route(selem_t *simple, selem_ctl_type_t type,
+ const snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s %sRoute", get_full_name(simple->id.name), direction);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < voices * voices; idx++)
+ for (idx = 0; idx < simple->ctls[type].values * simple->ctls[type].values; idx++)
ctl.value.integer.value[idx] = 0;
- for (idx = 0; idx < voices && idx < 32; idx++)
- ctl.value.integer.value[(idx * voices) + idx] = (control->mute & (1 << idx)) ? 0 : 1;
- if ((err = put_mixer_write(mixer, str, simple->id.index, &ctl)) < 0)
+ for (idx = 0; idx < simple->ctls[type].values && idx < 32; idx++)
+ ctl.value.integer.value[(idx * simple->ctls[type].values) + idx] = (control->mute & (1 << idx)) ? 0 : 1;
+ if ((err = snd_hctl_elem_write(simple->ctls[type].elem, &ctl)) < 0)
return err;
return 0;
}
-static int elem_write_capture_switch(snd_mixer_t *mixer, selem_t *simple, const snd_mixer_selem_t *control, const char *direction, int voices)
+static int elem_write_capture_switch(selem_t *simple, selem_ctl_type_t type,
+ const snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s %sSwitch", get_full_name(simple->id.name), direction);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < voices && idx < 32; idx++)
+ for (idx = 0; idx < simple->ctls[type].values && idx < 32; idx++)
ctl.value.integer.value[idx] = (control->capture & (1 << idx)) ? 1 : 0;
- if ((err = put_mixer_write(mixer, str, simple->id.index, &ctl)) < 0)
+ if ((err = snd_hctl_elem_write(simple->ctls[type].elem, &ctl)) < 0)
return err;
return 0;
}
-static int elem_write_capture_route(snd_mixer_t *mixer, selem_t *simple, const snd_mixer_selem_t *control, const char *direction, int voices)
+static int elem_write_capture_route(selem_t *simple, selem_ctl_type_t type,
+ const snd_mixer_selem_value_t *control)
{
- char str[128];
- snd_ctl_elem_t ctl;
- int idx, err;
-
- sprintf(str, "%s %sRoute", get_full_name(simple->id.name), direction);
- if ((err = get_mixer_read(mixer, str, simple->id.index, &ctl)) < 0)
+ snd_ctl_elem_value_t ctl;
+ unsigned int idx;
+ int err;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[type].elem, &ctl)) < 0)
return err;
- for (idx = 0; idx < voices * voices; idx++)
+ for (idx = 0; idx < simple->ctls[type].values * simple->ctls[type].values; idx++)
ctl.value.integer.value[idx] = 0;
- for (idx = 0; idx < voices && idx < 32; idx++)
- ctl.value.integer.value[(idx * voices) + idx] = (control->capture & (1 << idx)) ? 1 : 0;
- if ((err = put_mixer_write(mixer, str, simple->id.index, &ctl)) < 0)
+ for (idx = 0; idx < simple->ctls[type].values && idx < 32; idx++)
+ ctl.value.integer.value[(idx * simple->ctls[type].values) + idx] = (control->capture & (1 << idx)) ? 1 : 0;
+ if ((err = snd_hctl_elem_write(simple->ctls[type].elem, &ctl)) < 0)
return err;
return 0;
}
-static int elem_write(snd_mixer_elem_t *elem,
- const snd_mixer_selem_t *control)
+static int selem_write(snd_mixer_elem_t *elem,
+ const snd_mixer_selem_value_t *control)
{
- snd_mixer_t *mixer;
selem_t *simple;
- int idx, err;
+ unsigned int idx;
+ int err;
assert(elem->type == SND_MIXER_ELEM_SIMPLE);
- simple = elem->private;
- mixer = elem->mixer;
-
- if (simple->caps & SND_MIXER_SCTCAP_VOLUME) {
- if (simple->present & MIXER_PRESENT_PLAYBACK_VOLUME) {
- elem_write_volume(mixer, simple, control, " Playback", " Volume", simple->pvolume_values);
- if (simple->present & MIXER_PRESENT_CAPTURE_VOLUME)
- elem_write_volume(mixer, simple, control, " Capture", " Volume", simple->cvolume_values);
- } else if (simple->present & MIXER_PRESENT_GLOBAL_VOLUME) {
- elem_write_volume(mixer, simple, control, "", " Volume", simple->gvolume_values);
- } else if (simple->present & MIXER_PRESENT_SINGLE_VOLUME) {
- elem_write_volume(mixer, simple, control, "", "", simple->global_values);
+ simple = elem->private_data;
+
+ if (simple->caps & CAP_VOLUME) {
+ if (simple->ctls[CTL_PLAYBACK_VOLUME].elem) {
+ elem_write_volume(simple, CTL_PLAYBACK_VOLUME, control);
+ if (simple->ctls[CTL_CAPTURE_VOLUME].elem)
+ elem_write_volume(simple, CTL_CAPTURE_VOLUME, control);
+ } else if (simple->ctls[CTL_GLOBAL_VOLUME].elem) {
+ elem_write_volume(simple, CTL_GLOBAL_VOLUME, control);
+ } else if (simple->ctls[CTL_SINGLE].elem &&
+ simple->ctls[CTL_SINGLE].type == SND_CTL_ELEM_TYPE_INTEGER) {
+ elem_write_volume(simple, CTL_SINGLE, control);
}
}
- if (simple->caps & SND_MIXER_SCTCAP_MUTE) {
- if (simple->present & MIXER_PRESENT_PLAYBACK_SWITCH)
- elem_write_mute_switch(mixer, simple, control, " Playback", " Switch", simple->pswitch_values);
- if (simple->present & MIXER_PRESENT_GLOBAL_SWITCH)
- elem_write_mute_switch(mixer, simple, control, "", " Switch", simple->gswitch_values);
- if (simple->present & MIXER_PRESENT_SINGLE_SWITCH)
- elem_write_mute_switch(mixer, simple, control, "", "", simple->global_values);
- if (simple->present & MIXER_PRESENT_PLAYBACK_ROUTE)
- elem_write_mute_route(mixer, simple, control, "Playback ", simple->proute_values);
- if (simple->present & MIXER_PRESENT_GLOBAL_ROUTE)
- elem_write_mute_route(mixer, simple, control, "", simple->groute_values);
+ if (simple->caps & CAP_MUTE) {
+ if (simple->ctls[CTL_PLAYBACK_SWITCH].elem)
+ elem_write_mute_switch(simple, CTL_PLAYBACK_SWITCH, control);
+ if (simple->ctls[CTL_GLOBAL_SWITCH].elem)
+ elem_write_mute_switch(simple, CTL_GLOBAL_SWITCH, control);
+ if (simple->ctls[CTL_SINGLE].elem &&
+ simple->ctls[CTL_SINGLE].type == SND_CTL_ELEM_TYPE_BOOLEAN)
+ elem_write_mute_switch(simple, CTL_SINGLE, control);
+ if (simple->ctls[CTL_PLAYBACK_ROUTE].elem)
+ elem_write_mute_route(simple, CTL_PLAYBACK_ROUTE, control);
+ if (simple->ctls[CTL_GLOBAL_ROUTE].elem)
+ elem_write_mute_route(simple, CTL_GLOBAL_ROUTE, control);
}
- if (simple->caps & SND_MIXER_SCTCAP_CAPTURE) {
- // fprintf(stderr, "capture: present = 0x%x\n", simple->present);
- if (simple->present & MIXER_PRESENT_CAPTURE_SWITCH) {
- elem_write_capture_switch(mixer, simple, control, "Capture ", simple->cswitch_values);
- } else if (simple->present & MIXER_PRESENT_CAPTURE_ROUTE) {
- elem_write_capture_route(mixer, simple, control, "Capture ", simple->croute_values);
- } else if (simple->present & MIXER_PRESENT_CAPTURE_SOURCE) {
- snd_ctl_elem_t ctl;
- if ((err = get_mixer_read(mixer, "Capture Source", 0, &ctl)) < 0)
+ if (simple->caps & CAP_CAPTURE) {
+ if (simple->ctls[CTL_CAPTURE_SWITCH].elem) {
+ elem_write_capture_switch(simple, CTL_CAPTURE_SWITCH, control);
+ } else if (simple->ctls[CTL_CAPTURE_ROUTE].elem) {
+ elem_write_capture_route(simple, CTL_CAPTURE_ROUTE, control);
+ } else if (simple->ctls[CTL_CAPTURE_SOURCE].elem) {
+ snd_ctl_elem_value_t ctl;
+ memset(&ctl, 0, sizeof(ctl));
+ if ((err = snd_hctl_elem_read(simple->ctls[CTL_CAPTURE_SOURCE].elem, &ctl)) < 0)
return err;
- // fprintf(stderr, "put capture source : %i [0x%x]\n", simple->capture_item, control->capture);
- for (idx = 0; idx < simple->voices && idx < 32; idx++) {
+ for (idx = 0; idx < simple->channels; idx++) {
if (control->capture & (1 << idx))
- ctl.value.enumerated.item[idx] = simple->capture_item;
+ snd_ctl_elem_value_set_enumerated(&ctl, idx, simple->capture_item);
}
- if ((err = put_mixer_write(mixer, "Capture Source", 0, &ctl)) < 0)
+ if ((err = snd_hctl_elem_write(simple->ctls[CTL_CAPTURE_SOURCE].elem, &ctl)) < 0)
return err;
}
}
@@ -484,482 +429,529 @@ static void selem_free(snd_mixer_elem_t *elem)
{
selem_t *s;
assert(elem->type == SND_MIXER_ELEM_SIMPLE);
- s = elem->private;
- snd_hctl_bag_destroy(&s->elems);
+ s = elem->private_data;
free(s);
}
-static int build_elem_scontrol(snd_mixer_t *mixer, selem_t *s,
- const char *sname, int index)
+static int simple_update(snd_mixer_elem_t *melem)
{
- snd_mixer_elem_t *elem;
- strcpy(s->id.name, sname);
- s->id.index = index;
- s->read = elem_read;
- s->write = elem_write;
- elem = calloc(1, sizeof(*elem));
- if (!elem)
- return -ENOMEM;
- s->elems.private = elem;
- elem->type = SND_MIXER_ELEM_SIMPLE;
- elem->private = s;
- elem->private_free = selem_free;
- snd_mixer_add_elem(mixer, elem);
+ selem_t *simple;
+ unsigned int caps, channels;
+ long min, max;
+ selem_ctl_t *ctl;
+
+ channels = 0;
+ caps = 0;
+ min = max = 0;
+ assert(melem->type == SND_MIXER_ELEM_SIMPLE);
+ simple = melem->private_data;
+ ctl = &simple->ctls[CTL_SINGLE];
+ if (ctl->elem) {
+ if (channels < ctl->values)
+ channels = ctl->values;
+ caps |= ctl->type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ? CAP_MUTE : CAP_VOLUME;
+ if (ctl->type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
+ if (min > ctl->min)
+ min = ctl->min;
+ if (max < ctl->max)
+ max = ctl->max;
+ }
+ }
+ ctl = &simple->ctls[CTL_GLOBAL_SWITCH];
+ if (ctl->elem) {
+ if (channels < ctl->values)
+ channels = ctl->values;
+ caps |= CAP_MUTE;
+ }
+ ctl = &simple->ctls[CTL_GLOBAL_ROUTE];
+ if (ctl->elem) {
+ if (channels < 2)
+ channels = 2;
+ caps |= CAP_MUTE;
+ }
+ ctl = &simple->ctls[CTL_GLOBAL_VOLUME];
+ if (ctl->elem) {
+ if (channels < ctl->values)
+ channels = ctl->values;
+ if (min > ctl->min)
+ min = ctl->min;
+ if (max < ctl->max)
+ max = ctl->max;
+ caps |= CAP_VOLUME;
+ }
+ ctl = &simple->ctls[CTL_PLAYBACK_SWITCH];
+ if (ctl->elem) {
+ if (channels < ctl->values)
+ channels = ctl->values;
+ caps |= CAP_MUTE;
+ }
+ ctl = &simple->ctls[CTL_PLAYBACK_ROUTE];
+ if (ctl->elem) {
+ if (channels < 2)
+ channels = 2;
+ caps |= CAP_MUTE;
+ }
+ ctl = &simple->ctls[CTL_CAPTURE_SWITCH];
+ if (ctl->elem) {
+ if (channels < ctl->values)
+ channels = ctl->values;
+ caps |= CAP_CAPTURE;
+ }
+ ctl = &simple->ctls[CTL_CAPTURE_ROUTE];
+ if (ctl->elem) {
+ if (channels < 2)
+ channels = 2;
+ caps |= CAP_CAPTURE;
+ }
+ ctl = &simple->ctls[CTL_PLAYBACK_VOLUME];
+ if (ctl->elem) {
+ if (channels < ctl->values)
+ channels = ctl->values;
+ if (min > ctl->min)
+ min = ctl->min;
+ if (max < ctl->max)
+ max = ctl->max;
+ caps |= CAP_VOLUME;
+ }
+ ctl = &simple->ctls[CTL_CAPTURE_VOLUME];
+ if (ctl->elem) {
+ if (channels < ctl->values)
+ channels = ctl->values;
+ if (min > ctl->min)
+ min = ctl->min;
+ if (max < ctl->max)
+ max = ctl->max;
+ caps |= CAP_VOLUME;
+ }
+ ctl = &simple->ctls[CTL_CAPTURE_SOURCE];
+ if (ctl->elem) {
+ if (channels < ctl->values)
+ channels = ctl->values;
+ caps |= CAP_CAPTURE;
+ }
+ if (channels > 32)
+ channels = 32;
+ if (channels > 1) {
+ if ((simple->ctls[CTL_SINGLE].elem &&
+ simple->ctls[CTL_SINGLE].type == SND_CTL_ELEM_TYPE_BOOLEAN) ||
+ simple->ctls[CTL_GLOBAL_SWITCH].elem ||
+ simple->ctls[CTL_GLOBAL_ROUTE].elem ||
+ simple->ctls[CTL_PLAYBACK_SWITCH].elem ||
+ simple->ctls[CTL_PLAYBACK_ROUTE].elem)
+ caps |= CAP_JOIN_MUTE;
+ if (simple->ctls[CTL_CAPTURE_SWITCH].elem ||
+ simple->ctls[CTL_CAPTURE_ROUTE].elem ||
+ simple->ctls[CTL_CAPTURE_SOURCE].elem)
+ caps |= CAP_JOIN_CAPTURE;
+ if ((simple->ctls[CTL_SINGLE].elem &&
+ simple->ctls[CTL_SINGLE].type == SND_CTL_ELEM_TYPE_BOOLEAN) ||
+ simple->ctls[CTL_GLOBAL_VOLUME].elem ||
+ simple->ctls[CTL_PLAYBACK_VOLUME].elem ||
+ simple->ctls[CTL_CAPTURE_VOLUME].elem)
+ caps |= CAP_JOIN_VOLUME;
+ if (simple->ctls[CTL_SINGLE].elem &&
+ simple->ctls[CTL_SINGLE].type == SND_CTL_ELEM_TYPE_BOOLEAN &&
+ simple->ctls[CTL_SINGLE].values > 1)
+ caps &= ~CAP_JOIN_MUTE;
+ if (simple->ctls[CTL_GLOBAL_SWITCH].elem &&
+ simple->ctls[CTL_GLOBAL_SWITCH].values > 1)
+ caps &= ~CAP_JOIN_MUTE;
+ if (simple->ctls[CTL_PLAYBACK_SWITCH].elem &&
+ simple->ctls[CTL_PLAYBACK_SWITCH].values > 1)
+ caps &= ~CAP_JOIN_MUTE;
+ if (simple->ctls[CTL_GLOBAL_ROUTE].elem ||
+ simple->ctls[CTL_PLAYBACK_ROUTE].elem)
+ caps &= ~CAP_JOIN_MUTE;
+ if (simple->ctls[CTL_CAPTURE_SWITCH].elem &&
+ simple->ctls[CTL_CAPTURE_SWITCH].values > 1)
+ caps &= ~CAP_JOIN_CAPTURE;
+ if (simple->ctls[CTL_CAPTURE_ROUTE].elem)
+ caps &= ~CAP_JOIN_CAPTURE;
+ if (simple->ctls[CTL_SINGLE].elem &&
+ simple->ctls[CTL_SINGLE].type == SND_CTL_ELEM_TYPE_INTEGER &&
+ simple->ctls[CTL_SINGLE].values > 1)
+ caps &= ~CAP_JOIN_VOLUME;
+ if (simple->ctls[CTL_GLOBAL_VOLUME].elem &&
+ simple->ctls[CTL_GLOBAL_VOLUME].values > 1)
+ caps &= ~CAP_JOIN_VOLUME;
+ if (simple->ctls[CTL_PLAYBACK_VOLUME].elem &&
+ simple->ctls[CTL_PLAYBACK_VOLUME].values > 1)
+ caps &= ~CAP_JOIN_VOLUME;
+ if (simple->ctls[CTL_CAPTURE_VOLUME].elem &&
+ simple->ctls[CTL_CAPTURE_VOLUME].values > 1)
+ caps &= ~CAP_JOIN_VOLUME;
+ }
+ simple->caps = caps;
+ simple->channels = channels;
+ simple->min = min;
+ simple->max = max;
+ return 0;
+}
+
+static struct suf {
+ const char *suffix;
+ selem_ctl_type_t type;
+} suffixes[] = {
+ { " Playback Switch", CTL_PLAYBACK_SWITCH},
+ {" Playback Route", CTL_PLAYBACK_ROUTE},
+ {" Playback Volume", CTL_PLAYBACK_VOLUME},
+ {" Capture Switch", CTL_CAPTURE_SWITCH},
+ {" Capture Route", CTL_CAPTURE_ROUTE},
+ {" Capture Volume", CTL_CAPTURE_VOLUME},
+ {" Switch", CTL_GLOBAL_SWITCH},
+ {" Route", CTL_GLOBAL_ROUTE},
+ {" Volume", CTL_GLOBAL_VOLUME},
+ {NULL, 0}
+};
+
+/* Return base length or 0 on failure */
+static int base_len(const char *name, selem_ctl_type_t *type)
+{
+ struct suf *p;
+ size_t nlen = strlen(name);
+ p = suffixes;
+ while (p->suffix) {
+ size_t slen = strlen(p->suffix);
+ size_t l;
+ if (nlen > slen) {
+ l = nlen - slen;
+ if (strncmp(name + l, p->suffix, slen) == 0) {
+ *type = p->type;
+ return l;
+ }
+ }
+ p++;
+ }
return 0;
}
-static int build_elem(snd_mixer_t *mixer, const char *sname)
+int simple_add1(snd_mixer_class_t *class, const char *name,
+ snd_hctl_elem_t *helem, selem_ctl_type_t type,
+ int value)
{
- char str[128];
- unsigned int present, caps, capture_item, voices;
- int index = -1, err;
- snd_ctl_elem_info_t global_info;
- snd_ctl_elem_info_t gswitch_info, pswitch_info, cswitch_info;
- snd_ctl_elem_info_t gvolume_info, pvolume_info, cvolume_info;
- snd_ctl_elem_info_t groute_info, proute_info, croute_info;
- snd_ctl_elem_info_t csource_info;
- long min, max;
+ snd_mixer_elem_t *melem;
+ snd_mixer_selem_id_t id;
+ int new = 0;
+ int err;
+ snd_ctl_elem_info_t info;
selem_t *simple;
- snd_hctl_elem_t *helem;
- const char *sname1;
-
- memset(&gswitch_info, 0, sizeof(gswitch_info));
- memset(&pswitch_info, 0, sizeof(pswitch_info));
- memset(&cswitch_info, 0, sizeof(cswitch_info));
- memset(&gvolume_info, 0, sizeof(gvolume_info));
- memset(&pvolume_info, 0, sizeof(pvolume_info));
- memset(&cvolume_info, 0, sizeof(cvolume_info));
- memset(&groute_info, 0, sizeof(groute_info));
- memset(&proute_info, 0, sizeof(proute_info));
- memset(&croute_info, 0, sizeof(croute_info));
- while (1) {
+ const char *name1;
+ memset(&info, 0, sizeof(info));
+ err = snd_hctl_elem_info(helem, &info);
+ assert(err >= 0);
+ switch (type) {
+ case CTL_SINGLE:
+ if (info.type != SND_CTL_ELEM_TYPE_BOOLEAN &&
+ info.type != SND_CTL_ELEM_TYPE_INTEGER)
+ return 0;
+ break;
+ case CTL_GLOBAL_ROUTE:
+ case CTL_PLAYBACK_ROUTE:
+ case CTL_CAPTURE_ROUTE:
+ if (info.count != 4 ||
+ info.type != SND_CTL_ELEM_TYPE_BOOLEAN)
+ return 0;
+ break;
+ case CTL_GLOBAL_SWITCH:
+ case CTL_PLAYBACK_SWITCH:
+ case CTL_CAPTURE_SWITCH:
+ if (info.type != SND_CTL_ELEM_TYPE_BOOLEAN)
+ return 0;
+ break;
+ case CTL_GLOBAL_VOLUME:
+ case CTL_PLAYBACK_VOLUME:
+ case CTL_CAPTURE_VOLUME:
+ if (info.type != SND_CTL_ELEM_TYPE_INTEGER)
+ return 0;
+ break;
+ case CTL_CAPTURE_SOURCE:
+ if (info.type != SND_CTL_ELEM_TYPE_ENUMERATED)
+ return 0;
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ name1 = get_short_name(name);
+ strncpy(id.name, name1, sizeof(id.name));
+ id.index = snd_hctl_elem_get_index(helem);
+ melem = snd_mixer_find_selem(class->mixer, &id);
+ if (!melem) {
simple = calloc(1, sizeof(*simple));
- index++;
- voices = 0;
- present = caps = capture_item = 0;
- min = max = 0;
- if ((helem = test_mixer_id(mixer, sname, index)) != NULL) {
- if ((err = get_mixer_info(mixer, sname, index, &global_info)) < 0)
- return err;
- if (global_info.type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
- global_info.type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
- if (voices < global_info.count)
- voices = global_info.count;
- caps |= global_info.type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ? SND_MIXER_SCTCAP_MUTE : SND_MIXER_SCTCAP_VOLUME;
- present |= global_info.type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ? MIXER_PRESENT_SINGLE_SWITCH : MIXER_PRESENT_SINGLE_VOLUME;
- if (global_info.type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
- if (min > global_info.value.integer.min)
- min = global_info.value.integer.min;
- if (max < global_info.value.integer.max)
- max = global_info.value.integer.max;
- }
- hctl_elem_add(simple, helem);
- }
- }
- sprintf(str, "%s Switch", sname);
- if ((helem = test_mixer_id(mixer, str, index)) != NULL) {
- if ((err = get_mixer_info(mixer, str, index, &gswitch_info)) < 0)
- return err;
- if (gswitch_info.type == SNDRV_CTL_ELEM_TYPE_BOOLEAN) {
- if (voices < gswitch_info.count)
- voices = gswitch_info.count;
- caps |= SND_MIXER_SCTCAP_MUTE;
- present |= MIXER_PRESENT_GLOBAL_SWITCH;
- hctl_elem_add(simple, helem);
- }
- }
- sprintf(str, "%s Route", sname);
- if ((helem = test_mixer_id(mixer, str, index)) != NULL) {
- if ((err = get_mixer_info(mixer, str, index, &groute_info)) < 0)
- return err;
- if (groute_info.type == SNDRV_CTL_ELEM_TYPE_BOOLEAN && groute_info.count == 4) {
- if (voices < 2)
- voices = 2;
- caps |= SND_MIXER_SCTCAP_MUTE;
- present |= MIXER_PRESENT_GLOBAL_ROUTE;
- hctl_elem_add(simple, helem);
- }
- }
- sprintf(str, "%s Volume", sname);
- if ((helem = test_mixer_id(mixer, str, index)) != NULL) {
- if ((err = get_mixer_info(mixer, str, index, &gvolume_info)) < 0)
- return err;
- if (gvolume_info.type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
- 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)
- max = gvolume_info.value.integer.max;
- caps |= SND_MIXER_SCTCAP_VOLUME;
- present |= MIXER_PRESENT_GLOBAL_VOLUME;
- hctl_elem_add(simple, helem);
- }
- }
- sprintf(str, "%s Playback Switch", sname);
- if ((helem = test_mixer_id(mixer, str, index)) != NULL) {
- if ((err = get_mixer_info(mixer, str, index, &pswitch_info)) < 0)
- return err;
- if (pswitch_info.type == SNDRV_CTL_ELEM_TYPE_BOOLEAN) {
- if (voices < pswitch_info.count)
- voices = pswitch_info.count;
- caps |= SND_MIXER_SCTCAP_MUTE;
- present |= MIXER_PRESENT_PLAYBACK_SWITCH;
- hctl_elem_add(simple, helem);
- }
- }
- sprintf(str, "%s Playback Route", sname);
- if ((helem = test_mixer_id(mixer, str, index)) != NULL) {
- if ((err = get_mixer_info(mixer, str, index, &proute_info)) < 0)
- return err;
- if (proute_info.type == SNDRV_CTL_ELEM_TYPE_BOOLEAN && proute_info.count == 4) {
- if (voices < 2)
- voices = 2;
- caps |= SND_MIXER_SCTCAP_MUTE;
- present |= MIXER_PRESENT_PLAYBACK_ROUTE;
- hctl_elem_add(simple, helem);
- }
- }
- sprintf(str, "%s Capture Switch", sname);
- if ((helem = test_mixer_id(mixer, str, index)) != NULL) {
- if ((err = get_mixer_info(mixer, str, index, &cswitch_info)) < 0)
- return err;
- if (cswitch_info.type == SNDRV_CTL_ELEM_TYPE_BOOLEAN) {
- if (voices < cswitch_info.count)
- voices = cswitch_info.count;
- caps |= SND_MIXER_SCTCAP_CAPTURE;
- present |= MIXER_PRESENT_CAPTURE_SWITCH;
- hctl_elem_add(simple, helem);
- }
- }
- sprintf(str, "%s Capture Route", sname);
- if ((helem = test_mixer_id(mixer, str, index)) != NULL) {
- if ((err = get_mixer_info(mixer, str, index, &croute_info)) < 0)
- return err;
- if (croute_info.type == SNDRV_CTL_ELEM_TYPE_BOOLEAN && croute_info.count == 4) {
- if (voices < 2)
- voices = 2;
- caps |= SND_MIXER_SCTCAP_CAPTURE;
- present |= MIXER_PRESENT_CAPTURE_ROUTE;
- hctl_elem_add(simple, helem);
- }
- }
- sprintf(str, "%s Playback Volume", sname);
- if ((helem = test_mixer_id(mixer, str, index)) != NULL) {
- if ((err = get_mixer_info(mixer, str, index, &pvolume_info)) < 0)
- return err;
- if (pvolume_info.type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
- 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)
- max = pvolume_info.value.integer.max;
- caps |= SND_MIXER_SCTCAP_VOLUME;
- present |= MIXER_PRESENT_PLAYBACK_VOLUME;
- hctl_elem_add(simple, helem);
- }
- }
- sprintf(str, "%s Capture Volume", sname);
- if ((helem = test_mixer_id(mixer, str, index)) != NULL) {
- if ((err = get_mixer_info(mixer, str, index, &cvolume_info)) < 0)
- return err;
- if (cvolume_info.type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
- 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)
- max = pvolume_info.value.integer.max;
- caps |= SND_MIXER_SCTCAP_VOLUME;
- present |= MIXER_PRESENT_CAPTURE_VOLUME;
- hctl_elem_add(simple, helem);
- }
- }
- if (index == 0 && (helem = test_mixer_id(mixer, "Capture Source", 0)) != NULL) {
- if ((err = get_mixer_info(mixer, "Capture Source", 0, &csource_info)) < 0)
- return err;
- strcpy(str, sname);
- if (!strcmp(str, "Master")) /* special case */
- strcpy(str, "Mix");
- else if (!strcmp(str, "Master Mono")) /* special case */
- strcpy(str, "Mono Mix");
- if (csource_info.type == SNDRV_CTL_ELEM_TYPE_ENUMERATED) {
- capture_item = 0;
- if (!strcmp(csource_info.value.enumerated.name, str)) {
- if (voices < csource_info.count)
- voices = csource_info.count;
- caps |= SND_MIXER_SCTCAP_CAPTURE;
- present |= MIXER_PRESENT_CAPTURE_SOURCE;
- hctl_elem_add(simple, helem);
- } else for (capture_item = 1; capture_item < csource_info.value.enumerated.items; capture_item++) {
- csource_info.value.enumerated.item = capture_item;
- if ((err = snd_hctl_elem_info(helem, &csource_info)) < 0)
- return err;
- if (!strcmp(csource_info.value.enumerated.name, str)) {
- if (voices < csource_info.count)
- voices = csource_info.count;
- caps |= SND_MIXER_SCTCAP_CAPTURE;
- present |= MIXER_PRESENT_CAPTURE_SOURCE;
- hctl_elem_add(simple, helem);
- break;
- }
- }
- }
- }
- if (voices > 1) {
- if (present & (MIXER_PRESENT_SINGLE_SWITCH|MIXER_PRESENT_GLOBAL_SWITCH|MIXER_PRESENT_GLOBAL_ROUTE|MIXER_PRESENT_PLAYBACK_SWITCH|MIXER_PRESENT_GLOBAL_SWITCH))
- caps |= SND_MIXER_SCTCAP_JOIN_MUTE;
- if (present & (MIXER_PRESENT_CAPTURE_SWITCH|MIXER_PRESENT_CAPTURE_ROUTE|MIXER_PRESENT_CAPTURE_SOURCE))
- caps |= SND_MIXER_SCTCAP_JOIN_CAPTURE;
- if (present & (MIXER_PRESENT_SINGLE_VOLUME|MIXER_PRESENT_GLOBAL_VOLUME|MIXER_PRESENT_PLAYBACK_VOLUME|MIXER_PRESENT_CAPTURE_VOLUME))
- caps |= SND_MIXER_SCTCAP_JOIN_VOLUME;
- if (present & MIXER_PRESENT_SINGLE_SWITCH) {
- if (global_info.count > 1)
- caps &= ~SND_MIXER_SCTCAP_JOIN_MUTE;
- }
- if (present & MIXER_PRESENT_GLOBAL_SWITCH) {
- if (gswitch_info.count > 1)
- caps &= ~SND_MIXER_SCTCAP_JOIN_MUTE;
- }
- if (present & MIXER_PRESENT_PLAYBACK_SWITCH) {
- if (pswitch_info.count > 1)
- caps &= ~SND_MIXER_SCTCAP_JOIN_MUTE;
- }
- if (present & (MIXER_PRESENT_GLOBAL_ROUTE | MIXER_PRESENT_PLAYBACK_ROUTE))
- caps &= ~SND_MIXER_SCTCAP_JOIN_MUTE;
- if (present & MIXER_PRESENT_CAPTURE_SWITCH) {
- if (cswitch_info.count > 1)
- caps &= ~SND_MIXER_SCTCAP_JOIN_CAPTURE;
- }
- if (present & MIXER_PRESENT_CAPTURE_ROUTE)
- caps &= ~SND_MIXER_SCTCAP_JOIN_CAPTURE;
- if (present & MIXER_PRESENT_SINGLE_VOLUME) {
- if (global_info.count > 1)
- caps &= ~SND_MIXER_SCTCAP_JOIN_VOLUME;
- }
- if (present & MIXER_PRESENT_GLOBAL_VOLUME) {
- if (gvolume_info.count > 1)
- caps &= ~SND_MIXER_SCTCAP_JOIN_VOLUME;
- }
- if (present & MIXER_PRESENT_PLAYBACK_VOLUME) {
- if (pvolume_info.count > 1)
- caps &= ~SND_MIXER_SCTCAP_JOIN_VOLUME;
- }
- if (present & MIXER_PRESENT_CAPTURE_VOLUME) {
- if (cvolume_info.count > 1)
- caps &= ~SND_MIXER_SCTCAP_JOIN_VOLUME;
- }
- }
- if (present == 0) {
- free(simple);
- break;
- }
- sname1 = get_short_name(sname);
- simple->present = present;
- 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.count;
- simple->capture_item = capture_item;
- simple->caps = caps;
- simple->voices = voices;
- simple->min = min;
- simple->max = max;
- if (build_elem_scontrol(mixer, simple, sname1, index) < 0) {
- snd_hctl_bag_destroy(&simple->elems);
+ if (!simple)
+ return -ENOMEM;
+ melem = calloc(1, sizeof(*melem));
+ if (!melem) {
free(simple);
return -ENOMEM;
}
- // fprintf(stderr, "sname = '%s', index = %i, present = 0x%x, voices = %i\n", sname, index, present, voices);
- };
- return 0;
+ simple->id = id;
+ simple->read = selem_read;
+ simple->write = selem_write;
+ simple->info = selem_info;
+ melem->type = SND_MIXER_ELEM_SIMPLE;
+ melem->private_data = simple;
+ melem->private_free = selem_free;
+ INIT_LIST_HEAD(&melem->helems);
+ new = 1;
+ } else {
+ simple = melem->private_data;
+ }
+ assert(!simple->ctls[type].elem);
+ simple->ctls[type].elem = helem;
+ simple->ctls[type].type = info.type;
+ simple->ctls[type].values = info.count;
+ simple->ctls[type].min = info.value.integer.min;
+ simple->ctls[type].max = info.value.integer.max;
+ switch (type) {
+ case CTL_CAPTURE_SOURCE:
+ simple->capture_item = value;
+ break;
+ default:
+ break;
+ }
+ err = snd_mixer_elem_attach(melem, helem);
+ if (err < 0)
+ return err;
+ err = simple_update(melem);
+ assert(err >= 0);
+ if (new)
+ return snd_mixer_elem_add(melem, class);
+ return snd_mixer_elem_change(melem);
}
-int mixer_simple_ctl_callback(snd_hctl_t *hctl,
- snd_ctl_event_type_t event,
- snd_hctl_elem_t *elem ATTRIBUTE_UNUSED)
+int simple_event_add(snd_mixer_class_t *class, snd_hctl_elem_t *helem)
{
- snd_mixer_t *mixer = snd_hctl_get_callback_private(hctl);
+ const char *name = snd_hctl_elem_get_name(helem);
+ size_t len;
+ selem_ctl_type_t type;
+ if (snd_hctl_elem_get_interface(helem) != SND_CTL_ELEM_IFACE_MIXER)
+ return 0;
+ if (strcmp(name, "Capture Source") == 0) {
+ snd_ctl_elem_info_t *info;
+ unsigned int k, items;
+ int err;
+ snd_ctl_elem_info_alloca(&info);
+ err = snd_hctl_elem_info(helem, info);
+ assert(err >= 0);
+ if (snd_ctl_elem_info_get_type(info) != SND_CTL_ELEM_TYPE_ENUMERATED)
+ return 0;
+ items = snd_ctl_elem_info_get_items(info);
+ for (k = 0; k < items; ++k) {
+ const char *n;
+ snd_ctl_elem_info_set_item(info, k);
+ err = snd_hctl_elem_info(helem, info);
+ assert(err >= 0);
+ n = snd_ctl_elem_info_get_item_name(info);
+#if 0
+ /* FIXME: es18xx has both Mix and Master */
+ if (strcmp(n, "Mix") == 0)
+ n = "Master";
+ else if (strcmp(n, "Mono Mix") == 0)
+ n = "Master Mono";
+#endif
+ err = simple_add1(class, n, helem, CTL_CAPTURE_SOURCE, k);
+ if (err < 0)
+ return err;
+ }
+ return 0;
+ }
+ len = base_len(name, &type);
+ if (len == 0) {
+ return simple_add1(class, name, helem, CTL_SINGLE, 0);
+ } else {
+ char ename[128];
+ if (len >= sizeof(ename))
+ len = sizeof(ename) - 1;
+ memcpy(ename, name, len);
+ ename[len] = 0;
+ return simple_add1(class, ename, helem, type, 0);
+ }
+}
+
+int simple_event_remove(snd_hctl_elem_t *helem,
+ snd_mixer_elem_t *melem)
+{
+ selem_t *simple = melem->private_data;
int err;
+ int k;
+ for (k = 0; k <= CTL_LAST; k++) {
+ if (simple->ctls[k].elem == helem)
+ break;
+ }
+ assert(k <= CTL_LAST);
+ simple->ctls[k].elem = NULL;
+ err = snd_mixer_elem_detach(melem, helem);
+ assert(err >= 0);
+ if (snd_mixer_elem_empty(melem))
+ return snd_mixer_elem_remove(melem);
+ err = simple_update(melem);
+ return snd_mixer_elem_change(melem);
+}
+
+int simple_event_info(snd_mixer_elem_t *melem)
+{
+ int err = simple_update(melem);
+ assert(err >= 0);
+ return snd_mixer_elem_change(melem);
+}
+
+int simple_event(snd_mixer_class_t *class, snd_ctl_event_type_t event,
+ snd_hctl_elem_t *helem, snd_mixer_elem_t *melem)
+{
switch (event) {
- case SND_CTL_EVENT_REBUILD:
- snd_mixer_free(mixer);
- err = snd_mixer_simple_build(mixer);
- if (err < 0)
- return err;
- return mixer->callback(mixer, event, NULL);
case SND_CTL_EVENT_ADD:
- /* TODO */
- return 0;
+ return simple_event_add(class, helem);
+ case SND_CTL_EVENT_INFO:
+ return simple_event_info(melem);
+ case SND_CTL_EVENT_VALUE:
+ return snd_mixer_elem_throw_event(melem, event);
+ case SND_CTL_EVENT_REMOVE:
+ return simple_event_remove(helem, melem);
default:
assert(0);
+ break;
}
+ return 0;
}
-int snd_mixer_simple_build(snd_mixer_t *mixer)
-{
- static char *elems[] = {
- "Master",
- "Master Mono",
- "Master Digital",
- "Tone Control - Bass",
- "Tone Control - Treble",
- "Synth Tone Control - Bass",
- "Synth Tone Control - Treble",
- "PCM",
- "Surround",
- "Synth",
- "FM",
- "Wave",
- "Music",
- "DSP",
- "Line",
- "CD",
- "Mic",
- "Video",
- "Phone",
- "PC Speaker",
- "Aux",
- "Mono",
- "Mono Output",
- "Playback",
- "Capture",
- "Capture Boost",
- NULL
- };
- snd_hctl_t *hctl = mixer->hctl;
- char **elem = elems;
+int snd_mixer_selem_register(snd_mixer_t *mixer, snd_mixer_class_t **classp)
+{
+ snd_mixer_class_t *class = calloc(1, sizeof(*class));
int err;
-
- while (*elem) {
- if ((err = build_elem(mixer, *elem)) < 0)
- return err;
- elem++;
+ if (!class)
+ return -ENOMEM;
+ class->event = simple_event;
+ err = snd_mixer_class_register(class, mixer);
+ if (err < 0) {
+ free(class);
+ return err;
}
- snd_hctl_set_callback(hctl, mixer_simple_ctl_callback);
- snd_hctl_set_callback_private(hctl, mixer);
+ if (classp)
+ *classp = class;
return 0;
}
-
+
snd_mixer_elem_t *snd_mixer_find_selem(snd_mixer_t *mixer,
- const snd_mixer_selem_id_t *id)
+ const snd_mixer_selem_id_t *id)
{
- struct list_head *list;
- list_for_each(list, &mixer->elems) {
+ struct list_head *list, *next;
+ list_for_each(list, next, &mixer->elems) {
snd_mixer_elem_t *e;
selem_t *s;
e = list_entry(list, snd_mixer_elem_t, list);
if (e->type != SND_MIXER_ELEM_SIMPLE)
continue;
- s = e->private;
+ s = e->private_data;
if (!strcmp(s->id.name, id->name) && s->id.index == id->index)
return e;
}
return NULL;
}
-void snd_mixer_selem_get_id(snd_mixer_elem_t *element,
+void snd_mixer_selem_get_id(snd_mixer_elem_t *elem,
snd_mixer_selem_id_t *id)
{
selem_t *s;
- assert(element && id);
- assert(element->type == SND_MIXER_ELEM_SIMPLE);
- s = element->private;
+ assert(elem && id);
+ assert(elem->type == SND_MIXER_ELEM_SIMPLE);
+ s = elem->private_data;
*id = s->id;
}
-int snd_mixer_selem_read(snd_mixer_elem_t *element,
- snd_mixer_selem_t *value)
+int snd_mixer_selem_info(snd_mixer_elem_t *elem,
+ snd_mixer_selem_info_t *info)
+{
+ selem_t *s;
+ assert(elem && info);
+ assert(elem->type == SND_MIXER_ELEM_SIMPLE);
+ s = elem->private_data;
+ assert(s->info);
+ return s->info(elem, info);
+}
+
+int snd_mixer_selem_read(snd_mixer_elem_t *elem,
+ snd_mixer_selem_value_t *value)
{
selem_t *s;
- assert(element && value);
- assert(element->type == SND_MIXER_ELEM_SIMPLE);
- s = element->private;
- if (s->read == NULL)
- return -EIO;
- return s->read(element, value);
+ assert(elem && value);
+ assert(elem->type == SND_MIXER_ELEM_SIMPLE);
+ s = elem->private_data;
+ assert(s->read);
+ return s->read(elem, value);
}
-int snd_mixer_selem_write(snd_mixer_elem_t *element,
- const snd_mixer_selem_t *value)
+int snd_mixer_selem_write(snd_mixer_elem_t *elem,
+ const snd_mixer_selem_value_t *value)
{
selem_t *s;
- assert(element && value);
- assert(element->type == SND_MIXER_ELEM_SIMPLE);
- s = element->private;
- if (s->write == NULL)
- return -EIO;
- return s->write(element, value);
+ assert(elem && value);
+ assert(elem->type == SND_MIXER_ELEM_SIMPLE);
+ s = elem->private_data;
+ assert(s->write);
+ return s->write(elem, value);
}
-int snd_mixer_selem_is_mono(const snd_mixer_selem_t *obj)
+int snd_mixer_selem_info_is_mono(const snd_mixer_selem_info_t *obj)
{
assert(obj);
- return obj->channels == 1 << SND_MIXER_CHN_MONO;
+ return obj->channels == 1 << SND_MIXER_SCHN_MONO;
}
-long snd_mixer_selem_get_volume(const snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel)
+int snd_mixer_selem_info_has_channel(const snd_mixer_selem_info_t *obj, snd_mixer_selem_channel_id_t channel)
{
assert(obj);
- return obj->volume[channel];
+ assert(channel <= SND_MIXER_SCHN_LAST);
+ return !!(obj->channels & (1 << channel));
}
-void snd_mixer_selem_set_volume(snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel, long value)
+long snd_mixer_selem_value_get_volume(const snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel)
{
assert(obj);
- obj->volume[channel] = value;
+ return obj->volume[channel];
}
-int snd_mixer_selem_has_channel(const snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel)
+void snd_mixer_selem_value_set_volume(snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel, long value)
{
assert(obj);
- assert(channel <= SND_MIXER_CHN_LAST);
- return !!(obj->channels & (1 << channel));
+ obj->volume[channel] = value;
}
-int snd_mixer_selem_get_mute(const snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel)
+int snd_mixer_selem_value_get_mute(const snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel)
{
assert(obj);
- assert(channel <= SND_MIXER_CHN_LAST);
+ assert(channel <= SND_MIXER_SCHN_LAST);
return !!(obj->mute & (1 << channel));
}
-void snd_mixer_selem_set_mute(snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel, int mute)
+void snd_mixer_selem_value_set_mute(snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel, int mute)
{
assert(obj);
- assert(channel <= SND_MIXER_CHN_LAST);
+ assert(channel <= SND_MIXER_SCHN_LAST);
if (mute)
obj->mute |= (1 << channel);
else
obj->mute &= ~(1 << channel);
}
-int snd_mixer_selem_get_capture(const snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel)
+int snd_mixer_selem_value_get_capture(const snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel)
{
assert(obj);
- assert(channel <= SND_MIXER_CHN_LAST);
+ assert(channel <= SND_MIXER_SCHN_LAST);
return !!(obj->capture & (1 << channel));
}
-void snd_mixer_selem_set_capture(snd_mixer_selem_t *obj, snd_mixer_channel_id_t channel, int capture)
+void snd_mixer_selem_value_set_capture(snd_mixer_selem_value_t *obj, snd_mixer_selem_channel_id_t channel, int capture)
{
assert(obj);
- assert(channel <= SND_MIXER_CHN_LAST);
+ assert(channel <= SND_MIXER_SCHN_LAST);
if (capture)
obj->capture |= (1 << channel);
else
obj->capture &= ~(1 << channel);
}
-void snd_mixer_selem_set_mute_all(snd_mixer_selem_t *obj, int mute)
+void snd_mixer_selem_value_set_mute_all(snd_mixer_selem_value_t *obj, int mute)
{
assert(obj);
if (mute)
@@ -968,7 +960,7 @@ void snd_mixer_selem_set_mute_all(snd_mixer_selem_t *obj, int mute)
obj->mute = 0;
}
-void snd_mixer_selem_set_capture_all(snd_mixer_selem_t *obj, int capture)
+void snd_mixer_selem_value_set_capture_all(snd_mixer_selem_value_t *obj, int capture)
{
assert(obj);
if (capture)
@@ -977,10 +969,29 @@ void snd_mixer_selem_set_capture_all(snd_mixer_selem_t *obj, int capture)
obj->capture = 0;
}
-void snd_mixer_selem_set_volume_all(snd_mixer_selem_t *obj, long value)
+void snd_mixer_selem_value_set_volume_all(snd_mixer_selem_value_t *obj, long value)
{
unsigned int c;
assert(obj);
for (c = 0; c < sizeof(obj->volume) / sizeof(obj->volume[0]); c++)
obj->volume[c] = value;
}
+
+const char *snd_mixer_selem_channel_name(snd_mixer_selem_channel_id_t channel)
+{
+ static char *array[snd_enum_to_int(SND_MIXER_SCHN_LAST) + 1] = {
+ [SND_MIXER_SCHN_FRONT_LEFT] = "Front Left",
+ [SND_MIXER_SCHN_FRONT_RIGHT] = "Front Right",
+ [SND_MIXER_SCHN_FRONT_CENTER] = "Front Center",
+ [SND_MIXER_SCHN_REAR_LEFT] = "Rear Left",
+ [SND_MIXER_SCHN_REAR_RIGHT] = "Rear Right",
+ [SND_MIXER_SCHN_WOOFER] = "Woofer"
+ };
+ char *p;
+ assert(channel <= SND_MIXER_SCHN_LAST);
+ p = array[snd_enum_to_int(channel)];
+ if (!p)
+ return "?";
+ return p;
+}
+
diff --git a/src/output.c b/src/output.c
index 477c79ff..286e8833 100644
--- a/src/output.c
+++ b/src/output.c
@@ -36,7 +36,7 @@ typedef struct _snd_output_ops {
struct _snd_output {
snd_output_type_t type;
snd_output_ops_t *ops;
- void *private;
+ void *private_data;
};
int snd_output_close(snd_output_t *output)
@@ -78,7 +78,7 @@ typedef struct _snd_output_stdio {
int snd_output_stdio_close(snd_output_t *output ATTRIBUTE_UNUSED)
{
- snd_output_stdio_t *stdio = output->private;
+ snd_output_stdio_t *stdio = output->private_data;
if (close)
fclose(stdio->fp);
free(stdio);
@@ -87,25 +87,25 @@ int snd_output_stdio_close(snd_output_t *output ATTRIBUTE_UNUSED)
int snd_output_stdio_printf(snd_output_t *output, const char *format, va_list args)
{
- snd_output_stdio_t *stdio = output->private;
+ snd_output_stdio_t *stdio = output->private_data;
return vfprintf(stdio->fp, format, args);
}
int snd_output_stdio_puts(snd_output_t *output, const char *str)
{
- snd_output_stdio_t *stdio = output->private;
+ snd_output_stdio_t *stdio = output->private_data;
return fputs(str, stdio->fp);
}
int snd_output_stdio_putc(snd_output_t *output, int c)
{
- snd_output_stdio_t *stdio = output->private;
+ snd_output_stdio_t *stdio = output->private_data;
return putc(c, stdio->fp);
}
int snd_output_stdio_flush(snd_output_t *output)
{
- snd_output_stdio_t *stdio = output->private;
+ snd_output_stdio_t *stdio = output->private_data;
return fflush(stdio->fp);
}
@@ -134,7 +134,7 @@ int snd_output_stdio_attach(snd_output_t **outputp, FILE *fp, int close)
stdio->close = close;
output->type = SND_OUTPUT_STDIO;
output->ops = &snd_output_stdio_ops;
- output->private = stdio;
+ output->private_data = stdio;
*outputp = output;
return 0;
}
@@ -161,7 +161,7 @@ typedef struct _snd_output_buffer {
int snd_output_buffer_close(snd_output_t *output ATTRIBUTE_UNUSED)
{
- snd_output_buffer_t *buffer = output->private;
+ snd_output_buffer_t *buffer = output->private_data;
free(buffer->buf);
free(buffer);
return 0;
@@ -169,7 +169,7 @@ int snd_output_buffer_close(snd_output_t *output ATTRIBUTE_UNUSED)
int snd_output_buffer_need(snd_output_t *output, size_t size)
{
- snd_output_buffer_t *buffer = output->private;
+ snd_output_buffer_t *buffer = output->private_data;
size_t free = buffer->alloc - buffer->size;
size_t alloc;
if (free >= size)
@@ -187,7 +187,7 @@ int snd_output_buffer_need(snd_output_t *output, size_t size)
int snd_output_buffer_printf(snd_output_t *output, const char *format, va_list args)
{
- snd_output_buffer_t *buffer = output->private;
+ snd_output_buffer_t *buffer = output->private_data;
size_t size = 256;
int result;
result = snd_output_buffer_need(output, size);
@@ -210,7 +210,7 @@ int snd_output_buffer_printf(snd_output_t *output, const char *format, va_list a
int snd_output_buffer_puts(snd_output_t *output, const char *str)
{
- snd_output_buffer_t *buffer = output->private;
+ snd_output_buffer_t *buffer = output->private_data;
size_t size = strlen(str);
int err;
err = snd_output_buffer_need(output, size);
@@ -223,7 +223,7 @@ int snd_output_buffer_puts(snd_output_t *output, const char *str)
int snd_output_buffer_putc(snd_output_t *output, int c)
{
- snd_output_buffer_t *buffer = output->private;
+ snd_output_buffer_t *buffer = output->private_data;
int err;
err = snd_output_buffer_need(output, 1);
if (err < 0)
@@ -234,14 +234,14 @@ int snd_output_buffer_putc(snd_output_t *output, int c)
int snd_output_buffer_flush(snd_output_t *output ATTRIBUTE_UNUSED)
{
- snd_output_buffer_t *buffer = output->private;
+ snd_output_buffer_t *buffer = output->private_data;
buffer->size = 0;
return 0;
}
size_t snd_output_buffer_string(snd_output_t *output, char **buf)
{
- snd_output_buffer_t *buffer = output->private;
+ snd_output_buffer_t *buffer = output->private_data;
*buf = buffer->buf;
return buffer->size;
}
@@ -272,7 +272,7 @@ int snd_output_buffer_open(snd_output_t **outputp)
buffer->size = 0;
output->type = SND_OUTPUT_BUFFER;
output->ops = &snd_output_buffer_ops;
- output->private = buffer;
+ output->private_data = buffer;
*outputp = output;
return 0;
}
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 40dd2863..f7395561 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -32,6 +32,12 @@
#include "pcm_local.h"
#include "list.h"
+const char *snd_pcm_name(snd_pcm_t *pcm)
+{
+ assert(pcm);
+ return pcm->name;
+}
+
snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm)
{
assert(pcm);
@@ -541,7 +547,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
const char *str;
int err;
snd_config_t *pcm_conf, *conf, *type_conf;
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
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);
@@ -569,25 +575,25 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
return snd_pcm_plug_open_hw(pcmp, name, card, dev, -1, stream, mode);
err = sscanf(name, "shm:%256[^,],%256[^,]", socket, sname);
if (err == 2)
- return snd_pcm_shm_open(pcmp, NULL, socket, sname, stream, mode);
+ return snd_pcm_shm_open(pcmp, name, socket, sname, stream, mode);
err = sscanf(name, "file:%256[^,],%16[^,]", file, format);
if (err == 2) {
snd_pcm_t *slave;
- err = snd_pcm_null_open(&slave, NULL, stream, mode);
+ err = snd_pcm_null_open(&slave, name, stream, mode);
if (err < 0)
return err;
- return snd_pcm_file_open(pcmp, NULL, file, -1, format, slave, 1);
+ return snd_pcm_file_open(pcmp, name, file, -1, format, slave, 1);
}
err = sscanf(name, "file:%256[^,]", file);
if (err == 1) {
snd_pcm_t *slave;
- err = snd_pcm_null_open(&slave, NULL, stream, mode);
+ err = snd_pcm_null_open(&slave, name, stream, mode);
if (err < 0)
return err;
- return snd_pcm_file_open(pcmp, NULL, file, -1, "raw", slave, 1);
+ return snd_pcm_file_open(pcmp, name, file, -1, "raw", slave, 1);
}
if (strcmp(name, "null") == 0)
- return snd_pcm_null_open(pcmp, NULL, stream, mode);
+ return snd_pcm_null_open(pcmp, name, stream, mode);
ERR("Unknown PCM %s", name);
return -ENOENT;
}
@@ -610,7 +616,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
ERR("Unknown PCM type %s", str);
return err;
}
- snd_config_foreach(i, type_conf) {
+ snd_config_for_each(i, next, type_conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
@@ -830,7 +836,8 @@ int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t
unsigned int samples, snd_pcm_format_t format)
{
/* FIXME: sub byte resolution and odd dst_offset */
- char *src, *dst;
+ const char *src;
+ char *dst;
int width;
int src_step, dst_step;
if (!src_area->addr)
diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c
index 8a48a248..cdd61a84 100644
--- a/src/pcm/pcm_adpcm.c
+++ b/src/pcm/pcm_adpcm.c
@@ -203,7 +203,7 @@ void snd_pcm_adpcm_decode(const snd_pcm_channel_area_t *dst_areas,
void *put = put16_labels[putidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel, ++states) {
- char *src;
+ const char *src;
int srcbit;
char *dst;
int src_step, srcbit_step, dst_step;
@@ -265,7 +265,7 @@ void snd_pcm_adpcm_encode(const snd_pcm_channel_area_t *dst_areas,
unsigned int channel;
int16_t sample = 0;
for (channel = 0; channel < channels; ++channel, ++states) {
- char *src;
+ const char *src;
char *dst;
int dstbit;
int src_step, dst_step, dstbit_step;
@@ -314,7 +314,7 @@ void snd_pcm_adpcm_encode(const snd_pcm_channel_area_t *dst_areas,
static int snd_pcm_adpcm_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_adpcm_t *adpcm = pcm->private;
+ snd_pcm_adpcm_t *adpcm = pcm->private_data;
int err;
snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
@@ -341,7 +341,7 @@ static int snd_pcm_adpcm_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
static int snd_pcm_adpcm_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
{
- snd_pcm_adpcm_t *adpcm = pcm->private;
+ snd_pcm_adpcm_t *adpcm = pcm->private_data;
snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
_snd_pcm_hw_params_any(sparams);
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
@@ -399,7 +399,7 @@ static int snd_pcm_adpcm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
{
- snd_pcm_adpcm_t *adpcm = pcm->private;
+ snd_pcm_adpcm_t *adpcm = pcm->private_data;
int err = snd_pcm_hw_params_slave(pcm, params,
snd_pcm_adpcm_hw_refine_cchange,
snd_pcm_adpcm_hw_refine_sprepare,
@@ -433,7 +433,7 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
static int snd_pcm_adpcm_hw_free(snd_pcm_t *pcm)
{
- snd_pcm_adpcm_t *adpcm = pcm->private;
+ snd_pcm_adpcm_t *adpcm = pcm->private_data;
if (adpcm->states) {
free(adpcm->states);
adpcm->states = 0;
@@ -443,7 +443,7 @@ static int snd_pcm_adpcm_hw_free(snd_pcm_t *pcm)
static int snd_pcm_adpcm_init(snd_pcm_t *pcm)
{
- snd_pcm_adpcm_t *adpcm = pcm->private;
+ snd_pcm_adpcm_t *adpcm = pcm->private_data;
unsigned int k;
for (k = 0; k < pcm->channels; ++k) {
adpcm->states[k].pred_val = 0;
@@ -458,7 +458,7 @@ static snd_pcm_sframes_t snd_pcm_adpcm_write_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_adpcm_t *adpcm = pcm->private;
+ snd_pcm_adpcm_t *adpcm = pcm->private_data;
snd_pcm_t *slave = adpcm->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -493,7 +493,7 @@ static snd_pcm_sframes_t snd_pcm_adpcm_read_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_adpcm_t *adpcm = pcm->private;
+ snd_pcm_adpcm_t *adpcm = pcm->private_data;
snd_pcm_t *slave = adpcm->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -524,7 +524,7 @@ static snd_pcm_sframes_t snd_pcm_adpcm_read_areas(snd_pcm_t *pcm,
static void snd_pcm_adpcm_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_adpcm_t *adpcm = pcm->private;
+ snd_pcm_adpcm_t *adpcm = pcm->private_data;
snd_output_printf(out, "Ima-ADPCM conversion PCM (%s)\n",
snd_pcm_format_name(adpcm->sformat));
if (pcm->setup) {
@@ -550,7 +550,7 @@ snd_pcm_ops_t snd_pcm_adpcm_ops = {
munmap: snd_pcm_plugin_munmap,
};
-int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
+int snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *pcm;
snd_pcm_adpcm_t *adpcm;
@@ -583,7 +583,7 @@ int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, s
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_plugin_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = adpcm;
+ pcm->private_data = adpcm;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = &adpcm->plug.hw_ptr;
pcm->appl_ptr = &adpcm->plug.appl_ptr;
@@ -592,16 +592,16 @@ int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, s
return 0;
}
-int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name,
+int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
int err;
snd_pcm_t *spcm;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c
index 54b2915a..30ebf226 100644
--- a/src/pcm/pcm_alaw.c
+++ b/src/pcm/pcm_alaw.c
@@ -132,7 +132,7 @@ void snd_pcm_alaw_decode(const snd_pcm_channel_area_t *dst_areas,
void *put = put16_labels[putidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel) {
- char *src;
+ const char *src;
char *dst;
int src_step, dst_step;
snd_pcm_uframes_t frames1;
@@ -178,7 +178,7 @@ void snd_pcm_alaw_encode(const snd_pcm_channel_area_t *dst_areas,
unsigned int channel;
int16_t sample = 0;
for (channel = 0; channel < channels; ++channel) {
- char *src;
+ const char *src;
char *dst;
int src_step, dst_step;
snd_pcm_uframes_t frames1;
@@ -213,7 +213,7 @@ void snd_pcm_alaw_encode(const snd_pcm_channel_area_t *dst_areas,
static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_alaw_t *alaw = pcm->private;
+ snd_pcm_alaw_t *alaw = pcm->private_data;
int err;
snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
@@ -239,7 +239,7 @@ static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *
static int snd_pcm_alaw_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
{
- snd_pcm_alaw_t *alaw = pcm->private;
+ snd_pcm_alaw_t *alaw = pcm->private_data;
snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
_snd_pcm_hw_params_any(sparams);
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
@@ -297,7 +297,7 @@ static int snd_pcm_alaw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
{
- snd_pcm_alaw_t *alaw = pcm->private;
+ snd_pcm_alaw_t *alaw = pcm->private_data;
int err = snd_pcm_hw_params_slave(pcm, params,
snd_pcm_alaw_hw_refine_cchange,
snd_pcm_alaw_hw_refine_sprepare,
@@ -332,7 +332,7 @@ static snd_pcm_sframes_t snd_pcm_alaw_write_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_alaw_t *alaw = pcm->private;
+ snd_pcm_alaw_t *alaw = pcm->private_data;
snd_pcm_t *slave = alaw->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -367,7 +367,7 @@ static snd_pcm_sframes_t snd_pcm_alaw_read_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_alaw_t *alaw = pcm->private;
+ snd_pcm_alaw_t *alaw = pcm->private_data;
snd_pcm_t *slave = alaw->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -398,7 +398,7 @@ static snd_pcm_sframes_t snd_pcm_alaw_read_areas(snd_pcm_t *pcm,
static void snd_pcm_alaw_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_alaw_t *alaw = pcm->private;
+ snd_pcm_alaw_t *alaw = pcm->private_data;
snd_output_printf(out, "A-Law conversion PCM (%s)\n",
snd_pcm_format_name(alaw->sformat));
if (pcm->setup) {
@@ -424,7 +424,7 @@ snd_pcm_ops_t snd_pcm_alaw_ops = {
munmap: snd_pcm_plugin_munmap,
};
-int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
+int snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *pcm;
snd_pcm_alaw_t *alaw;
@@ -456,7 +456,7 @@ int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, sn
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_plugin_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = alaw;
+ pcm->private_data = alaw;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = &alaw->plug.hw_ptr;
pcm->appl_ptr = &alaw->plug.appl_ptr;
@@ -465,16 +465,16 @@ int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, sn
return 0;
}
-int _snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name,
+int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
int err;
snd_pcm_t *spcm;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_copy.c b/src/pcm/pcm_copy.c
index 9f91e8bd..cf06865a 100644
--- a/src/pcm/pcm_copy.c
+++ b/src/pcm/pcm_copy.c
@@ -96,7 +96,7 @@ static snd_pcm_sframes_t snd_pcm_copy_write_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_copy_t *copy = pcm->private;
+ snd_pcm_copy_t *copy = pcm->private_data;
snd_pcm_t *slave = copy->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -131,7 +131,7 @@ static snd_pcm_sframes_t snd_pcm_copy_read_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_copy_t *copy = pcm->private;
+ snd_pcm_copy_t *copy = pcm->private_data;
snd_pcm_t *slave = copy->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -161,7 +161,7 @@ static snd_pcm_sframes_t snd_pcm_copy_read_areas(snd_pcm_t *pcm,
static void snd_pcm_copy_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_copy_t *copy = pcm->private;
+ snd_pcm_copy_t *copy = pcm->private_data;
snd_output_printf(out, "Copy conversion PCM\n");
if (pcm->setup) {
snd_output_printf(out, "Its setup is:\n");
@@ -186,7 +186,7 @@ snd_pcm_ops_t snd_pcm_copy_ops = {
munmap: snd_pcm_plugin_munmap,
};
-int snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_pcm_t *slave, int close_slave)
+int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *pcm;
snd_pcm_copy_t *copy;
@@ -214,7 +214,7 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_pcm_t *slave, int close_
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_plugin_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = copy;
+ pcm->private_data = copy;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = &copy->plug.hw_ptr;
pcm->appl_ptr = &copy->plug.appl_ptr;
@@ -223,15 +223,15 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_pcm_t *slave, int close_
return 0;
}
-int _snd_pcm_copy_open(snd_pcm_t **pcmp, char *name,
+int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
int err;
snd_pcm_t *spcm;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c
index 1962f6c8..20876f04 100644
--- a/src/pcm/pcm_file.c
+++ b/src/pcm/pcm_file.c
@@ -45,7 +45,7 @@ typedef struct {
static void snd_pcm_file_write_bytes(snd_pcm_t *pcm, size_t bytes)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
assert(bytes <= file->wbuf_used_bytes);
while (bytes > 0) {
snd_pcm_sframes_t err;
@@ -72,7 +72,7 @@ static void snd_pcm_file_add_frames(snd_pcm_t *pcm,
const snd_pcm_channel_area_t *areas,
snd_pcm_uframes_t offset, snd_pcm_uframes_t frames)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
while (frames > 0) {
snd_pcm_uframes_t n = frames;
snd_pcm_uframes_t cont = file->wbuf_size - file->appl_ptr;
@@ -97,7 +97,7 @@ static void snd_pcm_file_add_frames(snd_pcm_t *pcm,
static int snd_pcm_file_close(snd_pcm_t *pcm)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
int err = 0;
if (file->close_slave)
err = snd_pcm_close(file->slave);
@@ -111,55 +111,55 @@ static int snd_pcm_file_close(snd_pcm_t *pcm)
static int snd_pcm_file_nonblock(snd_pcm_t *pcm, int nonblock)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_nonblock(file->slave, nonblock);
}
static int snd_pcm_file_async(snd_pcm_t *pcm, int sig, pid_t pid)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_async(file->slave, sig, pid);
}
static int snd_pcm_file_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_info(file->slave, info);
}
static int snd_pcm_file_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_channel_info(file->slave, info);
}
static int snd_pcm_file_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_status(file->slave, status);
}
static snd_pcm_state_t snd_pcm_file_state(snd_pcm_t *pcm)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_state(file->slave);
}
static int snd_pcm_file_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_delay(file->slave, delayp);
}
static int snd_pcm_file_prepare(snd_pcm_t *pcm)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_prepare(file->slave);
}
static int snd_pcm_file_reset(snd_pcm_t *pcm)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
int err = snd_pcm_reset(file->slave);
if (err >= 0) {
/* FIXME: Questionable here */
@@ -171,13 +171,13 @@ static int snd_pcm_file_reset(snd_pcm_t *pcm)
static int snd_pcm_file_start(snd_pcm_t *pcm)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_start(file->slave);
}
static int snd_pcm_file_drop(snd_pcm_t *pcm)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
int err = snd_pcm_drop(file->slave);
if (err >= 0) {
/* FIXME: Questionable here */
@@ -189,7 +189,7 @@ static int snd_pcm_file_drop(snd_pcm_t *pcm)
static int snd_pcm_file_drain(snd_pcm_t *pcm)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
int err = snd_pcm_drain(file->slave);
if (err >= 0) {
snd_pcm_file_write_bytes(pcm, file->wbuf_used_bytes);
@@ -200,13 +200,13 @@ static int snd_pcm_file_drain(snd_pcm_t *pcm)
static int snd_pcm_file_pause(snd_pcm_t *pcm, int enable)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_pause(file->slave, enable);
}
static snd_pcm_sframes_t snd_pcm_file_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
snd_pcm_sframes_t err = snd_pcm_rewind(file->slave, frames);
if (err > 0) {
snd_pcm_uframes_t n = snd_pcm_frames_to_bytes(pcm, frames);
@@ -222,7 +222,7 @@ static snd_pcm_sframes_t snd_pcm_file_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t f
static snd_pcm_sframes_t snd_pcm_file_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
snd_pcm_channel_area_t areas[pcm->channels];
snd_pcm_sframes_t n = snd_pcm_writei(file->slave, buffer, size);
if (n > 0) {
@@ -234,7 +234,7 @@ static snd_pcm_sframes_t snd_pcm_file_writei(snd_pcm_t *pcm, const void *buffer,
static snd_pcm_sframes_t snd_pcm_file_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
snd_pcm_channel_area_t areas[pcm->channels];
snd_pcm_sframes_t n = snd_pcm_writen(file->slave, bufs, size);
if (n > 0) {
@@ -246,7 +246,7 @@ static snd_pcm_sframes_t snd_pcm_file_writen(snd_pcm_t *pcm, void **bufs, snd_pc
static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
snd_pcm_channel_area_t areas[pcm->channels];
snd_pcm_sframes_t n = snd_pcm_readi(file->slave, buffer, size);
if (n > 0) {
@@ -258,7 +258,7 @@ static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pc
static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
snd_pcm_channel_area_t areas[pcm->channels];
snd_pcm_sframes_t n = snd_pcm_writen(file->slave, bufs, size);
if (n > 0) {
@@ -270,7 +270,7 @@ static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm
static snd_pcm_sframes_t snd_pcm_file_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t size)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
snd_pcm_uframes_t ofs = snd_pcm_mmap_offset(pcm);
snd_pcm_sframes_t n = snd_pcm_mmap_forward(file->slave, size);
snd_pcm_uframes_t xfer = 0;
@@ -292,19 +292,19 @@ static snd_pcm_sframes_t snd_pcm_file_mmap_forward(snd_pcm_t *pcm, snd_pcm_ufram
static snd_pcm_sframes_t snd_pcm_file_avail_update(snd_pcm_t *pcm)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_avail_update(file->slave);
}
static int snd_pcm_file_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_hw_refine(file->slave, params);
}
static int snd_pcm_file_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
unsigned int channel;
snd_pcm_t *slave = file->slave;
int err = _snd_pcm_hw_params(slave, params);
@@ -328,7 +328,7 @@ static int snd_pcm_file_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
static int snd_pcm_file_hw_free(snd_pcm_t *pcm)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
if (file->wbuf) {
free(file->wbuf);
free(file->wbuf_areas);
@@ -340,7 +340,7 @@ static int snd_pcm_file_hw_free(snd_pcm_t *pcm)
static int snd_pcm_file_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
return snd_pcm_sw_params(file->slave, params);
}
@@ -356,7 +356,7 @@ static int snd_pcm_file_munmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
static void snd_pcm_file_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_file_t *file = pcm->private;
+ snd_pcm_file_t *file = pcm->private_data;
if (file->fname)
snd_output_printf(out, "File PCM (file=%s)\n", file->fname);
else
@@ -450,7 +450,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, const char *fname, int
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_file_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = file;
+ pcm->private_data = file;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = slave->hw_ptr;
pcm->appl_ptr = slave->appl_ptr;
@@ -459,18 +459,18 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, const char *fname, int
return 0;
}
-int _snd_pcm_file_open(snd_pcm_t **pcmp, char *name,
+int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
int err;
snd_pcm_t *spcm;
const char *fname = NULL;
const char *format = NULL;
long fd = -1;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 6bc6ffb5..1720aaaa 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -55,7 +55,7 @@ typedef struct {
static int snd_pcm_hw_nonblock(snd_pcm_t *pcm, int nonblock)
{
long flags;
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if ((flags = fcntl(fd, F_GETFL)) < 0) {
@@ -76,7 +76,7 @@ static int snd_pcm_hw_nonblock(snd_pcm_t *pcm, int nonblock)
static int snd_pcm_hw_async(snd_pcm_t *pcm, int sig, pid_t pid)
{
long flags;
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if ((flags = fcntl(fd, F_GETFL)) < 0) {
@@ -110,7 +110,7 @@ static int snd_pcm_hw_async(snd_pcm_t *pcm, int sig, pid_t pid)
static int snd_pcm_hw_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, info) < 0) {
SYSERR("SNDRV_PCM_IOCTL_INFO failed");
@@ -121,7 +121,7 @@ static int snd_pcm_hw_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
static int snd_pcm_hw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_HW_REFINE, params) < 0) {
// SYSERR("SNDRV_PCM_IOCTL_HW_REFINE failed");
@@ -132,7 +132,7 @@ static int snd_pcm_hw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_HW_PARAMS, params) < 0) {
SYSERR("SNDRV_PCM_IOCTL_HW_PARAMS failed");
@@ -143,7 +143,7 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
static int snd_pcm_hw_hw_free(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_HW_FREE) < 0) {
SYSERR("SNDRV_PCM_IOCTL_HW_FREE failed");
@@ -154,7 +154,7 @@ static int snd_pcm_hw_hw_free(snd_pcm_t *pcm)
static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if ((snd_pcm_start_t) params->start_mode == pcm->start_mode &&
(snd_pcm_xrun_t) params->xrun_mode == pcm->xrun_mode &&
@@ -176,7 +176,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
static int snd_pcm_hw_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
struct sndrv_pcm_channel_info i;
int fd = hw->fd;
i.channel = info->channel;
@@ -199,7 +199,7 @@ static int snd_pcm_hw_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info
static int snd_pcm_hw_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_STATUS, status) < 0) {
SYSERR("SNDRV_PCM_IOCTL_STATUS failed");
@@ -210,13 +210,13 @@ static int snd_pcm_hw_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
static snd_pcm_state_t snd_pcm_hw_state(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
return (snd_pcm_state_t) hw->mmap_status->state;
}
static int snd_pcm_hw_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_DELAY, delayp) < 0) {
SYSERR("SNDRV_PCM_IOCTL_DELAY failed");
@@ -227,7 +227,7 @@ static int snd_pcm_hw_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
static int snd_pcm_hw_prepare(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_PREPARE) < 0) {
SYSERR("SNDRV_PCM_IOCTL_PREPARE failed");
@@ -238,7 +238,7 @@ static int snd_pcm_hw_prepare(snd_pcm_t *pcm)
static int snd_pcm_hw_reset(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_RESET) < 0) {
SYSERR("SNDRV_PCM_IOCTL_RESET failed");
@@ -249,7 +249,7 @@ static int snd_pcm_hw_reset(snd_pcm_t *pcm)
static int snd_pcm_hw_start(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
#if 0
assert(pcm->stream != SND_PCM_STREAM_PLAYBACK ||
@@ -264,7 +264,7 @@ static int snd_pcm_hw_start(snd_pcm_t *pcm)
static int snd_pcm_hw_drop(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_DROP) < 0) {
SYSERR("SNDRV_PCM_IOCTL_DROP failed");
@@ -275,7 +275,7 @@ static int snd_pcm_hw_drop(snd_pcm_t *pcm)
static int snd_pcm_hw_drain(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_DRAIN) < 0) {
SYSERR("SNDRV_PCM_IOCTL_DRAIN failed");
@@ -286,7 +286,7 @@ static int snd_pcm_hw_drain(snd_pcm_t *pcm)
static int snd_pcm_hw_pause(snd_pcm_t *pcm, int enable)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_PAUSE, enable) < 0) {
SYSERR("SNDRV_PCM_IOCTL_PAUSE failed");
@@ -297,7 +297,7 @@ static int snd_pcm_hw_pause(snd_pcm_t *pcm, int enable)
static snd_pcm_sframes_t snd_pcm_hw_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
if (ioctl(fd, SNDRV_PCM_IOCTL_REWIND, &frames) < 0) {
SYSERR("SNDRV_PCM_IOCTL_REWIND failed");
@@ -309,7 +309,7 @@ static snd_pcm_sframes_t snd_pcm_hw_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t fra
static snd_pcm_sframes_t snd_pcm_hw_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
{
snd_pcm_sframes_t result;
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
struct sndrv_xferi xferi;
xferi.buf = (char*) buffer;
@@ -323,7 +323,7 @@ static snd_pcm_sframes_t snd_pcm_hw_writei(snd_pcm_t *pcm, const void *buffer, s
static snd_pcm_sframes_t snd_pcm_hw_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
{
snd_pcm_sframes_t result;
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
struct sndrv_xfern xfern;
xfern.bufs = bufs;
@@ -337,7 +337,7 @@ static snd_pcm_sframes_t snd_pcm_hw_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_
static snd_pcm_sframes_t snd_pcm_hw_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
{
snd_pcm_sframes_t result;
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
struct sndrv_xferi xferi;
xferi.buf = buffer;
@@ -351,7 +351,7 @@ static snd_pcm_sframes_t snd_pcm_hw_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_
snd_pcm_sframes_t snd_pcm_hw_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
{
snd_pcm_sframes_t result;
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
int fd = hw->fd;
struct sndrv_xfern xfern;
xfern.bufs = bufs;
@@ -364,7 +364,7 @@ snd_pcm_sframes_t snd_pcm_hw_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_
static int snd_pcm_hw_mmap_status(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
void *ptr;
ptr = mmap(NULL, PAGE_ALIGN(sizeof(struct sndrv_pcm_mmap_status)), PROT_READ, MAP_FILE|MAP_SHARED,
hw->fd, SND_PCM_MMAP_OFFSET_STATUS);
@@ -379,7 +379,7 @@ static int snd_pcm_hw_mmap_status(snd_pcm_t *pcm)
static int snd_pcm_hw_mmap_control(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
void *ptr;
ptr = mmap(NULL, PAGE_ALIGN(sizeof(struct sndrv_pcm_mmap_control)), PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED,
hw->fd, SND_PCM_MMAP_OFFSET_CONTROL);
@@ -394,7 +394,7 @@ static int snd_pcm_hw_mmap_control(snd_pcm_t *pcm)
static int snd_pcm_hw_munmap_status(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
if (munmap((void*)hw->mmap_status, PAGE_ALIGN(sizeof(*hw->mmap_status))) < 0) {
SYSERR("status munmap failed");
return -errno;
@@ -404,7 +404,7 @@ static int snd_pcm_hw_munmap_status(snd_pcm_t *pcm)
static int snd_pcm_hw_munmap_control(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
if (munmap(hw->mmap_control, PAGE_ALIGN(sizeof(*hw->mmap_control))) < 0) {
SYSERR("control munmap failed");
return -errno;
@@ -414,7 +414,7 @@ static int snd_pcm_hw_munmap_control(snd_pcm_t *pcm)
static int snd_pcm_hw_mmap(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
if (!(pcm->info & SND_PCM_INFO_MMAP)) {
snd_pcm_uframes_t size = snd_pcm_frames_to_bytes(pcm, pcm->buffer_size);
int id = shmget(IPC_PRIVATE, size, 0666);
@@ -429,7 +429,7 @@ static int snd_pcm_hw_mmap(snd_pcm_t *pcm)
static int snd_pcm_hw_munmap(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
if (!(pcm->info & SND_PCM_INFO_MMAP)) {
if (shmctl(hw->shmid, IPC_RMID, 0) < 0) {
SYSERR("shmctl IPC_RMID failed");
@@ -441,7 +441,7 @@ static int snd_pcm_hw_munmap(snd_pcm_t *pcm)
static int snd_pcm_hw_close(snd_pcm_t *pcm)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
if (close(hw->fd)) {
SYSERR("close failed\n");
return -errno;
@@ -494,7 +494,7 @@ static snd_pcm_sframes_t snd_pcm_hw_avail_update(snd_pcm_t *pcm)
static void snd_pcm_hw_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_hw_t *hw = pcm->private;
+ snd_pcm_hw_t *hw = pcm->private_data;
char *name = "Unknown";
snd_card_get_name(hw->card, &name);
snd_output_printf(out, "Hardware PCM card %d '%s' device %d subdevice %d\n",
@@ -632,7 +632,7 @@ int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdev
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_hw_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = hw;
+ pcm->private_data = hw;
pcm->poll_fd = fd;
*pcmp = pcm;
ret = snd_pcm_hw_mmap_status(pcm);
@@ -673,14 +673,14 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, int card, int device, in
return 0;
}
-int _snd_pcm_hw_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
+int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
long card = -1, device = 0, subdevice = -1;
const char *str;
int err;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c
index 88d9c1e4..b3a2ca52 100644
--- a/src/pcm/pcm_linear.c
+++ b/src/pcm/pcm_linear.c
@@ -98,7 +98,7 @@ void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufr
void *conv = conv_labels[convidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel) {
- char *src;
+ const char *src;
char *dst;
int src_step, dst_step;
snd_pcm_uframes_t frames1;
@@ -152,7 +152,7 @@ static int snd_pcm_linear_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, sn
static int snd_pcm_linear_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
{
- snd_pcm_linear_t *linear = pcm->private;
+ snd_pcm_linear_t *linear = pcm->private_data;
snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
_snd_pcm_hw_params_any(sparams);
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
@@ -210,7 +210,7 @@ static int snd_pcm_linear_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_linear_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_linear_t *linear = pcm->private;
+ snd_pcm_linear_t *linear = pcm->private_data;
int err = snd_pcm_hw_params_slave(pcm, params,
snd_pcm_linear_hw_refine_cchange,
snd_pcm_linear_hw_refine_sprepare,
@@ -233,7 +233,7 @@ static snd_pcm_sframes_t snd_pcm_linear_write_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_linear_t *linear = pcm->private;
+ snd_pcm_linear_t *linear = pcm->private_data;
snd_pcm_t *slave = linear->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -267,7 +267,7 @@ static snd_pcm_sframes_t snd_pcm_linear_read_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_linear_t *linear = pcm->private;
+ snd_pcm_linear_t *linear = pcm->private_data;
snd_pcm_t *slave = linear->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -297,7 +297,7 @@ static snd_pcm_sframes_t snd_pcm_linear_read_areas(snd_pcm_t *pcm,
static void snd_pcm_linear_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_linear_t *linear = pcm->private;
+ snd_pcm_linear_t *linear = pcm->private_data;
snd_output_printf(out, "Linear conversion PCM (%s)\n",
snd_pcm_format_name(linear->sformat));
if (pcm->setup) {
@@ -323,7 +323,7 @@ snd_pcm_ops_t snd_pcm_linear_ops = {
munmap: snd_pcm_plugin_munmap,
};
-int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
+int snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *pcm;
snd_pcm_linear_t *linear;
@@ -354,7 +354,7 @@ int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat,
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_plugin_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = linear;
+ pcm->private_data = linear;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = &linear->plug.hw_ptr;
pcm->appl_ptr = &linear->plug.appl_ptr;
@@ -363,16 +363,16 @@ int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat,
return 0;
}
-int _snd_pcm_linear_open(snd_pcm_t **pcmp, char *name,
+int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
int err;
snd_pcm_t *spcm;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h
index 2e74eff9..97466a7d 100644
--- a/src/pcm/pcm_local.h
+++ b/src/pcm/pcm_local.h
@@ -162,7 +162,7 @@ struct _snd_pcm {
snd_pcm_fast_ops_t *fast_ops;
snd_pcm_t *op_arg;
snd_pcm_t *fast_op_arg;
- void *private;
+ void *private_data;
};
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);
diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c
index 81af0438..1e4cd20d 100644
--- a/src/pcm/pcm_mmap.c
+++ b/src/pcm/pcm_mmap.c
@@ -435,7 +435,7 @@ snd_pcm_sframes_t snd_pcm_write_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t size)
case SND_PCM_ACCESS_MMAP_INTERLEAVED:
{
const snd_pcm_channel_area_t *a = snd_pcm_mmap_areas(pcm);
- char *buf = snd_pcm_channel_area_addr(a, offset);
+ const char *buf = snd_pcm_channel_area_addr(a, offset);
err = _snd_pcm_writei(pcm, buf, size);
break;
}
diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c
index d6099b07..3399a882 100644
--- a/src/pcm/pcm_mulaw.c
+++ b/src/pcm/pcm_mulaw.c
@@ -149,7 +149,7 @@ void snd_pcm_mulaw_decode(const snd_pcm_channel_area_t *dst_areas,
void *put = put16_labels[putidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel) {
- char *src;
+ const char *src;
char *dst;
int src_step, dst_step;
snd_pcm_uframes_t frames1;
@@ -195,7 +195,7 @@ void snd_pcm_mulaw_encode(const snd_pcm_channel_area_t *dst_areas,
unsigned int channel;
int16_t sample = 0;
for (channel = 0; channel < channels; ++channel) {
- char *src;
+ const char *src;
char *dst;
int src_step, dst_step;
snd_pcm_uframes_t frames1;
@@ -230,7 +230,7 @@ void snd_pcm_mulaw_encode(const snd_pcm_channel_area_t *dst_areas,
static int snd_pcm_mulaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_mulaw_t *mulaw = pcm->private;
+ snd_pcm_mulaw_t *mulaw = pcm->private_data;
int err;
snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
@@ -254,7 +254,7 @@ static int snd_pcm_mulaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
static int snd_pcm_mulaw_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
{
- snd_pcm_mulaw_t *mulaw = pcm->private;
+ snd_pcm_mulaw_t *mulaw = pcm->private_data;
snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
_snd_pcm_hw_params_any(sparams);
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
@@ -312,7 +312,7 @@ static int snd_pcm_mulaw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_mulaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
{
- snd_pcm_mulaw_t *mulaw = pcm->private;
+ snd_pcm_mulaw_t *mulaw = pcm->private_data;
int err = snd_pcm_hw_params_slave(pcm, params,
snd_pcm_mulaw_hw_refine_cchange,
snd_pcm_mulaw_hw_refine_sprepare,
@@ -347,7 +347,7 @@ static snd_pcm_sframes_t snd_pcm_mulaw_write_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_mulaw_t *mulaw = pcm->private;
+ snd_pcm_mulaw_t *mulaw = pcm->private_data;
snd_pcm_t *slave = mulaw->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -382,7 +382,7 @@ static snd_pcm_sframes_t snd_pcm_mulaw_read_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_mulaw_t *mulaw = pcm->private;
+ snd_pcm_mulaw_t *mulaw = pcm->private_data;
snd_pcm_t *slave = mulaw->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -413,7 +413,7 @@ static snd_pcm_sframes_t snd_pcm_mulaw_read_areas(snd_pcm_t *pcm,
static void snd_pcm_mulaw_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_mulaw_t *mulaw = pcm->private;
+ snd_pcm_mulaw_t *mulaw = pcm->private_data;
snd_output_printf(out, "Mu-Law conversion PCM (%s)\n",
snd_pcm_format_name(mulaw->sformat));
if (pcm->setup) {
@@ -439,7 +439,7 @@ snd_pcm_ops_t snd_pcm_mulaw_ops = {
munmap: snd_pcm_plugin_munmap,
};
-int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
+int snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *pcm;
snd_pcm_mulaw_t *mulaw;
@@ -471,7 +471,7 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, s
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_plugin_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = mulaw;
+ pcm->private_data = mulaw;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = &mulaw->plug.hw_ptr;
pcm->appl_ptr = &mulaw->plug.appl_ptr;
@@ -480,16 +480,16 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, s
return 0;
}
-int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name,
+int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
int err;
snd_pcm_t *spcm;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c
index d14bddd2..4af4151f 100644
--- a/src/pcm/pcm_multi.c
+++ b/src/pcm/pcm_multi.c
@@ -46,7 +46,7 @@ typedef struct {
static int snd_pcm_multi_close(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
unsigned int i;
int ret = 0;
for (i = 0; i < multi->slaves_count; ++i) {
@@ -72,14 +72,14 @@ static int snd_pcm_multi_nonblock(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int nonblock
static int snd_pcm_multi_async(snd_pcm_t *pcm, int sig, pid_t pid)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_t *slave_0 = multi->slaves[0].pcm;
return snd_pcm_async(slave_0, sig, pid);
}
static int snd_pcm_multi_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
if (multi->slaves_count == 1)
return snd_pcm_info(multi->slaves[0].pcm, info);
memset(info, 0, sizeof(*info));
@@ -94,7 +94,7 @@ static int snd_pcm_multi_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
static int snd_pcm_multi_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_access_mask_t access_mask;
int err;
snd_pcm_access_mask_any(&access_mask);
@@ -114,7 +114,7 @@ static int snd_pcm_multi_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
static int snd_pcm_multi_hw_refine_sprepare(snd_pcm_t *pcm, int slave_idx,
snd_pcm_hw_params_t *sparams)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_multi_slave_t *slave = &multi->slaves[slave_idx];
snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
_snd_pcm_hw_params_any(sparams);
@@ -197,14 +197,14 @@ static int snd_pcm_multi_hw_refine_slave(snd_pcm_t *pcm,
int slave_idx,
snd_pcm_hw_params_t *sparams)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_t *slave = multi->slaves[slave_idx].pcm;
return snd_pcm_hw_refine(slave, sparams);
}
static int snd_pcm_multi_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
unsigned int k;
snd_pcm_hw_params_t sparams[multi->slaves_count];
int err;
@@ -247,7 +247,7 @@ static int snd_pcm_multi_hw_params_slave(snd_pcm_t *pcm,
int slave_idx,
snd_pcm_hw_params_t *sparams)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_t *slave = multi->slaves[slave_idx].pcm;
int err = snd_pcm_hw_refine(slave, sparams);
if (err < 0)
@@ -265,7 +265,7 @@ static int snd_pcm_multi_hw_params_slave(snd_pcm_t *pcm,
static int snd_pcm_multi_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
unsigned int k;
snd_pcm_hw_params_t sparams[multi->slaves_count];
int err;
@@ -285,7 +285,7 @@ static int snd_pcm_multi_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_multi_hw_free(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
unsigned int i;
int err = 0;
for (i = 0; i < multi->slaves_count; ++i) {
@@ -299,7 +299,7 @@ static int snd_pcm_multi_hw_free(snd_pcm_t *pcm)
static int snd_pcm_multi_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
unsigned int i;
int err;
for (i = 0; i < multi->slaves_count; ++i) {
@@ -313,71 +313,71 @@ static int snd_pcm_multi_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
static int snd_pcm_multi_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_t *slave = multi->slaves[0].pcm;
return snd_pcm_status(slave, status);
}
static snd_pcm_state_t snd_pcm_multi_state(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_t *slave = multi->slaves[0].pcm;
return snd_pcm_state(slave);
}
static int snd_pcm_multi_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_t *slave = multi->slaves[0].pcm;
return snd_pcm_delay(slave, delayp);
}
static snd_pcm_sframes_t snd_pcm_multi_avail_update(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_t *slave = multi->slaves[0].pcm;
return snd_pcm_avail_update(slave);
}
static int snd_pcm_multi_prepare(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
return snd_pcm_prepare(multi->slaves[0].pcm);
}
static int snd_pcm_multi_reset(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
return snd_pcm_reset(multi->slaves[0].pcm);
}
static int snd_pcm_multi_start(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
return snd_pcm_start(multi->slaves[0].pcm);
}
static int snd_pcm_multi_drop(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
return snd_pcm_drop(multi->slaves[0].pcm);
}
static int snd_pcm_multi_drain(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
return snd_pcm_drain(multi->slaves[0].pcm);
}
static int snd_pcm_multi_pause(snd_pcm_t *pcm, int enable)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
return snd_pcm_pause(multi->slaves[0].pcm, enable);
}
static int snd_pcm_multi_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
unsigned int channel = info->channel;
snd_pcm_multi_channel_t *c = &multi->channels[channel];
int err;
@@ -391,7 +391,7 @@ static int snd_pcm_multi_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *in
static snd_pcm_sframes_t snd_pcm_multi_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
unsigned int i;
snd_pcm_uframes_t pos[multi->slaves_count];
memset(pos, 0, sizeof(pos));
@@ -415,7 +415,7 @@ static snd_pcm_sframes_t snd_pcm_multi_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t
static snd_pcm_sframes_t snd_pcm_multi_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t size)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
unsigned int i;
for (i = 0; i < multi->slaves_count; ++i) {
@@ -445,14 +445,14 @@ static int snd_pcm_multi_munmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
int snd_pcm_multi_poll_descriptor(snd_pcm_t *pcm)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
snd_pcm_t *slave = multi->slaves[0].pcm;
return snd_pcm_poll_descriptor(slave);
}
static void snd_pcm_multi_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_multi_t *multi = pcm->private;
+ snd_pcm_multi_t *multi = pcm->private_data;
unsigned int k;
snd_output_printf(out, "Multi PCM\n");
snd_output_printf(out, "\nChannel bindings:\n");
@@ -507,7 +507,7 @@ snd_pcm_fast_ops_t snd_pcm_multi_fast_ops = {
mmap_forward: snd_pcm_multi_mmap_forward,
};
-int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name,
+int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
unsigned int slaves_count,
snd_pcm_t **slaves_pcm, unsigned int *schannels_count,
unsigned int channels_count,
@@ -572,7 +572,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name,
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_multi_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = multi;
+ pcm->private_data = multi;
pcm->poll_fd = multi->slaves[0].pcm->poll_fd;
pcm->hw_ptr = multi->slaves[0].pcm->hw_ptr;
pcm->appl_ptr = multi->slaves[0].pcm->appl_ptr;
@@ -580,15 +580,15 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name,
return 0;
}
-int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
+int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i, j;
+ snd_config_iterator_t i, inext, j, jnext;
snd_config_t *slave = NULL;
snd_config_t *binding = NULL;
int err;
unsigned int idx;
- char **slaves_id = NULL;
+ const char **slaves_id = NULL;
char **slaves_name = NULL;
snd_pcm_t **slaves_pcm = NULL;
unsigned int *slaves_channels = NULL;
@@ -596,7 +596,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
unsigned int *channels_schannel = NULL;
unsigned int slaves_count = 0;
unsigned int channels_count = 0;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, inext, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
@@ -630,10 +630,10 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
ERR("binding is not defined");
return -EINVAL;
}
- snd_config_foreach(i, slave) {
+ snd_config_for_each(i, inext, slave) {
++slaves_count;
}
- snd_config_foreach(i, binding) {
+ snd_config_for_each(i, inext, binding) {
int cchannel = -1;
char *p;
snd_config_t *m = snd_config_iterator_entry(i);
@@ -661,12 +661,12 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
for (idx = 0; idx < channels_count; ++idx)
channels_sidx[idx] = -1;
idx = 0;
- snd_config_foreach(i, slave) {
+ snd_config_for_each(i, inext, slave) {
snd_config_t *m = snd_config_iterator_entry(i);
const char *name = NULL;
long channels = -1;
slaves_id[idx] = snd_config_get_id(m);
- snd_config_foreach(j, m) {
+ snd_config_for_each(j, jnext, m) {
snd_config_t *n = snd_config_iterator_entry(j);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
@@ -706,7 +706,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
++idx;
}
- snd_config_foreach(i, binding) {
+ snd_config_for_each(i, inext, binding) {
snd_config_t *m = snd_config_iterator_entry(i);
long cchannel = -1;
long schannel = -1;
@@ -720,7 +720,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
err = -EINVAL;
goto _free;
}
- snd_config_foreach(j, m) {
+ snd_config_for_each(j, jnext, m) {
snd_config_t *n = snd_config_iterator_entry(j);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c
index ae8460cc..a750730d 100644
--- a/src/pcm/pcm_null.c
+++ b/src/pcm/pcm_null.c
@@ -36,7 +36,7 @@ typedef struct {
static int snd_pcm_null_close(snd_pcm_t *pcm)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
close(null->poll_fd);
free(null);
return 0;
@@ -66,13 +66,13 @@ static int snd_pcm_null_info(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_info_t * i
static int snd_pcm_null_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
return snd_pcm_channel_info_shm(pcm, info, null->shmid);
}
static int snd_pcm_null_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
memset(status, 0, sizeof(*status));
status->state = snd_enum_to_int(null->state);
status->trigger_tstamp = null->trigger_tstamp;
@@ -84,7 +84,7 @@ static int snd_pcm_null_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
static snd_pcm_state_t snd_pcm_null_state(snd_pcm_t *pcm)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
return null->state;
}
@@ -96,7 +96,7 @@ static int snd_pcm_null_delay(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sframes_t
static int snd_pcm_null_prepare(snd_pcm_t *pcm)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
null->state = SND_PCM_STATE_PREPARED;
null->appl_ptr = 0;
null->hw_ptr = 0;
@@ -105,7 +105,7 @@ static int snd_pcm_null_prepare(snd_pcm_t *pcm)
static int snd_pcm_null_reset(snd_pcm_t *pcm)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
null->appl_ptr = 0;
null->hw_ptr = 0;
return 0;
@@ -113,7 +113,7 @@ static int snd_pcm_null_reset(snd_pcm_t *pcm)
static int snd_pcm_null_start(snd_pcm_t *pcm)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
assert(null->state == SND_PCM_STATE_PREPARED);
null->state = SND_PCM_STATE_RUNNING;
if (pcm->stream == SND_PCM_STREAM_CAPTURE)
@@ -123,7 +123,7 @@ static int snd_pcm_null_start(snd_pcm_t *pcm)
static int snd_pcm_null_drop(snd_pcm_t *pcm)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
assert(null->state != SND_PCM_STATE_OPEN);
null->state = SND_PCM_STATE_SETUP;
return 0;
@@ -131,7 +131,7 @@ static int snd_pcm_null_drop(snd_pcm_t *pcm)
static int snd_pcm_null_drain(snd_pcm_t *pcm)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
assert(null->state != SND_PCM_STATE_OPEN);
null->state = SND_PCM_STATE_SETUP;
return 0;
@@ -139,7 +139,7 @@ static int snd_pcm_null_drain(snd_pcm_t *pcm)
static int snd_pcm_null_pause(snd_pcm_t *pcm, int enable)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
if (enable) {
if (null->state != SND_PCM_STATE_RUNNING)
return -EBADFD;
@@ -151,7 +151,7 @@ static int snd_pcm_null_pause(snd_pcm_t *pcm, int enable)
static snd_pcm_sframes_t snd_pcm_null_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
switch (snd_enum_to_int(null->state)) {
case SND_PCM_STATE_PREPARED:
case SND_PCM_STATE_RUNNING:
@@ -165,7 +165,7 @@ static snd_pcm_sframes_t snd_pcm_null_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t f
static snd_pcm_sframes_t snd_pcm_null_fwd(snd_pcm_t *pcm, snd_pcm_uframes_t size)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
switch (snd_enum_to_int(null->state)) {
case SND_PCM_STATE_PREPARED:
case SND_PCM_STATE_RUNNING:
@@ -179,7 +179,7 @@ static snd_pcm_sframes_t snd_pcm_null_fwd(snd_pcm_t *pcm, snd_pcm_uframes_t size
static snd_pcm_sframes_t snd_pcm_null_writei(snd_pcm_t *pcm, const void *buffer ATTRIBUTE_UNUSED, snd_pcm_uframes_t size)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
if (null->state == SND_PCM_STATE_PREPARED &&
pcm->start_mode != SND_PCM_START_EXPLICIT) {
null->state = SND_PCM_STATE_RUNNING;
@@ -189,7 +189,7 @@ static snd_pcm_sframes_t snd_pcm_null_writei(snd_pcm_t *pcm, const void *buffer
static snd_pcm_sframes_t snd_pcm_null_writen(snd_pcm_t *pcm, void **bufs ATTRIBUTE_UNUSED, snd_pcm_uframes_t size)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
if (null->state == SND_PCM_STATE_PREPARED &&
pcm->start_mode != SND_PCM_START_EXPLICIT) {
null->state = SND_PCM_STATE_RUNNING;
@@ -199,7 +199,7 @@ static snd_pcm_sframes_t snd_pcm_null_writen(snd_pcm_t *pcm, void **bufs ATTRIBU
static snd_pcm_sframes_t snd_pcm_null_readi(snd_pcm_t *pcm, void *buffer ATTRIBUTE_UNUSED, snd_pcm_uframes_t size)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
if (null->state == SND_PCM_STATE_PREPARED &&
pcm->start_mode != SND_PCM_START_EXPLICIT) {
null->state = SND_PCM_STATE_RUNNING;
@@ -210,7 +210,7 @@ static snd_pcm_sframes_t snd_pcm_null_readi(snd_pcm_t *pcm, void *buffer ATTRIBU
static snd_pcm_sframes_t snd_pcm_null_readn(snd_pcm_t *pcm, void **bufs ATTRIBUTE_UNUSED, snd_pcm_uframes_t size)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
if (null->state == SND_PCM_STATE_PREPARED &&
pcm->start_mode != SND_PCM_START_EXPLICIT) {
null->state = SND_PCM_STATE_RUNNING;
@@ -253,7 +253,7 @@ static int snd_pcm_null_sw_params(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_pa
static int snd_pcm_null_mmap(snd_pcm_t *pcm)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
if (!(pcm->info & SND_PCM_INFO_MMAP)) {
size_t size = snd_pcm_frames_to_bytes(pcm, pcm->buffer_size);
int id = shmget(IPC_PRIVATE, size, 0666);
@@ -268,7 +268,7 @@ static int snd_pcm_null_mmap(snd_pcm_t *pcm)
static int snd_pcm_null_munmap(snd_pcm_t *pcm)
{
- snd_pcm_null_t *null = pcm->private;
+ snd_pcm_null_t *null = pcm->private_data;
if (shmctl(null->shmid, IPC_RMID, 0) < 0) {
SYSERR("shmctl IPC_RMID failed");
return -errno;
@@ -361,7 +361,7 @@ int snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t strea
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_null_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = null;
+ pcm->private_data = null;
pcm->poll_fd = fd;
pcm->hw_ptr = &null->hw_ptr;
pcm->appl_ptr = &null->appl_ptr;
@@ -370,12 +370,12 @@ int snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t strea
return 0;
}
-int _snd_pcm_null_open(snd_pcm_t **pcmp, char *name,
+int _snd_pcm_null_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
- snd_config_foreach(i, conf) {
+ snd_config_iterator_t i, next;
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c
index 5de07a18..fe1772c9 100644
--- a/src/pcm/pcm_params.c
+++ b/src/pcm/pcm_params.c
@@ -1015,7 +1015,7 @@ struct _snd_pcm_hw_strategy {
unsigned int max_badness,
snd_pcm_t *pcm,
const snd_pcm_hw_strategy_t *strategy);
- void *private;
+ void *private_data;
void (*free)(snd_pcm_hw_strategy_t *strategy);
};
@@ -1034,7 +1034,7 @@ struct _snd_pcm_hw_strategy_simple {
unsigned int param,
snd_pcm_t *pcm,
const snd_pcm_hw_strategy_simple_t *par);
- void *private;
+ void *private_data;
void (*free)(snd_pcm_hw_strategy_simple_t *strategy);
};
@@ -1210,7 +1210,7 @@ int snd_pcm_hw_params_strategy(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
void snd_pcm_hw_strategy_simple_free(snd_pcm_hw_strategy_t *strategy)
{
- snd_pcm_hw_strategy_simple_t *pars = strategy->private;
+ snd_pcm_hw_strategy_simple_t *pars = strategy->private_data;
int k;
for (k = 0; k <= SND_PCM_HW_PARAM_LAST; ++k) {
if (pars[k].valid && pars[k].free)
@@ -1225,7 +1225,7 @@ int snd_pcm_hw_strategy_simple_choose_param(const snd_pcm_hw_params_t *params,
{
snd_pcm_hw_param_t var;
int best_var = -1;
- const snd_pcm_hw_strategy_simple_t *pars = strategy->private;
+ const snd_pcm_hw_strategy_simple_t *pars = strategy->private_data;
unsigned int min_choices = UINT_MAX;
unsigned int min_order = UINT_MAX;
for (var = 0; var <= SND_PCM_HW_PARAM_LAST; ++var) {
@@ -1254,7 +1254,7 @@ int snd_pcm_hw_strategy_simple_next_value(snd_pcm_hw_params_t *params,
snd_pcm_t *pcm,
const snd_pcm_hw_strategy_t *strategy)
{
- const snd_pcm_hw_strategy_simple_t *pars = strategy->private;
+ const snd_pcm_hw_strategy_simple_t *pars = strategy->private_data;
assert(pars[var].valid);
return pars[var].next_value(params, var, value, dir, pcm, &pars[var]);
}
@@ -1267,7 +1267,7 @@ int snd_pcm_hw_strategy_simple_min_badness(const snd_pcm_hw_params_t *params,
{
snd_pcm_hw_param_t var;
unsigned int badness = 0;
- const snd_pcm_hw_strategy_simple_t *pars = strategy->private;
+ const snd_pcm_hw_strategy_simple_t *pars = strategy->private_data;
for (var = 0; var <= SND_PCM_HW_PARAM_LAST; ++var) {
unsigned int b;
if (!pars[var].valid)
@@ -1283,7 +1283,7 @@ int snd_pcm_hw_strategy_simple_min_badness(const snd_pcm_hw_params_t *params,
void snd_pcm_hw_strategy_simple_near_free(snd_pcm_hw_strategy_simple_t *par)
{
- snd_pcm_hw_strategy_simple_near_t *p = par->private;
+ snd_pcm_hw_strategy_simple_near_t *p = par->private_data;
free(p);
}
@@ -1292,7 +1292,7 @@ unsigned int snd_pcm_hw_strategy_simple_near_min_badness(const snd_pcm_hw_params
snd_pcm_t *pcm,
const snd_pcm_hw_strategy_simple_t *par)
{
- const snd_pcm_hw_strategy_simple_near_t *p = par->private;
+ const snd_pcm_hw_strategy_simple_near_t *p = par->private_data;
snd_pcm_hw_params_t params1 = *params;
int value = snd_pcm_hw_param_set_near(pcm, &params1, var, p->best, 0);
int diff;
@@ -1309,7 +1309,7 @@ int snd_pcm_hw_strategy_simple_near_next_value(snd_pcm_hw_params_t *params,
snd_pcm_t *pcm,
const snd_pcm_hw_strategy_simple_t *par)
{
- const snd_pcm_hw_strategy_simple_near_t *p = par->private;
+ const snd_pcm_hw_strategy_simple_near_t *p = par->private_data;
if (value < 0) {
*dir = 0;
return snd_pcm_hw_param_set_near(pcm, params, var, p->best, dir);
@@ -1319,7 +1319,7 @@ int snd_pcm_hw_strategy_simple_near_next_value(snd_pcm_hw_params_t *params,
void snd_pcm_hw_strategy_simple_choices_free(snd_pcm_hw_strategy_simple_t *par)
{
- snd_pcm_hw_strategy_simple_choices_t *p = par->private;
+ snd_pcm_hw_strategy_simple_choices_t *p = par->private_data;
// free(p->choices);
free(p);
}
@@ -1329,7 +1329,7 @@ unsigned int snd_pcm_hw_strategy_simple_choices_min_badness(const snd_pcm_hw_par
snd_pcm_t *pcm,
const snd_pcm_hw_strategy_simple_t *par)
{
- const snd_pcm_hw_strategy_simple_choices_t *p = par->private;
+ const snd_pcm_hw_strategy_simple_choices_t *p = par->private_data;
unsigned int k;
for (k = 0; k < p->count; ++k) {
if (snd_pcm_hw_param_set(pcm, (snd_pcm_hw_params_t *) params, SND_TEST, var, p->choices[k].value, 0))
@@ -1345,7 +1345,7 @@ int snd_pcm_hw_strategy_simple_choices_next_value(snd_pcm_hw_params_t *params,
snd_pcm_t *pcm,
const snd_pcm_hw_strategy_simple_t *par)
{
- const snd_pcm_hw_strategy_simple_choices_t *p = par->private;
+ const snd_pcm_hw_strategy_simple_choices_t *p = par->private_data;
unsigned int k = 0;
if (value >= 0) {
for (; k < p->count; ++k) {
@@ -1393,7 +1393,7 @@ int snd_pcm_hw_strategy_simple(snd_pcm_hw_strategy_t **strategyp,
s->min_badness = snd_pcm_hw_strategy_simple_min_badness;
s->badness_min = badness_min;
s->badness_max = badness_max;
- s->private = data;
+ s->private_data = data;
s->free = snd_pcm_hw_strategy_simple_free;
*strategyp = s;
return 0;
@@ -1405,7 +1405,7 @@ int snd_pcm_hw_strategy_simple_near(snd_pcm_hw_strategy_t *strategy,
unsigned int best,
unsigned int mul)
{
- snd_pcm_hw_strategy_simple_t *s = strategy->private;
+ snd_pcm_hw_strategy_simple_t *s = strategy->private_data;
snd_pcm_hw_strategy_simple_near_t *data;
assert(strategy);
assert(var <= SND_PCM_HW_PARAM_LAST);
@@ -1420,7 +1420,7 @@ int snd_pcm_hw_strategy_simple_near(snd_pcm_hw_strategy_t *strategy,
s->valid = 1;
s->next_value = snd_pcm_hw_strategy_simple_near_next_value;
s->min_badness = snd_pcm_hw_strategy_simple_near_min_badness;
- s->private = data;
+ s->private_data = data;
s->free = snd_pcm_hw_strategy_simple_near_free;
return 0;
}
@@ -1431,7 +1431,7 @@ int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy,
unsigned int count,
snd_pcm_hw_strategy_simple_choices_list_t *choices)
{
- snd_pcm_hw_strategy_simple_t *s = strategy->private;
+ snd_pcm_hw_strategy_simple_t *s = strategy->private_data;
snd_pcm_hw_strategy_simple_choices_t *data;
assert(strategy);
assert(var <= SND_PCM_HW_PARAM_LAST);
@@ -1446,7 +1446,7 @@ int snd_pcm_hw_strategy_simple_choices(snd_pcm_hw_strategy_t *strategy,
s->order = order;
s->next_value = snd_pcm_hw_strategy_simple_choices_next_value;
s->min_badness = snd_pcm_hw_strategy_simple_choices_min_badness;
- s->private = data;
+ s->private_data = data;
s->free = snd_pcm_hw_strategy_simple_choices_free;
return 0;
}
@@ -1518,7 +1518,7 @@ struct _snd_pcm_hw_rule {
int var;
snd_pcm_hw_rule_func_t func;
int deps[4];
- void *private;
+ void *private_data;
};
int snd_pcm_hw_rule_mul(snd_pcm_hw_params_t *params,
@@ -1545,7 +1545,7 @@ int snd_pcm_hw_rule_muldivk(snd_pcm_hw_params_t *params,
snd_interval_t t;
snd_interval_muldivk(hw_param_interval_c(params, rule->deps[0]),
hw_param_interval_c(params, rule->deps[1]),
- (unsigned long) rule->private, &t);
+ (unsigned long) rule->private_data, &t);
return snd_interval_refine(hw_param_interval(params, rule->var), &t);
}
@@ -1554,7 +1554,7 @@ int snd_pcm_hw_rule_mulkdiv(snd_pcm_hw_params_t *params,
{
snd_interval_t t;
snd_interval_mulkdiv(hw_param_interval_c(params, rule->deps[0]),
- (unsigned long) rule->private,
+ (unsigned long) rule->private_data,
hw_param_interval_c(params, rule->deps[1]), &t);
return snd_interval_refine(hw_param_interval(params, rule->var), &t);
}
@@ -1624,140 +1624,140 @@ static snd_pcm_hw_rule_t refine_rules[] = {
var: SND_PCM_HW_PARAM_FORMAT,
func: snd_pcm_hw_rule_format,
deps: { SND_PCM_HW_PARAM_SAMPLE_BITS, -1 },
- private: 0,
+ private_data: 0,
},
{
var: SND_PCM_HW_PARAM_SAMPLE_BITS,
func: snd_pcm_hw_rule_sample_bits,
deps: { SND_PCM_HW_PARAM_FORMAT,
SND_PCM_HW_PARAM_SAMPLE_BITS, -1 },
- private: 0,
+ private_data: 0,
},
{
var: SND_PCM_HW_PARAM_SAMPLE_BITS,
func: snd_pcm_hw_rule_div,
deps: { SND_PCM_HW_PARAM_FRAME_BITS,
SND_PCM_HW_PARAM_CHANNELS, -1 },
- private: 0,
+ private_data: 0,
},
{
var: SND_PCM_HW_PARAM_FRAME_BITS,
func: snd_pcm_hw_rule_mul,
deps: { SND_PCM_HW_PARAM_SAMPLE_BITS,
SND_PCM_HW_PARAM_CHANNELS, -1 },
- private: 0,
+ private_data: 0,
},
{
var: SND_PCM_HW_PARAM_FRAME_BITS,
func: snd_pcm_hw_rule_mulkdiv,
deps: { SND_PCM_HW_PARAM_PERIOD_BYTES,
SND_PCM_HW_PARAM_PERIOD_SIZE, -1 },
- private: (void*) 8,
+ private_data: (void*) 8,
},
{
var: SND_PCM_HW_PARAM_FRAME_BITS,
func: snd_pcm_hw_rule_mulkdiv,
deps: { SND_PCM_HW_PARAM_BUFFER_BYTES,
SND_PCM_HW_PARAM_BUFFER_SIZE, -1 },
- private: (void*) 8,
+ private_data: (void*) 8,
},
{
var: SND_PCM_HW_PARAM_CHANNELS,
func: snd_pcm_hw_rule_div,
deps: { SND_PCM_HW_PARAM_FRAME_BITS,
SND_PCM_HW_PARAM_SAMPLE_BITS, -1 },
- private: 0,
+ private_data: 0,
},
{
var: SND_PCM_HW_PARAM_RATE,
func: snd_pcm_hw_rule_mulkdiv,
deps: { SND_PCM_HW_PARAM_PERIOD_SIZE,
SND_PCM_HW_PARAM_PERIOD_TIME, -1 },
- private: (void*) 1000000,
+ private_data: (void*) 1000000,
},
{
var: SND_PCM_HW_PARAM_RATE,
func: snd_pcm_hw_rule_mulkdiv,
deps: { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_BUFFER_TIME, -1 },
- private: (void*) 1000000,
+ private_data: (void*) 1000000,
},
{
var: SND_PCM_HW_PARAM_PERIODS,
func: snd_pcm_hw_rule_div,
deps: { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_PERIOD_SIZE, -1 },
- private: 0,
+ private_data: 0,
},
{
var: SND_PCM_HW_PARAM_PERIOD_SIZE,
func: snd_pcm_hw_rule_div,
deps: { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_PERIODS, -1 },
- private: 0,
+ private_data: 0,
},
{
var: SND_PCM_HW_PARAM_PERIOD_SIZE,
func: snd_pcm_hw_rule_mulkdiv,
deps: { SND_PCM_HW_PARAM_PERIOD_BYTES,
SND_PCM_HW_PARAM_FRAME_BITS, -1 },
- private: (void*) 8,
+ private_data: (void*) 8,
},
{
var: SND_PCM_HW_PARAM_PERIOD_SIZE,
func: snd_pcm_hw_rule_muldivk,
deps: { SND_PCM_HW_PARAM_PERIOD_TIME,
SND_PCM_HW_PARAM_RATE, -1 },
- private: (void*) 1000000,
+ private_data: (void*) 1000000,
},
{
var: SND_PCM_HW_PARAM_BUFFER_SIZE,
func: snd_pcm_hw_rule_mul,
deps: { SND_PCM_HW_PARAM_PERIOD_SIZE,
SND_PCM_HW_PARAM_PERIODS, -1 },
- private: 0,
+ private_data: 0,
},
{
var: SND_PCM_HW_PARAM_BUFFER_SIZE,
func: snd_pcm_hw_rule_mulkdiv,
deps: { SND_PCM_HW_PARAM_BUFFER_BYTES,
SND_PCM_HW_PARAM_FRAME_BITS, -1 },
- private: (void*) 8,
+ private_data: (void*) 8,
},
{
var: SND_PCM_HW_PARAM_BUFFER_SIZE,
func: snd_pcm_hw_rule_muldivk,
deps: { SND_PCM_HW_PARAM_BUFFER_TIME,
SND_PCM_HW_PARAM_RATE, -1 },
- private: (void*) 1000000,
+ private_data: (void*) 1000000,
},
{
var: SND_PCM_HW_PARAM_PERIOD_BYTES,
func: snd_pcm_hw_rule_muldivk,
deps: { SND_PCM_HW_PARAM_PERIOD_SIZE,
SND_PCM_HW_PARAM_FRAME_BITS, -1 },
- private: (void*) 8,
+ private_data: (void*) 8,
},
{
var: SND_PCM_HW_PARAM_BUFFER_BYTES,
func: snd_pcm_hw_rule_muldivk,
deps: { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_FRAME_BITS, -1 },
- private: (void*) 8,
+ private_data: (void*) 8,
},
{
var: SND_PCM_HW_PARAM_PERIOD_TIME,
func: snd_pcm_hw_rule_mulkdiv,
deps: { SND_PCM_HW_PARAM_PERIOD_SIZE,
SND_PCM_HW_PARAM_RATE, -1 },
- private: (void*) 1000000,
+ private_data: (void*) 1000000,
},
{
var: SND_PCM_HW_PARAM_BUFFER_TIME,
func: snd_pcm_hw_rule_mulkdiv,
deps: { SND_PCM_HW_PARAM_BUFFER_SIZE,
SND_PCM_HW_PARAM_RATE, -1 },
- private: (void*) 1000000,
+ private_data: (void*) 1000000,
},
};
diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c
index a2e4d4e1..bd331591 100644
--- a/src/pcm/pcm_plug.c
+++ b/src/pcm/pcm_plug.c
@@ -32,7 +32,7 @@ typedef struct {
static int snd_pcm_plug_close(snd_pcm_t *pcm)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
int err, result = 0;
if (plug->ttable)
free(plug->ttable);
@@ -48,19 +48,19 @@ static int snd_pcm_plug_close(snd_pcm_t *pcm)
static int snd_pcm_plug_nonblock(snd_pcm_t *pcm, int nonblock)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
return snd_pcm_nonblock(plug->slave, nonblock);
}
static int snd_pcm_plug_async(snd_pcm_t *pcm, int sig, pid_t pid)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
return snd_pcm_async(plug->slave, sig, pid);
}
static int snd_pcm_plug_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
snd_pcm_t *slave = plug->req_slave;
int err;
@@ -183,7 +183,7 @@ static snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format, const
static void snd_pcm_plug_clear(snd_pcm_t *pcm)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
snd_pcm_t *slave = plug->req_slave;
/* Clear old plugins */
if (plug->slave != slave) {
@@ -203,7 +203,7 @@ typedef struct {
static int snd_pcm_plug_change_rate(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_plug_params_t *clt, snd_pcm_plug_params_t *slv)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
int err;
assert(snd_pcm_format_linear(slv->format));
if (clt->rate == slv->rate)
@@ -220,7 +220,7 @@ static int snd_pcm_plug_change_rate(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_plu
static int snd_pcm_plug_change_channels(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_plug_params_t *clt, snd_pcm_plug_params_t *slv)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
unsigned int tt_ssize, tt_cused, tt_sused;
snd_pcm_route_ttable_entry_t *ttable;
int err;
@@ -285,10 +285,10 @@ static int snd_pcm_plug_change_channels(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm
static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_plug_params_t *clt, snd_pcm_plug_params_t *slv)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
int err;
snd_pcm_format_t cfmt;
- int (*f)(snd_pcm_t **pcm, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
+ int (*f)(snd_pcm_t **pcm, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
if (snd_pcm_format_linear(slv->format)) {
/* Conversion is done in another plugin */
if (clt->format == slv->format ||
@@ -346,7 +346,7 @@ static int snd_pcm_plug_change_format(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_p
static int snd_pcm_plug_change_access(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_plug_params_t *clt, snd_pcm_plug_params_t *slv)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
int err;
if (clt->access == slv->access)
return 0;
@@ -361,7 +361,7 @@ static int snd_pcm_plug_insert_plugins(snd_pcm_t *pcm,
snd_pcm_plug_params_t *client,
snd_pcm_plug_params_t *slave)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
int (*funcs[])(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm_plug_params_t *s, snd_pcm_plug_params_t *d) = {
snd_pcm_plug_change_format,
snd_pcm_plug_change_channels,
@@ -408,7 +408,7 @@ static int snd_pcm_plug_hw_refine_sprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
snd_pcm_t *slave = plug->req_slave;
unsigned int links = (SND_PCM_HW_PARBIT_PERIOD_TIME |
SND_PCM_HW_PARBIT_TICK_TIME);
@@ -533,7 +533,7 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
static int snd_pcm_plug_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
return snd_pcm_hw_refine(plug->req_slave, params);
}
@@ -549,7 +549,7 @@ static int snd_pcm_plug_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_plug_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
snd_pcm_t *slave = plug->req_slave;
snd_pcm_plug_params_t clt_params, slv_params;
snd_pcm_hw_params_t sparams;
@@ -594,7 +594,7 @@ static int snd_pcm_plug_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_plug_hw_free(snd_pcm_t *pcm)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
snd_pcm_t *slave = plug->slave;
int err = snd_pcm_hw_free(slave);
snd_pcm_plug_clear(pcm);
@@ -603,13 +603,13 @@ static int snd_pcm_plug_hw_free(snd_pcm_t *pcm)
static int snd_pcm_plug_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
return snd_pcm_sw_params(plug->slave, params);
}
static int snd_pcm_plug_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
return snd_pcm_channel_info(plug->slave, info);
}
@@ -625,7 +625,7 @@ static int snd_pcm_plug_munmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
static void snd_pcm_plug_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_plug_t *plug = pcm->private;
+ snd_pcm_plug_t *plug = pcm->private_data;
snd_output_printf(out, "Plug PCM: ");
snd_pcm_dump(plug->slave, out);
}
@@ -679,7 +679,7 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp,
pcm->op_arg = pcm;
pcm->fast_ops = slave->fast_ops;
pcm->fast_op_arg = slave->fast_op_arg;
- pcm->private = plug;
+ pcm->private_data = plug;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = slave->hw_ptr;
pcm->appl_ptr = slave->appl_ptr;
@@ -704,14 +704,14 @@ 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;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
int err;
snd_pcm_t *spcm;
snd_config_t *tt = NULL;
snd_pcm_route_ttable_entry_t *ttable = NULL;
unsigned int cused, sused;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c
index af7ab11e..4d4c7774 100644
--- a/src/pcm/pcm_plugin.c
+++ b/src/pcm/pcm_plugin.c
@@ -26,7 +26,7 @@
int snd_pcm_plugin_close(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
int err = 0;
if (plugin->close_slave)
err = snd_pcm_close(plugin->slave);
@@ -36,43 +36,43 @@ int snd_pcm_plugin_close(snd_pcm_t *pcm)
int snd_pcm_plugin_nonblock(snd_pcm_t *pcm, int nonblock)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_nonblock(plugin->slave, nonblock);
}
int snd_pcm_plugin_async(snd_pcm_t *pcm, int sig, pid_t pid)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_async(plugin->slave, sig, pid);
}
int snd_pcm_plugin_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_info(plugin->slave, info);
}
int snd_pcm_plugin_hw_free(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_hw_free(plugin->slave);
}
int snd_pcm_plugin_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_sw_params(plugin->slave, params);
}
int snd_pcm_plugin_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_channel_info_shm(pcm, info, plugin->shmid);
}
int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
int err = snd_pcm_status(plugin->slave, status);
if (err < 0)
return err;
@@ -84,13 +84,13 @@ int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
snd_pcm_state_t snd_pcm_plugin_state(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_state(plugin->slave);
}
int snd_pcm_plugin_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
snd_pcm_sframes_t sd;
int err = snd_pcm_delay(plugin->slave, &sd);
if (err < 0)
@@ -103,7 +103,7 @@ int snd_pcm_plugin_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
int snd_pcm_plugin_prepare(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
int err = snd_pcm_prepare(plugin->slave);
if (err < 0)
return err;
@@ -119,7 +119,7 @@ int snd_pcm_plugin_prepare(snd_pcm_t *pcm)
int snd_pcm_plugin_reset(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
int err = snd_pcm_reset(plugin->slave);
if (err < 0)
return err;
@@ -135,31 +135,31 @@ int snd_pcm_plugin_reset(snd_pcm_t *pcm)
int snd_pcm_plugin_start(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_start(plugin->slave);
}
int snd_pcm_plugin_drop(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_drop(plugin->slave);
}
int snd_pcm_plugin_drain(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_drain(plugin->slave);
}
int snd_pcm_plugin_pause(snd_pcm_t *pcm, int enable)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_pause(plugin->slave, enable);
}
snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
snd_pcm_sframes_t n = snd_pcm_mmap_hw_avail(pcm);
assert(n >= 0);
if (n > 0) {
@@ -190,7 +190,7 @@ snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames
snd_pcm_sframes_t snd_pcm_plugin_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
snd_pcm_channel_area_t areas[pcm->channels];
snd_pcm_sframes_t frames;
snd_pcm_areas_from_buf(pcm, areas, (void*)buffer);
@@ -202,7 +202,7 @@ snd_pcm_sframes_t snd_pcm_plugin_writei(snd_pcm_t *pcm, const void *buffer, snd_
snd_pcm_sframes_t snd_pcm_plugin_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
snd_pcm_channel_area_t areas[pcm->channels];
snd_pcm_sframes_t frames;
snd_pcm_areas_from_bufs(pcm, areas, bufs);
@@ -214,7 +214,7 @@ snd_pcm_sframes_t snd_pcm_plugin_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_ufr
snd_pcm_sframes_t snd_pcm_plugin_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
snd_pcm_channel_area_t areas[pcm->channels];
snd_pcm_sframes_t frames;
snd_pcm_areas_from_buf(pcm, areas, buffer);
@@ -226,7 +226,7 @@ snd_pcm_sframes_t snd_pcm_plugin_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_ufr
snd_pcm_sframes_t snd_pcm_plugin_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
snd_pcm_channel_area_t areas[pcm->channels];
snd_pcm_sframes_t frames;
snd_pcm_areas_from_bufs(pcm, areas, bufs);
@@ -238,7 +238,7 @@ snd_pcm_sframes_t snd_pcm_plugin_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_ufra
snd_pcm_sframes_t snd_pcm_plugin_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t client_size)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
snd_pcm_t *slave = plugin->slave;
snd_pcm_uframes_t client_xfer = 0;
snd_pcm_uframes_t slave_xfer = 0;
@@ -275,7 +275,7 @@ snd_pcm_sframes_t snd_pcm_plugin_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t
snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
snd_pcm_t *slave = plugin->slave;
snd_pcm_uframes_t client_xfer;
snd_pcm_uframes_t slave_xfer = 0;
@@ -313,7 +313,7 @@ snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
int snd_pcm_plugin_mmap(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plug = pcm->private;
+ snd_pcm_plugin_t *plug = pcm->private_data;
size_t size = snd_pcm_frames_to_bytes(pcm, pcm->buffer_size);
int id = shmget(IPC_PRIVATE, size, 0666);
if (id < 0) {
@@ -326,7 +326,7 @@ int snd_pcm_plugin_mmap(snd_pcm_t *pcm)
int snd_pcm_plugin_munmap(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plug = pcm->private;
+ snd_pcm_plugin_t *plug = pcm->private_data;
if (shmctl(plug->shmid, IPC_RMID, 0) < 0) {
SYSERR("shmctl IPC_RMID failed");
return -errno;
@@ -336,19 +336,19 @@ int snd_pcm_plugin_munmap(snd_pcm_t *pcm)
int snd_pcm_plugin_poll_descriptor(snd_pcm_t *pcm)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_poll_descriptor(plugin->slave);
}
int snd_pcm_plugin_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return snd_pcm_hw_refine(plugin->slave, params);
}
int snd_pcm_plugin_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_plugin_t *plugin = pcm->private;
+ snd_pcm_plugin_t *plugin = pcm->private_data;
return _snd_pcm_hw_params(plugin->slave, params);
}
diff --git a/src/pcm/pcm_plugin.h b/src/pcm/pcm_plugin.h
index a7068683..a0856187 100644
--- a/src/pcm/pcm_plugin.h
+++ b/src/pcm/pcm_plugin.h
@@ -102,22 +102,22 @@ typedef int snd_pcm_route_ttable_entry_t;
int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format);
int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format);
int snd_pcm_linear_convert_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format);
-int snd_pcm_copy_open(snd_pcm_t **pcmp, char *name, snd_pcm_t *slave, int close_slave);
-int snd_pcm_linear_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
-int snd_pcm_mulaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
-int snd_pcm_alaw_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
-int snd_pcm_adpcm_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
+int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int close_slave);
+int snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
+int snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
+int snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
+int snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave);
int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *ttable,
unsigned int tt_csize, unsigned int tt_ssize,
unsigned int *tt_cused, unsigned int *tt_sused,
int schannels);
-int snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
+int snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_format_t sformat, unsigned int schannels,
snd_pcm_route_ttable_entry_t *ttable,
unsigned int tt_ssize,
unsigned int tt_cused, unsigned int tt_sused,
snd_pcm_t *slave, int close_slave);
-int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, int srate, snd_pcm_t *slave, int close_slave);
+int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, int srate, snd_pcm_t *slave, int close_slave);
#define SND_PCM_ACCBIT_PLUGIN ((1 << (unsigned long) SND_PCM_ACCESS_MMAP_INTERLEAVED) | \
diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c
index 6862e3e3..1709f4ad 100644
--- a/src/pcm/pcm_rate.c
+++ b/src/pcm/pcm_rate.c
@@ -83,7 +83,8 @@ snd_pcm_uframes_t snd_pcm_rate_expand(const snd_pcm_channel_area_t *dst_areas,
for (channel = 0; channel < channels; ++channel) {
const snd_pcm_channel_area_t *src_area = &src_areas[channel];
const snd_pcm_channel_area_t *dst_area = &dst_areas[channel];
- char *src, *dst;
+ const char *src;
+ char *dst;
int src_step, dst_step;
int16_t old_sample = states->sample;
unsigned int pos = states->pos;
@@ -167,7 +168,8 @@ snd_pcm_uframes_t snd_pcm_rate_shrink(const snd_pcm_channel_area_t *dst_areas,
const snd_pcm_channel_area_t *dst_area = &dst_areas[channel];
unsigned int pos;
int sum;
- char *src, *dst;
+ const char *src;
+ char *dst;
int src_step, dst_step;
sum = states->sum;
pos = states->pos;
@@ -253,7 +255,7 @@ static int snd_pcm_rate_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
static int snd_pcm_rate_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
_snd_pcm_hw_params_any(sparams);
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
@@ -270,7 +272,7 @@ static int snd_pcm_rate_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *
static int snd_pcm_rate_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
snd_interval_t t, buffer_size;
const snd_interval_t *srate, *crate;
int err;
@@ -299,7 +301,7 @@ static int snd_pcm_rate_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
static int snd_pcm_rate_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
snd_interval_t t;
const snd_interval_t *sbuffer_size;
const snd_interval_t *srate, *crate;
@@ -339,7 +341,7 @@ static int snd_pcm_rate_hw_refine(snd_pcm_t *pcm,
static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
snd_pcm_t *slave = rate->plug.slave;
snd_pcm_format_t src_format, dst_format;
unsigned int src_rate, dst_rate;
@@ -379,7 +381,7 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
static int snd_pcm_rate_hw_free(snd_pcm_t *pcm)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
if (rate->states) {
free(rate->states);
rate->states = 0;
@@ -389,7 +391,7 @@ static int snd_pcm_rate_hw_free(snd_pcm_t *pcm)
static int snd_pcm_rate_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
snd_pcm_t *slave = rate->plug.slave;
snd_pcm_sw_params_t sparams;
sparams = *params;
@@ -402,7 +404,7 @@ static int snd_pcm_rate_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
static int snd_pcm_rate_init(snd_pcm_t *pcm)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
unsigned int k;
for (k = 0; k < pcm->channels; ++k) {
rate->states[k].sum = 0;
@@ -423,7 +425,7 @@ static snd_pcm_sframes_t snd_pcm_rate_write_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t client_size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
snd_pcm_t *slave = rate->plug.slave;
snd_pcm_uframes_t client_xfer = 0;
snd_pcm_uframes_t slave_xfer = 0;
@@ -475,7 +477,7 @@ static snd_pcm_sframes_t snd_pcm_rate_read_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
snd_pcm_t *slave = rate->plug.slave;
snd_pcm_uframes_t client_xfer = 0;
snd_pcm_uframes_t slave_xfer = 0;
@@ -521,7 +523,7 @@ static snd_pcm_sframes_t snd_pcm_rate_read_areas(snd_pcm_t *pcm,
snd_pcm_sframes_t snd_pcm_rate_client_frames(snd_pcm_t *pcm, snd_pcm_sframes_t frames)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
/* Round toward zero */
if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
return muldiv_down(frames, DIV, rate->pitch);
@@ -531,7 +533,7 @@ snd_pcm_sframes_t snd_pcm_rate_client_frames(snd_pcm_t *pcm, snd_pcm_sframes_t f
snd_pcm_sframes_t snd_pcm_rate_slave_frames(snd_pcm_t *pcm, snd_pcm_sframes_t frames)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
/* Round toward zero */
if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
return muldiv_down(frames, rate->pitch, DIV);
@@ -541,7 +543,7 @@ snd_pcm_sframes_t snd_pcm_rate_slave_frames(snd_pcm_t *pcm, snd_pcm_sframes_t fr
static void snd_pcm_rate_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_rate_t *rate = pcm->private;
+ snd_pcm_rate_t *rate = pcm->private_data;
if (rate->sformat == SND_PCM_FORMAT_UNKNOWN)
snd_output_printf(out, "Rate conversion PCM (%d)\n",
rate->srate);
@@ -572,7 +574,7 @@ snd_pcm_ops_t snd_pcm_rate_ops = {
munmap: snd_pcm_plugin_munmap,
};
-int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, int srate, snd_pcm_t *slave, int close_slave)
+int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, int srate, snd_pcm_t *slave, int close_slave)
{
snd_pcm_t *pcm;
snd_pcm_rate_t *rate;
@@ -608,7 +610,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, in
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_plugin_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = rate;
+ pcm->private_data = rate;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = &rate->plug.hw_ptr;
pcm->appl_ptr = &rate->plug.appl_ptr;
@@ -617,17 +619,17 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, char *name, snd_pcm_format_t sformat, in
return 0;
}
-int _snd_pcm_rate_open(snd_pcm_t **pcmp, char *name,
+int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
int err;
snd_pcm_t *spcm;
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
long srate = -1;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
index 775a97f2..0145f499 100644
--- a/src/pcm/pcm_route.c
+++ b/src/pcm/pcm_route.c
@@ -118,7 +118,8 @@ void snd_pcm_route_convert1_one(const snd_pcm_channel_area_t *dst_area,
void *conv;
const snd_pcm_channel_area_t *src_area = 0;
unsigned int srcidx;
- char *src, *dst;
+ const char *src;
+ char *dst;
int src_step, dst_step;
for (srcidx = 0; srcidx < ttable->nsrcs; ++srcidx) {
src_area = &src_areas[ttable->srcs[srcidx].channel];
@@ -208,7 +209,7 @@ void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
int nsrcs = ttable->nsrcs;
char *dst;
int dst_step;
- char *srcs[nsrcs];
+ const char *srcs[nsrcs];
int src_steps[nsrcs];
snd_pcm_route_ttable_src_t src_tt[nsrcs];
u_int32_t sample = 0;
@@ -267,7 +268,7 @@ void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
#endif
zero_end:
for (srcidx = 0; srcidx < nsrcs; ++srcidx) {
- char *src = srcs[srcidx];
+ const char *src = srcs[srcidx];
/* Get sample */
goto *get;
@@ -418,7 +419,7 @@ void snd_pcm_route_convert(const snd_pcm_channel_area_t *dst_areas,
static int snd_pcm_route_close(snd_pcm_t *pcm)
{
- snd_pcm_route_t *route = pcm->private;
+ snd_pcm_route_t *route = pcm->private_data;
snd_pcm_route_params_t *params = &route->params;
int err = 0;
unsigned int dst_channel;
@@ -460,7 +461,7 @@ static int snd_pcm_route_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd
static int snd_pcm_route_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
{
- snd_pcm_route_t *route = pcm->private;
+ snd_pcm_route_t *route = pcm->private_data;
snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
_snd_pcm_hw_params_any(sparams);
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
@@ -479,7 +480,7 @@ static int snd_pcm_route_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
static int snd_pcm_route_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
- snd_pcm_route_t *route = pcm->private;
+ snd_pcm_route_t *route = pcm->private_data;
int err;
unsigned int links = (SND_PCM_HW_PARBIT_RATE |
SND_PCM_HW_PARBIT_PERIODS |
@@ -503,7 +504,7 @@ static int snd_pcm_route_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *
static int snd_pcm_route_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
snd_pcm_hw_params_t *sparams)
{
- snd_pcm_route_t *route = pcm->private;
+ snd_pcm_route_t *route = pcm->private_data;
int err;
unsigned int links = (SND_PCM_HW_PARBIT_RATE |
SND_PCM_HW_PARBIT_PERIODS |
@@ -536,7 +537,7 @@ static int snd_pcm_route_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
{
- snd_pcm_route_t *route = pcm->private;
+ snd_pcm_route_t *route = pcm->private_data;
snd_pcm_t *slave = route->plug.slave;
snd_pcm_format_t src_format, dst_format;
int err = snd_pcm_hw_params_slave(pcm, params,
@@ -576,7 +577,7 @@ static snd_pcm_sframes_t snd_pcm_route_write_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_route_t *route = pcm->private;
+ snd_pcm_route_t *route = pcm->private_data;
snd_pcm_t *slave = route->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -610,7 +611,7 @@ static snd_pcm_sframes_t snd_pcm_route_read_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size,
snd_pcm_uframes_t *slave_sizep)
{
- snd_pcm_route_t *route = pcm->private;
+ snd_pcm_route_t *route = pcm->private_data;
snd_pcm_t *slave = route->plug.slave;
snd_pcm_uframes_t xfer = 0;
snd_pcm_sframes_t err = 0;
@@ -640,7 +641,7 @@ static snd_pcm_sframes_t snd_pcm_route_read_areas(snd_pcm_t *pcm,
static void snd_pcm_route_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_route_t *route = pcm->private;
+ snd_pcm_route_t *route = pcm->private_data;
unsigned int dst;
if (route->sformat == SND_PCM_FORMAT_UNKNOWN)
snd_output_printf(out, "Route conversion PCM\n");
@@ -763,7 +764,7 @@ int route_load_ttable(snd_pcm_route_params_t *params, snd_pcm_stream_t stream,
}
-int snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
+int snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_format_t sformat, unsigned int schannels,
snd_pcm_route_ttable_entry_t *ttable,
unsigned int tt_ssize,
@@ -802,7 +803,7 @@ int snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_plugin_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = route;
+ pcm->private_data = route;
pcm->poll_fd = slave->poll_fd;
pcm->hw_ptr = &route->plug.hw_ptr;
pcm->appl_ptr = &route->plug.appl_ptr;
@@ -823,13 +824,13 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
{
int cused = -1;
int sused = -1;
- snd_config_iterator_t i;
+ snd_config_iterator_t i, inext;
unsigned int k;
for (k = 0; k < tt_csize * tt_ssize; ++k)
ttable[k] = 0.0;
- snd_config_foreach(i, tt) {
+ snd_config_for_each(i, inext, tt) {
snd_config_t *in = snd_config_iterator_entry(i);
- snd_config_iterator_t j;
+ snd_config_iterator_t j, jnext;
char *p;
long cchannel;
errno = 0;
@@ -841,7 +842,7 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
}
if (snd_config_get_type(in) != SND_CONFIG_TYPE_COMPOUND)
return -EINVAL;
- snd_config_foreach(j, in) {
+ snd_config_for_each(j, jnext, in) {
snd_config_t *jn = snd_config_iterator_entry(j);
double value;
long schannel;
@@ -879,11 +880,11 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
#define MAX_CHANNELS 32
-int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
+int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
int err;
snd_pcm_t *spcm;
@@ -892,7 +893,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, char *name,
snd_config_t *tt = NULL;
snd_pcm_route_ttable_entry_t ttable[MAX_CHANNELS*MAX_CHANNELS];
unsigned int cused, sused;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c
index f8f1d15b..00b535c1 100644
--- a/src/pcm/pcm_share.c
+++ b/src/pcm/pcm_share.c
@@ -188,7 +188,7 @@ static snd_pcm_uframes_t _snd_pcm_share_slave_forward(snd_pcm_share_slave_t *sla
*/
static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm, int slave_xrun)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_t *spcm = slave->pcm;
snd_pcm_uframes_t buffer_size = spcm->buffer_size;
@@ -394,7 +394,7 @@ void *snd_pcm_share_slave_thread(void *data)
static void _snd_pcm_share_update(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_t *spcm = slave->pcm;
snd_pcm_uframes_t missing;
@@ -434,7 +434,7 @@ static int snd_pcm_share_nonblock(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int nonblock
static int snd_pcm_share_async(snd_pcm_t *pcm, int sig, pid_t pid)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
if (sig)
share->async_sig = sig;
else
@@ -448,13 +448,13 @@ static int snd_pcm_share_async(snd_pcm_t *pcm, int sig, pid_t pid)
static int snd_pcm_share_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
return snd_pcm_info(share->slave->pcm, info);
}
static int snd_pcm_share_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_access_mask_t access_mask;
int err;
@@ -486,7 +486,7 @@ static int snd_pcm_share_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
static int snd_pcm_share_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
_snd_pcm_hw_params_any(sparams);
@@ -562,13 +562,13 @@ static int snd_pcm_share_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
static int snd_pcm_share_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
return snd_pcm_hw_refine(share->slave->pcm, params);
}
static int snd_pcm_share_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
return _snd_pcm_hw_params(share->slave->pcm, params);
}
@@ -584,7 +584,7 @@ static int snd_pcm_share_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_t *spcm = slave->pcm;
int err = 0;
@@ -643,7 +643,7 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_share_hw_free(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
Pthread_mutex_lock(&slave->mutex);
@@ -662,7 +662,7 @@ static int snd_pcm_share_sw_params(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_p
static int snd_pcm_share_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
snd_pcm_sframes_t sd = 0, d = 0;
@@ -693,13 +693,13 @@ static int snd_pcm_share_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
static snd_pcm_state_t snd_pcm_share_state(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
return share->state;
}
static int _snd_pcm_share_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
snd_pcm_sframes_t sd;
@@ -724,7 +724,7 @@ static int _snd_pcm_share_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
static int snd_pcm_share_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err;
Pthread_mutex_lock(&slave->mutex);
@@ -735,7 +735,7 @@ static int snd_pcm_share_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
static snd_pcm_sframes_t snd_pcm_share_avail_update(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_sframes_t avail;
Pthread_mutex_lock(&slave->mutex);
@@ -757,7 +757,7 @@ static snd_pcm_sframes_t snd_pcm_share_avail_update(snd_pcm_t *pcm)
/* Call it with mutex held */
static snd_pcm_sframes_t _snd_pcm_share_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t size)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_sframes_t ret = 0;
snd_pcm_sframes_t frames;
@@ -790,7 +790,7 @@ static snd_pcm_sframes_t _snd_pcm_share_mmap_forward(snd_pcm_t *pcm, snd_pcm_ufr
static snd_pcm_sframes_t snd_pcm_share_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t size)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_sframes_t ret;
Pthread_mutex_lock(&slave->mutex);
@@ -801,7 +801,7 @@ static snd_pcm_sframes_t snd_pcm_share_mmap_forward(snd_pcm_t *pcm, snd_pcm_ufra
static int snd_pcm_share_prepare(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
Pthread_mutex_lock(&slave->mutex);
@@ -821,7 +821,7 @@ static int snd_pcm_share_prepare(snd_pcm_t *pcm)
static int snd_pcm_share_reset(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
/* FIXME? */
@@ -835,7 +835,7 @@ static int snd_pcm_share_reset(snd_pcm_t *pcm)
static int snd_pcm_share_start(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
if (share->state != SND_PCM_STATE_PREPARED)
@@ -897,7 +897,7 @@ static int snd_pcm_share_pause(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int enable ATTRI
static int snd_pcm_share_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
unsigned int channel = info->channel;
int c = share->slave_channels[channel];
@@ -910,7 +910,7 @@ static int snd_pcm_share_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *in
static snd_pcm_sframes_t _snd_pcm_share_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_sframes_t n;
switch (snd_enum_to_int(share->state)) {
@@ -950,7 +950,7 @@ static snd_pcm_sframes_t _snd_pcm_share_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t
static snd_pcm_sframes_t snd_pcm_share_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_sframes_t ret;
Pthread_mutex_lock(&slave->mutex);
@@ -962,7 +962,7 @@ static snd_pcm_sframes_t snd_pcm_share_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t
/* Warning: take the mutex before to call this */
static void _snd_pcm_share_stop(snd_pcm_t *pcm, snd_pcm_state_t state)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
if (!pcm->mmap_channels) {
/* PCM closing already begun in the main thread */
@@ -995,7 +995,7 @@ static void _snd_pcm_share_stop(snd_pcm_t *pcm, snd_pcm_state_t state)
static int snd_pcm_share_drain(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
Pthread_mutex_lock(&slave->mutex);
@@ -1053,7 +1053,7 @@ static int snd_pcm_share_drain(snd_pcm_t *pcm)
static int snd_pcm_share_drop(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
Pthread_mutex_lock(&slave->mutex);
@@ -1090,7 +1090,7 @@ static int snd_pcm_share_drop(snd_pcm_t *pcm)
static int snd_pcm_share_close(snd_pcm_t *pcm)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
int err = 0;
Pthread_mutex_lock(&slaves_mutex);
@@ -1131,7 +1131,7 @@ static int snd_pcm_share_munmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
static void snd_pcm_share_dump(snd_pcm_t *pcm, snd_output_t *out)
{
- snd_pcm_share_t *share = pcm->private;
+ snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
unsigned int k;
snd_output_printf(out, "Share PCM\n");
@@ -1344,7 +1344,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname,
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_share_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = share;
+ pcm->private_data = share;
pcm->poll_fd = share->client_socket;
pcm->hw_ptr = &share->hw_ptr;
pcm->appl_ptr = &share->appl_ptr;
@@ -1358,10 +1358,10 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname,
return 0;
}
-int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
+int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *sname = NULL;
snd_config_t *binding = NULL;
int err;
@@ -1373,7 +1373,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
snd_pcm_format_t sformat = SND_PCM_FORMAT_UNKNOWN;
long srate = -1;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
@@ -1437,7 +1437,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
ERR("binding is not defined");
return -EINVAL;
}
- snd_config_foreach(i, binding) {
+ snd_config_for_each(i, next, binding) {
int cchannel = -1;
char *p;
snd_config_t *n = snd_config_iterator_entry(i);
@@ -1459,7 +1459,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
for (idx = 0; idx < channels_count; ++idx)
channels_map[idx] = -1;
- snd_config_foreach(i, binding) {
+ snd_config_for_each(i, next, binding) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
long cchannel;
diff --git a/src/pcm/pcm_shm.c b/src/pcm/pcm_shm.c
index df785a19..8581f934 100644
--- a/src/pcm/pcm_shm.c
+++ b/src/pcm/pcm_shm.c
@@ -79,7 +79,7 @@ int receive_fd(int socket, void *data, size_t len, int *fd)
static int snd_pcm_shm_action(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
int err;
char buf[1];
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
@@ -98,7 +98,7 @@ static int snd_pcm_shm_action(snd_pcm_t *pcm)
static int snd_pcm_shm_action_fd(snd_pcm_t *pcm, int *fd)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
int err;
char buf[1];
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
@@ -122,7 +122,7 @@ static int snd_pcm_shm_nonblock(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int nonblock AT
static int snd_pcm_shm_async(snd_pcm_t *pcm, int sig, pid_t pid)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SND_PCM_IOCTL_ASYNC;
ctrl->u.async.sig = sig;
@@ -134,7 +134,7 @@ static int snd_pcm_shm_async(snd_pcm_t *pcm, int sig, pid_t pid)
static int snd_pcm_shm_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
// ctrl->u.info = *info;
@@ -201,7 +201,7 @@ static int snd_pcm_shm_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pc
static int snd_pcm_shm_hw_refine_slave(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.hw_refine = *params;
@@ -224,7 +224,7 @@ static int snd_pcm_shm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
static int snd_pcm_shm_hw_params_slave(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->cmd = SNDRV_PCM_IOCTL_HW_PARAMS;
@@ -245,7 +245,7 @@ static int snd_pcm_shm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
static int snd_pcm_shm_hw_free(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SNDRV_PCM_IOCTL_HW_FREE;
return snd_pcm_shm_action(pcm);
@@ -253,7 +253,7 @@ static int snd_pcm_shm_hw_free(snd_pcm_t *pcm)
static int snd_pcm_shm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->cmd = SNDRV_PCM_IOCTL_SW_PARAMS;
@@ -300,7 +300,7 @@ static int snd_pcm_shm_munmap(snd_pcm_t *pcm)
static int snd_pcm_shm_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
int fd;
@@ -326,7 +326,7 @@ static int snd_pcm_shm_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * inf
static int snd_pcm_shm_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->cmd = SNDRV_PCM_IOCTL_STATUS;
@@ -340,7 +340,7 @@ static int snd_pcm_shm_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
static snd_pcm_state_t snd_pcm_shm_state(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SND_PCM_IOCTL_STATE;
return snd_int_to_enum(snd_pcm_shm_action(pcm));
@@ -348,7 +348,7 @@ static snd_pcm_state_t snd_pcm_shm_state(snd_pcm_t *pcm)
static int snd_pcm_shm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->cmd = SNDRV_PCM_IOCTL_DELAY;
@@ -361,7 +361,7 @@ static int snd_pcm_shm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
static snd_pcm_sframes_t snd_pcm_shm_avail_update(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->cmd = SND_PCM_IOCTL_AVAIL_UPDATE;
@@ -373,7 +373,7 @@ static snd_pcm_sframes_t snd_pcm_shm_avail_update(snd_pcm_t *pcm)
static int snd_pcm_shm_prepare(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SNDRV_PCM_IOCTL_PREPARE;
return snd_pcm_shm_action(pcm);
@@ -381,7 +381,7 @@ static int snd_pcm_shm_prepare(snd_pcm_t *pcm)
static int snd_pcm_shm_reset(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SNDRV_PCM_IOCTL_RESET;
return snd_pcm_shm_action(pcm);
@@ -389,7 +389,7 @@ static int snd_pcm_shm_reset(snd_pcm_t *pcm)
static int snd_pcm_shm_start(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SNDRV_PCM_IOCTL_START;
return snd_pcm_shm_action(pcm);
@@ -397,7 +397,7 @@ static int snd_pcm_shm_start(snd_pcm_t *pcm)
static int snd_pcm_shm_drop(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SNDRV_PCM_IOCTL_DROP;
return snd_pcm_shm_action(pcm);
@@ -405,7 +405,7 @@ static int snd_pcm_shm_drop(snd_pcm_t *pcm)
static int snd_pcm_shm_drain(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->cmd = SNDRV_PCM_IOCTL_DRAIN;
@@ -419,7 +419,7 @@ static int snd_pcm_shm_drain(snd_pcm_t *pcm)
static int snd_pcm_shm_pause(snd_pcm_t *pcm, int enable)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SNDRV_PCM_IOCTL_PAUSE;
ctrl->u.pause.enable = enable;
@@ -428,7 +428,7 @@ static int snd_pcm_shm_pause(snd_pcm_t *pcm, int enable)
static snd_pcm_sframes_t snd_pcm_shm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SNDRV_PCM_IOCTL_REWIND;
ctrl->u.rewind.frames = frames;
@@ -437,7 +437,7 @@ static snd_pcm_sframes_t snd_pcm_shm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t fr
static snd_pcm_sframes_t snd_pcm_shm_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframes_t size)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SND_PCM_IOCTL_MMAP_FORWARD;
ctrl->u.mmap_forward.frames = size;
@@ -446,7 +446,7 @@ static snd_pcm_sframes_t snd_pcm_shm_mmap_forward(snd_pcm_t *pcm, snd_pcm_uframe
static int snd_pcm_shm_poll_descriptor(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int fd, err;
ctrl->cmd = SND_PCM_IOCTL_POLL_DESCRIPTOR;
@@ -458,7 +458,7 @@ static int snd_pcm_shm_poll_descriptor(snd_pcm_t *pcm)
static int snd_pcm_shm_close(snd_pcm_t *pcm)
{
- snd_pcm_shm_t *shm = pcm->private;
+ snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
int result;
ctrl->cmd = SND_PCM_IOCTL_CLOSE;
@@ -650,7 +650,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, const char *socket, con
pcm->op_arg = pcm;
pcm->fast_ops = &snd_pcm_shm_fast_ops;
pcm->fast_op_arg = pcm;
- pcm->private = shm;
+ pcm->private_data = shm;
err = snd_pcm_shm_poll_descriptor(pcm);
if (err < 0) {
snd_pcm_close(pcm);
@@ -716,10 +716,10 @@ int is_local(struct hostent *hent)
return i < numreqs;
}
-int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
+int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
snd_pcm_stream_t stream, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *server = NULL;
const char *sname = NULL;
snd_config_t *sconfig;
@@ -729,7 +729,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
int err;
int local;
struct hostent *h;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
@@ -768,7 +768,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, char *name, snd_config_t *conf,
ERR("Unknown server %s", server);
return -EINVAL;
}
- snd_config_foreach(i, sconfig) {
+ snd_config_for_each(i, next, sconfig) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c
index 65f6e737..32f608a7 100644
--- a/src/rawmidi/rawmidi.c
+++ b/src/rawmidi/rawmidi.c
@@ -28,6 +28,18 @@
#include <asm/page.h>
#include "rawmidi_local.h"
+const char *snd_rawmidi_name(snd_rawmidi_t *rawmidi)
+{
+ assert(rawmidi);
+ return rawmidi->name;
+}
+
+snd_rawmidi_type_t snd_rawmidi_type(snd_rawmidi_t *rawmidi)
+{
+ assert(rawmidi);
+ return rawmidi->type;
+}
+
int snd_rawmidi_close(snd_rawmidi_t *rmidi)
{
int err;
@@ -137,16 +149,16 @@ int snd_rawmidi_params_default(snd_rawmidi_t *rmidi, snd_rawmidi_params_t *param
}
int snd_rawmidi_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
- char *name, int mode)
+ const char *name, int mode)
{
const char *str;
int err;
snd_config_t *rawmidi_conf, *conf, *type_conf;
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
snd_rawmidi_params_t params;
const char *lib = NULL, *open = NULL;
int (*open_func)(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
- char *name, snd_config_t *conf, int mode);
+ const char *name, snd_config_t *conf, int mode);
void *h;
assert((inputp || outputp) && name);
err = snd_config_update();
@@ -183,7 +195,7 @@ int snd_rawmidi_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
ERR("Unknown RAWMIDI type %s", str);
return err;
}
- snd_config_foreach(i, type_conf) {
+ snd_config_for_each(i, next, type_conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c
index 112a4c2d..ec0b5e7d 100644
--- a/src/rawmidi/rawmidi_hw.c
+++ b/src/rawmidi/rawmidi_hw.c
@@ -40,7 +40,7 @@ typedef struct {
static int snd_rawmidi_hw_close(snd_rawmidi_t *rmidi)
{
- snd_rawmidi_hw_t *hw = rmidi->private;
+ snd_rawmidi_hw_t *hw = rmidi->private_data;
hw->open--;
if (hw->open)
return 0;
@@ -54,7 +54,7 @@ static int snd_rawmidi_hw_close(snd_rawmidi_t *rmidi)
static int snd_rawmidi_hw_nonblock(snd_rawmidi_t *rmidi, int nonblock)
{
- snd_rawmidi_hw_t *hw = rmidi->private;
+ snd_rawmidi_hw_t *hw = rmidi->private_data;
long flags;
if ((flags = fcntl(hw->fd, F_GETFL)) < 0) {
@@ -74,7 +74,7 @@ static int snd_rawmidi_hw_nonblock(snd_rawmidi_t *rmidi, int nonblock)
static int snd_rawmidi_hw_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info)
{
- snd_rawmidi_hw_t *hw = rmidi->private;
+ snd_rawmidi_hw_t *hw = rmidi->private_data;
info->stream = snd_enum_to_int(rmidi->stream);
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_INFO, info) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_INFO failed");
@@ -85,7 +85,7 @@ static int snd_rawmidi_hw_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info)
static int snd_rawmidi_hw_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params)
{
- snd_rawmidi_hw_t *hw = rmidi->private;
+ snd_rawmidi_hw_t *hw = rmidi->private_data;
params->stream = snd_enum_to_int(rmidi->stream);
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_PARAMS, params) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_PARAMS failed");
@@ -96,7 +96,7 @@ static int snd_rawmidi_hw_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * pa
static int snd_rawmidi_hw_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * status)
{
- snd_rawmidi_hw_t *hw = rmidi->private;
+ snd_rawmidi_hw_t *hw = rmidi->private_data;
status->stream = snd_enum_to_int(rmidi->stream);
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_STATUS, status) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_STATUS failed");
@@ -107,7 +107,7 @@ static int snd_rawmidi_hw_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * st
static int snd_rawmidi_hw_drop(snd_rawmidi_t *rmidi)
{
- snd_rawmidi_hw_t *hw = rmidi->private;
+ snd_rawmidi_hw_t *hw = rmidi->private_data;
int str = snd_enum_to_int(rmidi->stream);
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DROP, &str) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_DROP failed");
@@ -118,7 +118,7 @@ static int snd_rawmidi_hw_drop(snd_rawmidi_t *rmidi)
static int snd_rawmidi_hw_drain(snd_rawmidi_t *rmidi)
{
- snd_rawmidi_hw_t *hw = rmidi->private;
+ snd_rawmidi_hw_t *hw = rmidi->private_data;
int str = snd_enum_to_int(rmidi->stream);
if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DRAIN, &str) < 0) {
SYSERR("SNDRV_RAWMIDI_IOCTL_DRAIN failed");
@@ -129,7 +129,7 @@ static int snd_rawmidi_hw_drain(snd_rawmidi_t *rmidi)
static ssize_t snd_rawmidi_hw_write(snd_rawmidi_t *rmidi, const void *buffer, size_t size)
{
- snd_rawmidi_hw_t *hw = rmidi->private;
+ snd_rawmidi_hw_t *hw = rmidi->private_data;
ssize_t result;
result = write(hw->fd, buffer, size);
if (result < 0)
@@ -139,7 +139,7 @@ static ssize_t snd_rawmidi_hw_write(snd_rawmidi_t *rmidi, const void *buffer, si
static ssize_t snd_rawmidi_hw_read(snd_rawmidi_t *rmidi, void *buffer, size_t size)
{
- snd_rawmidi_hw_t *hw = rmidi->private;
+ snd_rawmidi_hw_t *hw = rmidi->private_data;
ssize_t result;
result = read(hw->fd, buffer, size);
if (result < 0)
@@ -161,7 +161,7 @@ snd_rawmidi_ops_t snd_rawmidi_hw_ops = {
int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
- char *name, int card, int device, int subdevice,
+ const char *name, int card, int device, int subdevice,
int mode)
{
int fd, ver, ret;
@@ -266,7 +266,7 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
rmidi->mode = mode;
rmidi->poll_fd = fd;
rmidi->ops = &snd_rawmidi_hw_ops;
- rmidi->private = hw;
+ rmidi->private_data = hw;
hw->open++;
*inputp = rmidi;
}
@@ -281,7 +281,7 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
rmidi->mode = mode;
rmidi->poll_fd = fd;
rmidi->ops = &snd_rawmidi_hw_ops;
- rmidi->private = hw;
+ rmidi->private_data = hw;
hw->open++;
*outputp = rmidi;
}
@@ -301,11 +301,11 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
int _snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
char *name, snd_config_t *conf, int mode)
{
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
long card = -1, device = 0, subdevice = -1;
const char *str;
int err;
- snd_config_foreach(i, conf) {
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/rawmidi/rawmidi_local.h b/src/rawmidi/rawmidi_local.h
index 0fa46eaa..18016909 100644
--- a/src/rawmidi/rawmidi_local.h
+++ b/src/rawmidi/rawmidi_local.h
@@ -45,7 +45,7 @@ struct _snd_rawmidi {
int mode;
int poll_fd;
snd_rawmidi_ops_t *ops;
- void *private;
+ void *private_data;
size_t buffer_size;
size_t avail_min;
unsigned int no_active_sensing: 1;
@@ -53,6 +53,6 @@ struct _snd_rawmidi {
};
int snd_rawmidi_hw_open(snd_rawmidi_t **input, snd_rawmidi_t **output,
- char *name, int card, int device, int subdevice,
+ const char *name, int card, int device, int subdevice,
int mode);
diff --git a/src/seq/seq.c b/src/seq/seq.c
index 27a200bb..e45aa985 100644
--- a/src/seq/seq.c
+++ b/src/seq/seq.c
@@ -24,15 +24,27 @@
#include <dlfcn.h>
#include "seq_local.h"
-int snd_seq_open(snd_seq_t **seqp, char *name,
+const char *snd_seq_name(snd_seq_t *seq)
+{
+ assert(seq);
+ return seq->name;
+}
+
+snd_seq_type_t snd_seq_type(snd_seq_t *seq)
+{
+ assert(seq);
+ return seq->type;
+}
+
+int snd_seq_open(snd_seq_t **seqp, const char *name,
int streams, int mode)
{
const char *str;
int err;
snd_config_t *seq_conf, *conf, *type_conf;
- snd_config_iterator_t i;
+ snd_config_iterator_t i, next;
const char *lib = NULL, *open = NULL;
- int (*open_func)(snd_seq_t **seqp, char *name, snd_config_t *conf,
+ int (*open_func)(snd_seq_t **seqp, const char *name, snd_config_t *conf,
int streams, int mode);
void *h;
assert(seqp && name);
@@ -65,7 +77,7 @@ int snd_seq_open(snd_seq_t **seqp, char *name,
ERR("Unknown SEQ type %s", str);
return err;
}
- snd_config_foreach(i, type_conf) {
+ snd_config_for_each(i, next, type_conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
@@ -426,7 +438,7 @@ int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info)
return info->queue;
}
-int snd_seq_alloc_named_queue(snd_seq_t *seq, char *name)
+int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name)
{
snd_seq_queue_info_t info;
memset(&info, 0, sizeof(info));
@@ -477,7 +489,7 @@ int snd_seq_set_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info)
return seq->ops->set_queue_info(seq, info);
}
-int snd_seq_get_named_queue(snd_seq_t *seq, char *name)
+int snd_seq_get_named_queue(snd_seq_t *seq, const char *name)
{
int err;
snd_seq_queue_info_t info;
diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c
index d9e1b9f1..c4a2c10a 100644
--- a/src/seq/seq_hw.c
+++ b/src/seq/seq_hw.c
@@ -34,7 +34,7 @@ typedef struct {
static int snd_seq_hw_close(snd_seq_t *seq)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (close(hw->fd)) {
SYSERR("close failed\n");
return -errno;
@@ -45,7 +45,7 @@ static int snd_seq_hw_close(snd_seq_t *seq)
static int snd_seq_hw_nonblock(snd_seq_t *seq, int nonblock)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
long flags;
if ((flags = fcntl(hw->fd, F_GETFL)) < 0) {
@@ -65,7 +65,7 @@ static int snd_seq_hw_nonblock(snd_seq_t *seq, int nonblock)
static int snd_seq_hw_client_id(snd_seq_t *seq)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
int client;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_CLIENT_ID, &client) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_CLIENT_ID failed");
@@ -76,7 +76,7 @@ static int snd_seq_hw_client_id(snd_seq_t *seq)
static int snd_seq_hw_system_info(snd_seq_t *seq, snd_seq_system_info_t * info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SYSTEM_INFO, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SYSTEM_INFO failed");
return -errno;
@@ -86,7 +86,7 @@ static int snd_seq_hw_system_info(snd_seq_t *seq, snd_seq_system_info_t * info)
static int snd_seq_hw_get_client_info(snd_seq_t *seq, snd_seq_client_info_t * info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_CLIENT_INFO, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_CLIENT_INFO failed");
return -errno;
@@ -96,7 +96,7 @@ static int snd_seq_hw_get_client_info(snd_seq_t *seq, snd_seq_client_info_t * in
static int snd_seq_hw_set_client_info(snd_seq_t *seq, snd_seq_client_info_t * info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SET_CLIENT_INFO failed");
return -errno;
@@ -106,7 +106,7 @@ static int snd_seq_hw_set_client_info(snd_seq_t *seq, snd_seq_client_info_t * in
static int snd_seq_hw_create_port(snd_seq_t *seq, snd_seq_port_info_t * port)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_CREATE_PORT, port) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_CREATE_PORT failed");
return -errno;
@@ -116,7 +116,7 @@ static int snd_seq_hw_create_port(snd_seq_t *seq, snd_seq_port_info_t * port)
static int snd_seq_hw_delete_port(snd_seq_t *seq, snd_seq_port_info_t * port)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_DELETE_PORT, port) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_DELETE_PORT failed");
return -errno;
@@ -126,7 +126,7 @@ static int snd_seq_hw_delete_port(snd_seq_t *seq, snd_seq_port_info_t * port)
static int snd_seq_hw_get_port_info(snd_seq_t *seq, snd_seq_port_info_t * info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_PORT_INFO, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_PORT_INFO failed");
return -errno;
@@ -136,7 +136,7 @@ static int snd_seq_hw_get_port_info(snd_seq_t *seq, snd_seq_port_info_t * info)
static int snd_seq_hw_set_port_info(snd_seq_t *seq, snd_seq_port_info_t * info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SET_PORT_INFO, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SET_PORT_INFO failed");
return -errno;
@@ -146,7 +146,7 @@ static int snd_seq_hw_set_port_info(snd_seq_t *seq, snd_seq_port_info_t * info)
static int snd_seq_hw_get_port_subscription(snd_seq_t *seq, snd_seq_port_subscribe_t * sub)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION, sub) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION failed");
return -errno;
@@ -156,7 +156,7 @@ static int snd_seq_hw_get_port_subscription(snd_seq_t *seq, snd_seq_port_subscri
static int snd_seq_hw_subscribe_port(snd_seq_t *seq, snd_seq_port_subscribe_t * sub)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT, sub) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT failed");
return -errno;
@@ -166,7 +166,7 @@ static int snd_seq_hw_subscribe_port(snd_seq_t *seq, snd_seq_port_subscribe_t *
static int snd_seq_hw_unsubscribe_port(snd_seq_t *seq, snd_seq_port_subscribe_t * sub)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT, sub) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT failed");
return -errno;
@@ -176,7 +176,7 @@ static int snd_seq_hw_unsubscribe_port(snd_seq_t *seq, snd_seq_port_subscribe_t
static int snd_seq_hw_query_port_subscribers(snd_seq_t *seq, snd_seq_query_subs_t * subs)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_QUERY_SUBS, subs) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_QUERY_SUBS failed");
return -errno;
@@ -186,7 +186,7 @@ static int snd_seq_hw_query_port_subscribers(snd_seq_t *seq, snd_seq_query_subs_
static int snd_seq_hw_get_queue_status(snd_seq_t *seq, snd_seq_queue_status_t * status)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS, status) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS failed");
return -errno;
@@ -196,7 +196,7 @@ static int snd_seq_hw_get_queue_status(snd_seq_t *seq, snd_seq_queue_status_t *
static int snd_seq_hw_get_queue_tempo(snd_seq_t *seq, snd_seq_queue_tempo_t * tempo)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO, tempo) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO failed");
return -errno;
@@ -206,7 +206,7 @@ static int snd_seq_hw_get_queue_tempo(snd_seq_t *seq, snd_seq_queue_tempo_t * te
static int snd_seq_hw_set_queue_tempo(snd_seq_t *seq, snd_seq_queue_tempo_t * tempo)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO, tempo) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO failed");
return -errno;
@@ -216,7 +216,7 @@ static int snd_seq_hw_set_queue_tempo(snd_seq_t *seq, snd_seq_queue_tempo_t * te
static int snd_seq_hw_get_queue_owner(snd_seq_t *seq, snd_seq_queue_owner_t * owner)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER, owner) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER failed");
return -errno;
@@ -226,7 +226,7 @@ static int snd_seq_hw_get_queue_owner(snd_seq_t *seq, snd_seq_queue_owner_t * ow
static int snd_seq_hw_set_queue_owner(snd_seq_t *seq, snd_seq_queue_owner_t * owner)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER, owner) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER failed");
return -errno;
@@ -236,7 +236,7 @@ static int snd_seq_hw_set_queue_owner(snd_seq_t *seq, snd_seq_queue_owner_t * ow
static int snd_seq_hw_get_queue_timer(snd_seq_t *seq, snd_seq_queue_timer_t * timer)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER, timer) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER failed");
return -errno;
@@ -246,7 +246,7 @@ static int snd_seq_hw_get_queue_timer(snd_seq_t *seq, snd_seq_queue_timer_t * ti
static int snd_seq_hw_set_queue_timer(snd_seq_t *seq, snd_seq_queue_timer_t * timer)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER, timer) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER failed");
return -errno;
@@ -256,7 +256,7 @@ static int snd_seq_hw_set_queue_timer(snd_seq_t *seq, snd_seq_queue_timer_t * ti
static int snd_seq_hw_get_queue_client(snd_seq_t *seq, snd_seq_queue_client_t * info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT failed");
return -errno;
@@ -266,7 +266,7 @@ static int snd_seq_hw_get_queue_client(snd_seq_t *seq, snd_seq_queue_client_t *
static int snd_seq_hw_set_queue_client(snd_seq_t *seq, snd_seq_queue_client_t * info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT failed");
return -errno;
@@ -276,7 +276,7 @@ static int snd_seq_hw_set_queue_client(snd_seq_t *seq, snd_seq_queue_client_t *
static int snd_seq_hw_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_CREATE_QUEUE, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_CREATE_QUEUE failed");
return -errno;
@@ -286,7 +286,7 @@ static int snd_seq_hw_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info)
static int snd_seq_hw_delete_queue(snd_seq_t *seq, snd_seq_queue_info_t *info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_DELETE_QUEUE, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_DELETE_QUEUE failed");
return -errno;
@@ -296,7 +296,7 @@ static int snd_seq_hw_delete_queue(snd_seq_t *seq, snd_seq_queue_info_t *info)
static int snd_seq_hw_get_queue_info(snd_seq_t *seq, snd_seq_queue_info_t *info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_QUEUE_INFO, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_QUEUE_INFO failed");
return -errno;
@@ -306,7 +306,7 @@ static int snd_seq_hw_get_queue_info(snd_seq_t *seq, snd_seq_queue_info_t *info)
static int snd_seq_hw_set_queue_info(snd_seq_t *seq, snd_seq_queue_info_t *info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SET_QUEUE_INFO, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SET_QUEUE_INFO failed");
return -errno;
@@ -316,7 +316,7 @@ static int snd_seq_hw_set_queue_info(snd_seq_t *seq, snd_seq_queue_info_t *info)
static int snd_seq_hw_get_named_queue(snd_seq_t *seq, snd_seq_queue_info_t *info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE failed");
return -errno;
@@ -326,7 +326,7 @@ static int snd_seq_hw_get_named_queue(snd_seq_t *seq, snd_seq_queue_info_t *info
static ssize_t snd_seq_hw_write(snd_seq_t *seq, void *buf, size_t len)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
ssize_t result = write(hw->fd, buf, len);
if (result < 0)
return -errno;
@@ -335,7 +335,7 @@ static ssize_t snd_seq_hw_write(snd_seq_t *seq, void *buf, size_t len)
static ssize_t snd_seq_hw_read(snd_seq_t *seq, void *buf, size_t len)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
ssize_t result = read(hw->fd, buf, len);
if (result < 0)
return -errno;
@@ -344,7 +344,7 @@ static ssize_t snd_seq_hw_read(snd_seq_t *seq, void *buf, size_t len)
static int snd_seq_hw_remove_events(snd_seq_t *seq, snd_seq_remove_events_t *rmp)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_REMOVE_EVENTS, rmp) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_REMOVE_EVENTS failed");
return -errno;
@@ -354,7 +354,7 @@ static int snd_seq_hw_remove_events(snd_seq_t *seq, snd_seq_remove_events_t *rmp
static int snd_seq_hw_get_client_pool(snd_seq_t *seq, snd_seq_client_pool_t *info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_GET_CLIENT_POOL, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_GET_CLIENT_POOL failed");
return -errno;
@@ -364,7 +364,7 @@ static int snd_seq_hw_get_client_pool(snd_seq_t *seq, snd_seq_client_pool_t *inf
static int snd_seq_hw_set_client_pool(snd_seq_t *seq, snd_seq_client_pool_t *info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SET_CLIENT_POOL, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_SET_CLIENT_POOL failed");
return -errno;
@@ -374,7 +374,7 @@ static int snd_seq_hw_set_client_pool(snd_seq_t *seq, snd_seq_client_pool_t *inf
static int snd_seq_hw_query_next_client(snd_seq_t *seq, snd_seq_client_info_t *info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT failed");
return -errno;
@@ -384,7 +384,7 @@ static int snd_seq_hw_query_next_client(snd_seq_t *seq, snd_seq_client_info_t *i
static int snd_seq_hw_query_next_port(snd_seq_t *seq, snd_seq_port_info_t *info)
{
- snd_seq_hw_t *hw = seq->private;
+ snd_seq_hw_t *hw = seq->private_data;
if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT, info) < 0) {
SYSERR("SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT failed");
return -errno;
@@ -429,7 +429,7 @@ snd_seq_ops_t snd_seq_hw_ops = {
query_next_port: snd_seq_hw_query_next_port,
};
-int snd_seq_hw_open(snd_seq_t **handle, char *name, int streams, int mode)
+int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode)
{
int fd, ver, client, fmode;
char filename[32];
@@ -514,7 +514,7 @@ int snd_seq_hw_open(snd_seq_t **handle, char *name, int streams, int mode)
seq->tmpbufsize = 0;
seq->poll_fd = fd;
seq->ops = &snd_seq_hw_ops;
- seq->private = hw;
+ seq->private_data = hw;
client = snd_seq_hw_client_id(seq);
if (client < 0) {
snd_seq_close(seq);
@@ -528,8 +528,8 @@ int snd_seq_hw_open(snd_seq_t **handle, char *name, int streams, int mode)
int _snd_seq_hw_open(snd_seq_t **handlep, char *name, snd_config_t *conf,
int streams, int mode)
{
- snd_config_iterator_t i;
- snd_config_foreach(i, conf) {
+ snd_config_iterator_t i, next;
+ snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id = snd_config_get_id(n);
if (strcmp(id, "comment") == 0)
diff --git a/src/seq/seq_local.h b/src/seq/seq_local.h
index ee515f7f..165ec856 100644
--- a/src/seq/seq_local.h
+++ b/src/seq/seq_local.h
@@ -76,7 +76,7 @@ struct _snd_seq {
int mode;
int poll_fd;
snd_seq_ops_t *ops;
- void *private;
+ void *private_data;
int client; /* client number */
/* buffers */
char *obuf; /* output buffer */
@@ -90,6 +90,6 @@ struct _snd_seq {
size_t tmpbufsize; /* size of errbuf */
};
-int snd_seq_hw_open(snd_seq_t **handle, char *name, int streams, int mode);
+int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode);
#endif
diff --git a/src/seq/seqmid.c b/src/seq/seqmid.c
index 64e79c59..6d34c058 100644
--- a/src/seq/seqmid.c
+++ b/src/seq/seqmid.c
@@ -144,7 +144,7 @@ int snd_seq_setpos_queue(snd_seq_t *seq, int q, snd_seq_timestamp_t *rtime, snd_
/* create a port - simple version
* return the port number
*/
-int snd_seq_create_simple_port(snd_seq_t *seq, char *name,
+int snd_seq_create_simple_port(snd_seq_t *seq, const char *name,
unsigned int caps, unsigned int type)
{
snd_seq_port_info_t pinfo;
@@ -241,7 +241,7 @@ int snd_seq_disconnect_to(snd_seq_t *seq, int myport, int dest_client, int dest_
/*
* set client information
*/
-int snd_seq_set_client_name(snd_seq_t *seq, char *name)
+int snd_seq_set_client_name(snd_seq_t *seq, const char *name)
{
snd_seq_client_info_t info;
int err;
@@ -252,7 +252,7 @@ int snd_seq_set_client_name(snd_seq_t *seq, char *name)
return snd_seq_set_client_info(seq, &info);
}
-int snd_seq_set_client_group(snd_seq_t *seq, char *name)
+int snd_seq_set_client_group(snd_seq_t *seq, const char *name)
{
snd_seq_client_info_t info;
int err;