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;
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;
};
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;
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)
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;
#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);
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();
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
#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)
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);
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);
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);
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
}
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);
/**
* 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
#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
****************************************************************************/
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,
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,
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
}
* 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
}
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
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);
#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);
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);
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);
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);
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
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);
/*
* 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);
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;
}
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) {
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;
{
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) {
#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;
}
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);
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();
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;
}
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)
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));
const char *snd_ctl_event_type_names[] = {
EVENT(REBUILD),
EVENT(VALUE),
- EVENT(CHANGE),
+ EVENT(INFO),
EVENT(ADD),
EVENT(REMOVE),
};
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);
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) {
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) {
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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)
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);
char *name;
snd_ctl_type_t type;
snd_ctl_ops_t *ops;
- void *private;
+ void *private_data;
int nonblock;
};
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;
};
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);
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;
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;
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;
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;
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;
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;
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);
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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)
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)
#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;
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;
}
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);
}
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)
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;
}
{
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);
}
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);
}
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);
}
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;
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;
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;
}
}
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)
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;
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)
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);
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;
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;
}
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);
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);
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)
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);
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);
}
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;
}
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;
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);
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++;
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--;
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--;
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;
}
/*
- * 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>
*
*
*
*/
-#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);
}
#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)
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);
}
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;
}
*
*/
-//#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);
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;
}
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 {
{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++) {
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;
}
}
{
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)
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)
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;
+}
+
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)
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);
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);
}
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;
}
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;
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)
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);
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);
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)
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;
}
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;
}
#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);
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);
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;
}
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)
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)
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;
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;
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,
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,
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,
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;
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;
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;
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;
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) {
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;
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;
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)
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;
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;
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,
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,
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,
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;
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;
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) {
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;
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;
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)
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;
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;
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");
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;
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 = ©->plug.hw_ptr;
pcm->appl_ptr = ©->plug.appl_ptr;
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)
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;
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;
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);
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 */
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 */
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);
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);
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) {
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) {
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) {
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) {
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;
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);
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);
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);
}
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
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;
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)
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) {
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) {
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");
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");
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");
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");
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 &&
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;
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");
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");
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");
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");
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 ||
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");
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");
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");
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");
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;
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;
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;
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;
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);
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);
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;
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;
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);
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");
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;
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",
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);
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)
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;
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,
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,
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;
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;
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) {
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;
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;
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)
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);
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;
}
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;
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;
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,
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,
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,
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;
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;
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) {
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;
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;
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)
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) {
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));
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);
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);
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;
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)
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;
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) {
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) {
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;
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));
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) {
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");
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,
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;
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;
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)
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);
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)
++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;
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)
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;
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;
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;
}
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;
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;
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)
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;
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;
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;
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:
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:
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;
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;
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;
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;
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);
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;
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;
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)
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);
};
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);
};
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)
{
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) {
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]);
}
{
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)
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);
}
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, ¶ms1, var, p->best, 0);
int diff;
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);
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);
}
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))
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) {
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;
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);
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;
}
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);
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;
}
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,
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);
}
{
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);
}
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,
},
};
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);
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;
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) {
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)
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;
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 ||
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;
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,
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);
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);
}
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;
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);
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);
}
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);
}
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;
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)
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);
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;
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)
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;
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;
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) {
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);
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);
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);
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);
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;
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;
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) {
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;
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);
}
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) | \
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;
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;
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,
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;
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;
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;
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;
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;
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;
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;
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;
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);
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);
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);
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;
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;
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)
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];
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;
#endif
zero_end:
for (srcidx = 0; srcidx < nsrcs; ++srcidx) {
- char *src = srcs[srcidx];
+ const char *src = srcs[srcidx];
/* Get sample */
goto *get;
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;
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,
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 |
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 |
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,
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;
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;
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");
}
-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,
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;
{
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;
}
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;
#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;
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)
*/
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;
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;
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
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;
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);
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);
}
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;
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);
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;
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;
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);
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);
/* 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;
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);
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);
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? */
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)
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];
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)) {
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);
/* 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 */
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);
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);
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);
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");
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;
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;
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)
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);
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;
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;
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;
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;
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;
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;
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;
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);
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;
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;
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;
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));
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;
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;
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);
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);
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);
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);
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;
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;
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;
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;
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;
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;
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);
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;
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)
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)
#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;
}
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();
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)
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;
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) {
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");
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");
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");
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");
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");
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)
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)
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;
rmidi->mode = mode;
rmidi->poll_fd = fd;
rmidi->ops = &snd_rawmidi_hw_ops;
- rmidi->private = hw;
+ rmidi->private_data = hw;
hw->open++;
*inputp = rmidi;
}
rmidi->mode = mode;
rmidi->poll_fd = fd;
rmidi->ops = &snd_rawmidi_hw_ops;
- rmidi->private = hw;
+ rmidi->private_data = hw;
hw->open++;
*outputp = rmidi;
}
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)
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;
};
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);
#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);
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)
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));
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;
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;
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) {
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");
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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];
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);
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)
int mode;
int poll_fd;
snd_seq_ops_t *ops;
- void *private;
+ void *private_data;
int client; /* client number */
/* buffers */
char *obuf; /* output buffer */
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
/* 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;
/*
* 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;
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;