]> git.alsa-project.org Git - alsa-lib.git/commitdiff
More documentation. Added mode argument to i/o_stdio_open.
authorAbramo Bagnara <abramo@alsa-project.org>
Thu, 29 Mar 2001 09:10:46 +0000 (09:10 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Thu, 29 Mar 2001 09:10:46 +0000 (09:10 +0000)
12 files changed:
include/control.h
include/control_m4.h
include/input.h
include/output.h
src/conf.c
src/control/Makefile.am
src/control/control.c
src/control/control_m4.c [deleted file]
src/control/hcontrol.c
src/error.c
src/input.c
src/output.c

index 5ae53f39dba749f7420cb70a4a8ce58d23d7dce1..e3b311aa20a7c1660a763f601d771c7c169c97bc 100644 (file)
@@ -273,7 +273,6 @@ void snd_hctl_set_callback_private(snd_hctl_t *hctl, void *data);
 void *snd_hctl_get_callback_private(snd_hctl_t *hctl);
 int snd_hctl_load(snd_hctl_t *hctl);
 int snd_hctl_free(snd_hctl_t *hctl);
-int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event);
 int snd_hctl_handle_events(snd_hctl_t *hctl);
 const char *snd_hctl_name(snd_hctl_t *hctl);
 snd_ctl_type_t snd_hctl_type(snd_hctl_t *hctl);
index a98ffdef93dba8abea8e040b13d4d2f1d1558bc3..1023bc2dc4bda7b821d7c50425cd738b40721cd5 100644 (file)
@@ -184,7 +184,7 @@ void snd_ctl_elem_value_set_name(snd_ctl_elem_value_t *obj, const char *val);
 
 void snd_ctl_elem_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val);
 
-long snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int idx);
+int snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int idx);
 
 long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_t *obj, unsigned int idx);
 
index 67021ffeeb398a16853be81762770b297c5f6ab4..8dc40704c068b953a2236c812d34cf51059c0ea8 100644 (file)
@@ -14,7 +14,7 @@ typedef enum _snd_input_type {
 extern "C" {
 #endif
 
-int snd_input_stdio_open(snd_input_t **inputp, const char *file);
+int snd_input_stdio_open(snd_input_t **inputp, const char *file, const char *mode);
 int snd_input_stdio_attach(snd_input_t **inputp, FILE *fp, int close);
 int snd_input_buffer_open(snd_input_t **inputp, const char *buffer, int size);
 int snd_input_close(snd_input_t *input);
index 806ebe61acc792fddf081feb099cc4749a2dc414..e7a46fcf7499175d0db710a86119ad1be6f2cd1c 100644 (file)
@@ -14,7 +14,7 @@ typedef enum _snd_output_type {
 extern "C" {
 #endif
 
-int snd_output_stdio_open(snd_output_t **outputp, const char *file);
+int snd_output_stdio_open(snd_output_t **outputp, const char *file, const char *open);
 int snd_output_stdio_attach(snd_output_t **outputp, FILE *fp, int close);
 int snd_output_buffer_open(snd_output_t **outputp);
 size_t snd_output_buffer_string(snd_output_t *output, char **buf);
index 50221b00be1c81124f4e492f77cf314546a939cb..418f21d52467bfb5d6b62e56b87af4333ead08d8 100644 (file)
@@ -118,7 +118,7 @@ static int get_char_skip_comments(input_t *input)
                        int err = get_delimstring(&file, '>', input);
                        if (err < 0)
                                return err;
-                       err = snd_input_stdio_open(&in, file);
+                       err = snd_input_stdio_open(&in, file, "r");
                        if (err < 0)
                                return err;
                        fd = malloc(sizeof(*fd));
@@ -1220,7 +1220,7 @@ int snd_config_update()
        err = snd_config_top(&snd_config);
        if (err < 0)
                return err;
-       err = snd_input_stdio_open(&in, SYS_ASOUNDRC);
+       err = snd_input_stdio_open(&in, SYS_ASOUNDRC, "r");
        if (err >= 0) {
                err = snd_config_load(snd_config, in);
                snd_input_close(in);
@@ -1233,7 +1233,7 @@ int snd_config_update()
                sys_asoundrc_inode = sys_st.st_ino;
                sys_asoundrc_mtime = sys_st.st_mtime;
        }
-       err = snd_input_stdio_open(&in, usr_asoundrc);
+       err = snd_input_stdio_open(&in, usr_asoundrc, "r");
        if (err >= 0) {
                err = snd_config_load(snd_config, in);
                snd_input_close(in);
index 96031bc96c9d29dee0b8d59212e1ad62bbe447ac..d8b0aeccd8b543e0374a1b0fb773561ddae758d1 100644 (file)
@@ -1,7 +1,7 @@
 EXTRA_LTLIBRARIES = libcontrol.la
 
 libcontrol_la_SOURCES = cards.c hcontrol.c defaults.c \
-                        control.c control_m4.c control_hw.c control_shm.c
+                        control.c control_hw.c control_shm.c
 
 noinst_HEADERS = control_local.h
 
index 262c07d1f0c49f1265e40e24f3777808c58c2c6d..bf43ad63d28b04091ae7599b3de9f75849848e1d 100644 (file)
@@ -572,27 +572,27 @@ unsigned int snd_ctl_event_elem_get_mask(const snd_ctl_event_t *obj)
 }
 
 /**
- * \brief Get element numeric identificator for an element related event
+ * \brief Get CTL element identificator for an element related event
  * \param obj CTL event
- * \return element numeric identificator for element related event
+ * \param ptr Pointer to returned CTL element identificator
  */
-unsigned int snd_ctl_event_elem_get_numid(const snd_ctl_event_t *obj)
+void snd_ctl_event_elem_get_id(const snd_ctl_event_t *obj, snd_ctl_elem_id_t *ptr)
 {
-       assert(obj);
+       assert(obj && ptr);
        assert(obj->type == SND_CTL_EVENT_ELEM);
-       return obj->data.elem.id.numid;
+       *ptr = obj->data.elem.id;
 }
 
 /**
- * \brief Get CTL element identificator for an element related event
+ * \brief Get element numeric identificator for an element related event
  * \param obj CTL event
- * \param ptr Pointer to returned CTL element identificator
+ * \return element numeric identificator
  */
-void snd_ctl_event_elem_get_id(const snd_ctl_event_t *obj, snd_ctl_elem_id_t *ptr)
+unsigned int snd_ctl_event_elem_get_numid(const snd_ctl_event_t *obj)
 {
-       assert(obj && ptr);
+       assert(obj);
        assert(obj->type == SND_CTL_EVENT_ELEM);
-       *ptr = obj->data.elem.id;
+       return obj->data.elem.id.numid;
 }
 
 /**
@@ -662,3 +662,1217 @@ int _snd_ctl_poll_descriptor(snd_ctl_t *ctl)
        return ctl->ops->poll_descriptor(ctl);
 }
 #endif
+
+/**
+ * \brief get size of #snd_ctl_elem_id_t
+ * \return size in bytes
+ */
+size_t snd_ctl_elem_id_sizeof()
+{
+       return sizeof(snd_ctl_elem_id_t);
+}
+
+/**
+ * \brief allocate an invalid #snd_ctl_elem_id_t using standard malloc
+ * \param ptr returned pointer
+ * \return 0 on success otherwise negative error code
+ */
+int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr)
+{
+       assert(ptr);
+       *ptr = calloc(1, sizeof(snd_ctl_elem_id_t));
+       if (!*ptr)
+               return -ENOMEM;
+       return 0;
+}
+
+/**
+ * \brief frees a previously allocated #snd_ctl_elem_id_t
+ * \param pointer to object to free
+ */
+void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj)
+{
+       free(obj);
+}
+
+/**
+ * \brief copy one #snd_ctl_elem_id_t to another
+ * \param dst pointer to destination
+ * \param src pointer to source
+ */
+void snd_ctl_elem_id_copy(snd_ctl_elem_id_t *dst, const snd_ctl_elem_id_t *src)
+{
+       assert(dst && src);
+       *dst = *src;
+}
+
+/**
+ * \brief Get numeric identificator from a CTL element identificator
+ * \param obj CTL element identificator
+ * \return CTL element numeric identificator
+ */
+unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj)
+{
+       assert(obj);
+       return obj->numid;
+}
+
+/**
+ * \brief Get interface part of a CTL element identificator
+ * \param obj CTL element identificator
+ * \return CTL element related interface
+ */
+snd_ctl_elem_iface_t snd_ctl_elem_id_get_interface(const snd_ctl_elem_id_t *obj)
+{
+       assert(obj);
+       return snd_int_to_enum(obj->iface);
+}
+
+/**
+ * \brief Get device part of a CTL element identificator
+ * \param obj CTL element identificator
+ * \return CTL element related device
+ */
+unsigned int snd_ctl_elem_id_get_device(const snd_ctl_elem_id_t *obj)
+{
+       assert(obj);
+       return obj->device;
+}
+
+/**
+ * \brief Get subdevice part of a CTL element identificator
+ * \param obj CTL element identificator
+ * \return CTL element related subdevice
+ */
+unsigned int snd_ctl_elem_id_get_subdevice(const snd_ctl_elem_id_t *obj)
+{
+       assert(obj);
+       return obj->subdevice;
+}
+
+/**
+ * \brief Get name part of a CTL element identificator
+ * \param obj CTL element identificator
+ * \return CTL element name
+ */
+const char *snd_ctl_elem_id_get_name(const snd_ctl_elem_id_t *obj)
+{
+       assert(obj);
+       return obj->name;
+}
+
+/**
+ * \brief Get index part of a CTL element identificator
+ * \param obj CTL element identificator
+ * \return CTL element index
+ */
+unsigned int snd_ctl_elem_id_get_index(const snd_ctl_elem_id_t *obj)
+{
+       assert(obj);
+       return obj->index;
+}
+
+/**
+ * \brief Set numeric identificator for a CTL element identificator
+ * \param obj CTL element identificator
+ * \param val CTL element numeric identificator
+ */
+void snd_ctl_elem_id_set_numid(snd_ctl_elem_id_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->numid = val;
+}
+
+/**
+ * \brief Set interface part for a CTL element identificator
+ * \param obj CTL element identificator
+ * \param val CTL element related interface
+ */
+void snd_ctl_elem_id_set_interface(snd_ctl_elem_id_t *obj, snd_ctl_elem_iface_t val)
+{
+       assert(obj);
+       obj->iface = snd_enum_to_int(val);
+}
+
+/**
+ * \brief Set device part for a CTL element identificator
+ * \param obj CTL element identificator
+ * \param val CTL element related device
+ */
+void snd_ctl_elem_id_set_device(snd_ctl_elem_id_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->device = val;
+}
+
+/**
+ * \brief Set subdevice part for a CTL element identificator
+ * \param obj CTL element identificator
+ * \param val CTL element related subdevice
+ */
+void snd_ctl_elem_id_set_subdevice(snd_ctl_elem_id_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->subdevice = val;
+}
+
+/**
+ * \brief Set name part for a CTL element identificator
+ * \param obj CTL element identificator
+ * \param val CTL element name
+ */
+void snd_ctl_elem_id_set_name(snd_ctl_elem_id_t *obj, const char *val)
+{
+       assert(obj);
+       strncpy(obj->name, val, sizeof(obj->name));
+}
+
+/**
+ * \brief Set index part for a CTL element identificator
+ * \param obj CTL element identificator
+ * \param val CTL element index
+ */
+void snd_ctl_elem_id_set_index(snd_ctl_elem_id_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->index = val;
+}
+
+/**
+ * \brief get size of #snd_ctl_card_info_t
+ * \return size in bytes
+ */
+size_t snd_ctl_card_info_sizeof()
+{
+       return sizeof(snd_ctl_card_info_t);
+}
+
+/**
+ * \brief allocate an invalid #snd_ctl_card_info_t using standard malloc
+ * \param ptr returned pointer
+ * \return 0 on success otherwise negative error code
+ */
+int snd_ctl_card_info_malloc(snd_ctl_card_info_t **ptr)
+{
+       assert(ptr);
+       *ptr = calloc(1, sizeof(snd_ctl_card_info_t));
+       if (!*ptr)
+               return -ENOMEM;
+       return 0;
+}
+
+/**
+ * \brief frees a previously allocated #snd_ctl_card_info_t
+ * \param pointer to object to free
+ */
+void snd_ctl_card_info_free(snd_ctl_card_info_t *obj)
+{
+       free(obj);
+}
+
+/**
+ * \brief copy one #snd_ctl_card_info_t to another
+ * \param dst pointer to destination
+ * \param src pointer to source
+ */
+void snd_ctl_card_info_copy(snd_ctl_card_info_t *dst, const snd_ctl_card_info_t *src)
+{
+       assert(dst && src);
+       *dst = *src;
+}
+
+/**
+ * \brief Get card number from a CTL card info
+ * \param obj CTL card info
+ * \return card number
+ */
+int snd_ctl_card_info_get_card(const snd_ctl_card_info_t *obj)
+{
+       assert(obj);
+       return obj->card;
+}
+
+/**
+ * \brief Get card type from a CTL card info
+ * \param obj CTL card info
+ * \return card type
+ */
+snd_card_type_t snd_ctl_card_info_get_type(const snd_ctl_card_info_t *obj)
+{
+       assert(obj);
+       return snd_int_to_enum(obj->type);
+}
+
+/**
+ * \brief Get card identificator from a CTL card info
+ * \param obj CTL card info
+ * \return card identificator
+ */
+const char *snd_ctl_card_info_get_id(const snd_ctl_card_info_t *obj)
+{
+       assert(obj);
+       return obj->id;
+}
+
+/**
+ * \brief Get card abbreviation from a CTL card info
+ * \param obj CTL card info
+ * \return card abbreviation
+ */
+const char *snd_ctl_card_info_get_abbreviation(const snd_ctl_card_info_t *obj)
+{
+       assert(obj);
+       return obj->abbreviation;
+}
+
+/**
+ * \brief Get card name from a CTL card info
+ * \param obj CTL card info
+ * \return card name
+ */
+const char *snd_ctl_card_info_get_name(const snd_ctl_card_info_t *obj)
+{
+       assert(obj);
+       return obj->name;
+}
+
+/**
+ * \brief Get card long name from a CTL card info
+ * \param obj CTL card info
+ * \return card long name
+ */
+const char *snd_ctl_card_info_get_longname(const snd_ctl_card_info_t *obj)
+{
+       assert(obj);
+       return obj->longname;
+}
+
+/**
+ * \brief Get card mixer identificator from a CTL card info
+ * \param obj CTL card info
+ * \return card mixer identificator
+ */
+const char *snd_ctl_card_info_get_mixerid(const snd_ctl_card_info_t *obj)
+{
+       assert(obj);
+       return obj->mixerid;
+}
+
+/**
+ * \brief Get card mixer name from a CTL card info
+ * \param obj CTL card info
+ * \return card mixer name
+ */
+const char *snd_ctl_card_info_get_mixername(const snd_ctl_card_info_t *obj)
+{
+       assert(obj);
+       return obj->mixername;
+}
+
+/**
+ * \brief get size of #snd_ctl_event_t
+ * \return size in bytes
+ */
+size_t snd_ctl_event_sizeof()
+{
+       return sizeof(snd_ctl_event_t);
+}
+
+/**
+ * \brief allocate an invalid #snd_ctl_event_t using standard malloc
+ * \param ptr returned pointer
+ * \return 0 on success otherwise negative error code
+ */
+int snd_ctl_event_malloc(snd_ctl_event_t **ptr)
+{
+       assert(ptr);
+       *ptr = calloc(1, sizeof(snd_ctl_event_t));
+       if (!*ptr)
+               return -ENOMEM;
+       return 0;
+}
+
+/**
+ * \brief frees a previously allocated #snd_ctl_event_t
+ * \param pointer to object to free
+ */
+void snd_ctl_event_free(snd_ctl_event_t *obj)
+{
+       free(obj);
+}
+
+/**
+ * \brief copy one #snd_ctl_event_t to another
+ * \param dst pointer to destination
+ * \param src pointer to source
+ */
+void snd_ctl_event_copy(snd_ctl_event_t *dst, const snd_ctl_event_t *src)
+{
+       assert(dst && src);
+       *dst = *src;
+}
+
+/**
+ * \brief Get type of a CTL event
+ * \param obj CTL event
+ * \return CTL event type
+ */
+snd_ctl_event_type_t snd_ctl_event_get_type(const snd_ctl_event_t *obj)
+{
+       assert(obj);
+       return snd_int_to_enum(obj->type);
+}
+
+/**
+ * \brief get size of #snd_ctl_elem_list_t
+ * \return size in bytes
+ */
+size_t snd_ctl_elem_list_sizeof()
+{
+       return sizeof(snd_ctl_elem_list_t);
+}
+
+/**
+ * \brief allocate an invalid #snd_ctl_elem_list_t using standard malloc
+ * \param ptr returned pointer
+ * \return 0 on success otherwise negative error code
+ */
+int snd_ctl_elem_list_malloc(snd_ctl_elem_list_t **ptr)
+{
+       assert(ptr);
+       *ptr = calloc(1, sizeof(snd_ctl_elem_list_t));
+       if (!*ptr)
+               return -ENOMEM;
+       return 0;
+}
+
+/**
+ * \brief frees a previously allocated #snd_ctl_elem_list_t
+ * \param pointer to object to free
+ */
+void snd_ctl_elem_list_free(snd_ctl_elem_list_t *obj)
+{
+       free(obj);
+}
+
+/**
+ * \brief copy one #snd_ctl_elem_list_t to another
+ * \param dst pointer to destination
+ * \param src pointer to source
+ */
+void snd_ctl_elem_list_copy(snd_ctl_elem_list_t *dst, const snd_ctl_elem_list_t *src)
+{
+       assert(dst && src);
+       *dst = *src;
+}
+
+/**
+ * \brief Set index of first wanted CTL element identificator in a CTL element identificators list
+ * \param obj CTL element identificators list
+ * \param val index of CTL element to put at position 0 of list
+ */
+void snd_ctl_elem_list_set_offset(snd_ctl_elem_list_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->offset = val;
+}
+
+/**
+ * \brief Get number of used entries in CTL element identificators list
+ * \param obj CTL element identificator list
+ * \return number of used entries
+ */
+unsigned int snd_ctl_elem_list_get_used(const snd_ctl_elem_list_t *obj)
+{
+       assert(obj);
+       return obj->used;
+}
+
+/**
+ * \brief Get total count of elements present in CTL device (information present in every filled CTL element identificators list)
+ * \param obj CTL element identificator list
+ * \return total number of elements
+ */
+unsigned int snd_ctl_elem_list_get_count(const snd_ctl_elem_list_t *obj)
+{
+       assert(obj);
+       return obj->count;
+}
+
+/**
+ * \brief Get CTL element identificator for an entry of a CTL element identificators list
+ * \param obj CTL element identificator list
+ * \param idx Index of entry
+ * \param ptr Pointer to returned CTL element identificator
+ */
+void snd_ctl_elem_list_get_id(const snd_ctl_elem_list_t *obj, unsigned int idx, snd_ctl_elem_id_t *ptr)
+{
+       assert(obj && ptr);
+       assert(idx < obj->used);
+       *ptr = obj->pids[idx];
+}
+
+/**
+ * \brief Get CTL element numeric identificator for an entry of a CTL element identificators list
+ * \param obj CTL element identificator list
+ * \param idx Index of entry
+ * \return CTL element numeric identificator
+ */
+unsigned int snd_ctl_elem_list_get_numid(const snd_ctl_elem_list_t *obj, unsigned int idx)
+{
+       assert(obj);
+       assert(idx < obj->used);
+       return obj->pids[idx].numid;
+}
+
+/**
+ * \brief Get interface part of CTL element identificator for an entry of a CTL element identificators list
+ * \param obj CTL element identificator list
+ * \param idx Index of entry
+ * \return CTL element related interface
+ */
+snd_ctl_elem_iface_t snd_ctl_elem_list_get_interface(const snd_ctl_elem_list_t *obj, unsigned int idx)
+{
+       assert(obj);
+       assert(idx < obj->used);
+       return snd_int_to_enum(obj->pids[idx].iface);
+}
+
+/**
+ * \brief Get device part of CTL element identificator for an entry of a CTL element identificators list
+ * \param obj CTL element identificator list
+ * \param idx Index of entry
+ * \return CTL element related device
+ */
+unsigned int snd_ctl_elem_list_get_device(const snd_ctl_elem_list_t *obj, unsigned int idx)
+{
+       assert(obj);
+       assert(idx < obj->used);
+       return obj->pids[idx].device;
+}
+
+/**
+ * \brief Get subdevice part of CTL element identificator for an entry of a CTL element identificators list
+ * \param obj CTL element identificator list
+ * \param idx Index of entry
+ * \return CTL element related subdevice
+ */
+unsigned int snd_ctl_elem_list_get_subdevice(const snd_ctl_elem_list_t *obj, unsigned int idx)
+{
+       assert(obj);
+       assert(idx < obj->used);
+       return obj->pids[idx].subdevice;
+}
+
+/**
+ * \brief Get name part of CTL element identificator for an entry of a CTL element identificators list
+ * \param obj CTL element identificator list
+ * \param idx Index of entry
+ * \return CTL element name
+ */
+const char *snd_ctl_elem_list_get_name(const snd_ctl_elem_list_t *obj, unsigned int idx)
+{
+       assert(obj);
+       assert(idx < obj->used);
+       return obj->pids[idx].name;
+}
+
+/**
+ * \brief Get index part of CTL element identificator for an entry of a CTL element identificators list
+ * \param obj CTL element identificator list
+ * \param idx Index of entry
+ * \return CTL element index
+ */
+unsigned int snd_ctl_elem_list_get_index(const snd_ctl_elem_list_t *obj, unsigned int idx)
+{
+       assert(obj);
+       assert(idx < obj->used);
+       return obj->pids[idx].index;
+}
+
+/**
+ * \brief get size of #snd_ctl_elem_info_t
+ * \return size in bytes
+ */
+size_t snd_ctl_elem_info_sizeof()
+{
+       return sizeof(snd_ctl_elem_info_t);
+}
+
+/**
+ * \brief allocate an invalid #snd_ctl_elem_info_t using standard malloc
+ * \param ptr returned pointer
+ * \return 0 on success otherwise negative error code
+ */
+int snd_ctl_elem_info_malloc(snd_ctl_elem_info_t **ptr)
+{
+       assert(ptr);
+       *ptr = calloc(1, sizeof(snd_ctl_elem_info_t));
+       if (!*ptr)
+               return -ENOMEM;
+       return 0;
+}
+
+/**
+ * \brief frees a previously allocated #snd_ctl_elem_info_t
+ * \param pointer to object to free
+ */
+void snd_ctl_elem_info_free(snd_ctl_elem_info_t *obj)
+{
+       free(obj);
+}
+
+/**
+ * \brief copy one #snd_ctl_elem_info_t to another
+ * \param dst pointer to destination
+ * \param src pointer to source
+ */
+void snd_ctl_elem_info_copy(snd_ctl_elem_info_t *dst, const snd_ctl_elem_info_t *src)
+{
+       assert(dst && src);
+       *dst = *src;
+}
+
+/**
+ * \brief Get type from a CTL element id/info
+ * \param obj CTL element id/info
+ * \return CTL element content type
+ */
+snd_ctl_elem_type_t snd_ctl_elem_info_get_type(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return snd_int_to_enum(obj->type);
+}
+
+/**
+ * \brief Get info about readability from a CTL element id/info
+ * \param obj CTL element id/info
+ * \return 0 if element is not redable, 1 if element is readable
+ */
+int snd_ctl_elem_info_is_readable(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_READ);
+}
+
+/**
+ * \brief Get info about writability from a CTL element id/info
+ * \param obj CTL element id/info
+ * \return 0 if element is not writable, 1 if element is not writable
+ */
+int snd_ctl_elem_info_is_writable(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_WRITE);
+}
+
+/**
+ * \brief Get info about notification feasibility from a CTL element id/info
+ * \param obj CTL element id/info
+ * \return 0 if all element value changes are notified to subscribed applications, 1 otherwise
+ */
+int snd_ctl_elem_info_is_volatile(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_VOLATILE);
+}
+
+/**
+ * \brief Get info about status from a CTL element id/info
+ * \param obj CTL element id/info
+ * \return 0 if element value is not active, 1 if is active
+ */
+int snd_ctl_elem_info_is_inactive(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE);
+}
+
+/**
+ * \brief Get info about status from a CTL element id/info
+ * \param obj CTL element id/info
+ * \return 0 if element value is currently changeable, 1 if it's locked by another application
+ */
+int snd_ctl_elem_info_is_locked(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_LOCK);
+}
+
+/**
+ * \brief Get info about values passing policy from a CTL element id/info
+ * \param obj CTL element id/info
+ * \return 0 if element value need to be passed by contents, 1 if need to be passed with a pointer
+ */
+int snd_ctl_elem_info_is_indirect(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_INDIRECT);
+}
+
+/**
+ * \brief Get number of value entries from a CTL element id/info
+ * \param obj CTL element id/info
+ * \return value entries count
+ */
+unsigned int snd_ctl_elem_info_get_count(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return obj->count;
+}
+
+/**
+ * \brief Get minimum value from a #SND_CTL_ELEM_TYPE_INTEGER CTL element id/info
+ * \param obj CTL element id/info
+ * \return Minimum value
+ */
+long snd_ctl_elem_info_get_min(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       assert(obj->type == SND_CTL_ELEM_TYPE_INTEGER);
+       return obj->value.integer.min;
+}
+
+/**
+ * \brief Get maximum value from a #SND_CTL_ELEM_TYPE_INTEGER CTL element id/info
+ * \param obj CTL element id/info
+ * \return Maximum value
+ */
+long snd_ctl_elem_info_get_max(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       assert(obj->type == SND_CTL_ELEM_TYPE_INTEGER);
+       return obj->value.integer.max;
+}
+
+/**
+ * \brief Get value step from a #SND_CTL_ELEM_TYPE_INTEGER CTL element id/info
+ * \param obj CTL element id/info
+ * \return Step
+ */
+long snd_ctl_elem_info_get_step(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       assert(obj->type == SND_CTL_ELEM_TYPE_INTEGER);
+       return obj->value.integer.step;
+}
+
+/**
+ * \brief Get number of items available from a #SND_CTL_ELEM_TYPE_ENUMERATED CTL element id/info
+ * \param obj CTL element id/info
+ * \return items count
+ */
+unsigned int snd_ctl_elem_info_get_items(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       assert(obj->type == SND_CTL_ELEM_TYPE_ENUMERATED);
+       return obj->value.enumerated.items;
+}
+
+/**
+ * \brief Select item in a #SND_CTL_ELEM_TYPE_ENUMERATED CTL element id/info
+ * \param obj CTL element id/info
+ * \param val item number
+ */
+void snd_ctl_elem_info_set_item(snd_ctl_elem_info_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->value.enumerated.item = val;
+}
+
+/**
+ * \brief Get name for selected item in a #SND_CTL_ELEM_TYPE_ENUMERATED CTL element id/info
+ * \param obj CTL element id/info
+ * \return name of choosen item
+ */
+const char *snd_ctl_elem_info_get_item_name(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       assert(obj->type == SND_CTL_ELEM_TYPE_ENUMERATED);
+       return obj->value.enumerated.name;
+}
+
+/**
+ * \brief Get CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \param ptr Pointer to returned CTL element identificator
+ */
+void snd_ctl_elem_info_get_id(const snd_ctl_elem_info_t *obj, snd_ctl_elem_id_t *ptr)
+{
+       assert(obj && ptr);
+       *ptr = obj->id;
+}
+
+/**
+ * \brief Get element numeric identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \return element numeric identificator
+ */
+unsigned int snd_ctl_elem_info_get_numid(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return obj->id.numid;
+}
+
+/**
+ * \brief Get interface part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \return interface part of element identificator
+ */
+snd_ctl_elem_iface_t snd_ctl_elem_info_get_interface(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return snd_int_to_enum(obj->id.iface);
+}
+
+/**
+ * \brief Get device part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \return device part of element identificator
+ */
+unsigned int snd_ctl_elem_info_get_device(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return obj->id.device;
+}
+
+/**
+ * \brief Get subdevice part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \return subdevice part of element identificator
+ */
+unsigned int snd_ctl_elem_info_get_subdevice(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return obj->id.subdevice;
+}
+
+/**
+ * \brief Get name part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \return name part of element identificator
+ */
+const char *snd_ctl_elem_info_get_name(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return obj->id.name;
+}
+
+/**
+ * \brief Get index part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \return index part of element identificator
+ */
+unsigned int snd_ctl_elem_info_get_index(const snd_ctl_elem_info_t *obj)
+{
+       assert(obj);
+       return obj->id.index;
+}
+
+/**
+ * \brief Set CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \param ptr CTL element identificator
+ */
+void snd_ctl_elem_info_set_id(snd_ctl_elem_info_t *obj, const snd_ctl_elem_id_t *ptr)
+{
+       assert(obj && ptr);
+       obj->id = *ptr;
+}
+
+/**
+ * \brief Set element numeric identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \param val element numeric identificator
+ */
+void snd_ctl_elem_info_set_numid(snd_ctl_elem_info_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->id.numid = val;
+}
+
+/**
+ * \brief Set interface part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \param val interface part of element identificator
+ */
+void snd_ctl_elem_info_set_interface(snd_ctl_elem_info_t *obj, snd_ctl_elem_iface_t val)
+{
+       assert(obj);
+       obj->id.iface = snd_enum_to_int(val);
+}
+
+/**
+ * \brief Set device part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \param val device part of element identificator
+ */
+void snd_ctl_elem_info_set_device(snd_ctl_elem_info_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->id.device = val;
+}
+
+/**
+ * \brief Set subdevice part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \param val subdevice part of element identificator
+ */
+void snd_ctl_elem_info_set_subdevice(snd_ctl_elem_info_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->id.subdevice = val;
+}
+
+/**
+ * \brief Set name part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \param val name part of element identificator
+ */
+void snd_ctl_elem_info_set_name(snd_ctl_elem_info_t *obj, const char *val)
+{
+       assert(obj);
+       strncpy(obj->id.name, val, sizeof(obj->id.name));
+}
+
+/**
+ * \brief Set index part of CTL element identificator of a CTL element id/info
+ * \param obj CTL element id/info
+ * \param val index part of element identificator
+ */
+void snd_ctl_elem_info_set_index(snd_ctl_elem_info_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->id.index = val;
+}
+
+/**
+ * \brief get size of #snd_ctl_elem_value_t
+ * \return size in bytes
+ */
+size_t snd_ctl_elem_value_sizeof()
+{
+       return sizeof(snd_ctl_elem_value_t);
+}
+
+/**
+ * \brief allocate an invalid #snd_ctl_elem_value_t using standard malloc
+ * \param ptr returned pointer
+ * \return 0 on success otherwise negative error code
+ */
+int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr)
+{
+       assert(ptr);
+       *ptr = calloc(1, sizeof(snd_ctl_elem_value_t));
+       if (!*ptr)
+               return -ENOMEM;
+       return 0;
+}
+
+/**
+ * \brief frees a previously allocated #snd_ctl_elem_value_t
+ * \param pointer to object to free
+ */
+void snd_ctl_elem_value_free(snd_ctl_elem_value_t *obj)
+{
+       free(obj);
+}
+
+/**
+ * \brief copy one #snd_ctl_elem_value_t to another
+ * \param dst pointer to destination
+ * \param src pointer to source
+ */
+void snd_ctl_elem_value_copy(snd_ctl_elem_value_t *dst, const snd_ctl_elem_value_t *src)
+{
+       assert(dst && src);
+       *dst = *src;
+}
+
+/**
+ * \brief Get CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \param ptr Pointer to returned CTL element identificator
+ */
+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;
+}
+
+/**
+ * \brief Get element numeric identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return element numeric identificator
+ */
+unsigned int snd_ctl_elem_value_get_numid(const snd_ctl_elem_value_t *obj)
+{
+       assert(obj);
+       return obj->id.numid;
+}
+
+/**
+ * \brief Get interface part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return interface part of element identificator
+ */
+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);
+}
+
+/**
+ * \brief Get device part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return device part of element identificator
+ */
+unsigned int snd_ctl_elem_value_get_device(const snd_ctl_elem_value_t *obj)
+{
+       assert(obj);
+       return obj->id.device;
+}
+
+/**
+ * \brief Get subdevice part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return subdevice part of element identificator
+ */
+unsigned int snd_ctl_elem_value_get_subdevice(const snd_ctl_elem_value_t *obj)
+{
+       assert(obj);
+       return obj->id.subdevice;
+}
+
+/**
+ * \brief Get name part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return name part of element identificator
+ */
+const char *snd_ctl_elem_value_get_name(const snd_ctl_elem_value_t *obj)
+{
+       assert(obj);
+       return obj->id.name;
+}
+
+/**
+ * \brief Get index part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return index part of element identificator
+ */
+unsigned int snd_ctl_elem_value_get_index(const snd_ctl_elem_value_t *obj)
+{
+       assert(obj);
+       return obj->id.index;
+}
+
+/**
+ * \brief Set CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \param ptr CTL element identificator
+ */
+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;
+}
+
+/**
+ * \brief Set element numeric identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \param val element numeric identificator
+ */
+void snd_ctl_elem_value_set_numid(snd_ctl_elem_value_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->id.numid = val;
+}
+
+/**
+ * \brief Set interface part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \param val interface part of element identificator
+ */
+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);
+}
+
+/**
+ * \brief Set device part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \param val device part of element identificator
+ */
+void snd_ctl_elem_value_set_device(snd_ctl_elem_value_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->id.device = val;
+}
+
+/**
+ * \brief Set subdevice part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \param val subdevice part of element identificator
+ */
+void snd_ctl_elem_value_set_subdevice(snd_ctl_elem_value_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->id.subdevice = val;
+}
+
+/**
+ * \brief Set name part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \param val name part of element identificator
+ */
+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));
+}
+
+/**
+ * \brief Set index part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \param val index part of element identificator
+ */
+void snd_ctl_elem_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val)
+{
+       assert(obj);
+       obj->id.index = val;
+}
+
+/**
+ * \brief Get value for an entry of a #SND_CTL_ELEM_TYPE_BOOLEAN CTL element id/value 
+ * \param obj CTL element id/value
+ * \param idx Entry index
+ * \return value for the entry
+ */ 
+int 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];
+}
+
+/**
+ * \brief Get value for an entry of a #SND_CTL_ELEM_TYPE_INTEGER CTL element id/value 
+ * \param obj CTL element id/value
+ * \param idx Entry index
+ * \return value for the entry
+ */ 
+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];
+}
+
+/**
+ * \brief Get value for an entry of a #SND_CTL_ELEM_TYPE_ENUMERATED CTL element id/value 
+ * \param obj CTL element id/value
+ * \param idx Entry index
+ * \return value for the entry
+ */ 
+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];
+}
+
+/**
+ * \brief Get value for an entry of a #SND_CTL_ELEM_TYPE_BYTES CTL element id/value 
+ * \param obj CTL element id/value
+ * \param idx Entry index
+ * \return value for the entry
+ */ 
+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];
+}
+
+/**
+ * \brief Set value for an entry of a #SND_CTL_ELEM_TYPE_BOOLEAN CTL element id/value 
+ * \param obj CTL element id/value
+ * \param idx Entry index
+ * \param val value for the entry
+ */ 
+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;
+}
+
+/**
+ * \brief Set value for an entry of a #SND_CTL_ELEM_TYPE_INTEGER CTL element id/value 
+ * \param obj CTL element id/value
+ * \param idx Entry index
+ * \param val value for the entry
+ */ 
+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;
+}
+
+/**
+ * \brief Set value for an entry of a #SND_CTL_ELEM_TYPE_ENUMERATED CTL element id/value 
+ * \param obj CTL element id/value
+ * \param idx Entry index
+ * \param val value for the entry
+ */ 
+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;
+}
+
+/**
+ * \brief Set value for an entry of a #SND_CTL_ELEM_TYPE_BYTES CTL element id/value 
+ * \param obj CTL element id/value
+ * \param idx Entry index
+ * \param val value for the entry
+ */ 
+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;
+}
+
+/**
+ * \brief Get value for a #SND_CTL_ELEM_TYPE_BYTES CTL element id/value 
+ * \param obj CTL element id/value
+ * \return Pointer to CTL element value
+ */ 
+const void * snd_ctl_elem_value_get_bytes(const snd_ctl_elem_value_t *obj)
+{
+       assert(obj);
+       return obj->value.bytes.data;
+}
+
+/**
+ * \brief Get value for a #SND_CTL_ELEM_TYPE_IEC958 CTL element id/value 
+ * \param obj CTL element id/value
+ * \param Pointer to returned CTL element value
+ */ 
+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;
+}
+
+/**
+ * \brief Set value for a #SND_CTL_ELEM_TYPE_IEC958 CTL element id/value 
+ * \param obj CTL element id/value
+ * \param Pointer to CTL element value
+ */ 
+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;
+}
+
diff --git a/src/control/control_m4.c b/src/control/control_m4.c
deleted file mode 100644 (file)
index a0776a3..0000000
+++ /dev/null
@@ -1,753 +0,0 @@
-/*
- *  Control - Automatically generated functions
- *  Copyright (c) 2001 by Abramo Bagnara <abramo@alsa-project.org>
- *
- *
- *   This library is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU Library General Public License as
- *   published by the Free Software Foundation; either version 2 of
- *   the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU Library General Public License for more details.
- *
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-  
-#include "control_local.h"
-
-size_t snd_ctl_elem_id_sizeof()
-{
-       return sizeof(snd_ctl_elem_id_t);
-}
-
-int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr)
-{
-       assert(ptr);
-       *ptr = calloc(1, sizeof(snd_ctl_elem_id_t));
-       if (!*ptr)
-               return -ENOMEM;
-       return 0;
-}
-
-void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj)
-{
-       free(obj);
-}
-
-void snd_ctl_elem_id_copy(snd_ctl_elem_id_t *dst, const snd_ctl_elem_id_t *src)
-{
-       assert(dst && src);
-       *dst = *src;
-}
-
-unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj)
-{
-       assert(obj);
-       return obj->numid;
-}
-
-snd_ctl_elem_iface_t snd_ctl_elem_id_get_interface(const snd_ctl_elem_id_t *obj)
-{
-       assert(obj);
-       return snd_int_to_enum(obj->iface);
-}
-
-unsigned int snd_ctl_elem_id_get_device(const snd_ctl_elem_id_t *obj)
-{
-       assert(obj);
-       return obj->device;
-}
-
-unsigned int snd_ctl_elem_id_get_subdevice(const snd_ctl_elem_id_t *obj)
-{
-       assert(obj);
-       return obj->subdevice;
-}
-
-const char *snd_ctl_elem_id_get_name(const snd_ctl_elem_id_t *obj)
-{
-       assert(obj);
-       return obj->name;
-}
-
-unsigned int snd_ctl_elem_id_get_index(const snd_ctl_elem_id_t *obj)
-{
-       assert(obj);
-       return obj->index;
-}
-
-void snd_ctl_elem_id_set_numid(snd_ctl_elem_id_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->numid = val;
-}
-
-void snd_ctl_elem_id_set_interface(snd_ctl_elem_id_t *obj, snd_ctl_elem_iface_t val)
-{
-       assert(obj);
-       obj->iface = snd_enum_to_int(val);
-}
-
-void snd_ctl_elem_id_set_device(snd_ctl_elem_id_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->device = val;
-}
-
-void snd_ctl_elem_id_set_subdevice(snd_ctl_elem_id_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->subdevice = val;
-}
-
-void snd_ctl_elem_id_set_name(snd_ctl_elem_id_t *obj, const char *val)
-{
-       assert(obj);
-       strncpy(obj->name, val, sizeof(obj->name));
-}
-
-void snd_ctl_elem_id_set_index(snd_ctl_elem_id_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->index = val;
-}
-
-size_t snd_ctl_card_info_sizeof()
-{
-       return sizeof(snd_ctl_card_info_t);
-}
-
-int snd_ctl_card_info_malloc(snd_ctl_card_info_t **ptr)
-{
-       assert(ptr);
-       *ptr = calloc(1, sizeof(snd_ctl_card_info_t));
-       if (!*ptr)
-               return -ENOMEM;
-       return 0;
-}
-
-void snd_ctl_card_info_free(snd_ctl_card_info_t *obj)
-{
-       free(obj);
-}
-
-void snd_ctl_card_info_copy(snd_ctl_card_info_t *dst, const snd_ctl_card_info_t *src)
-{
-       assert(dst && src);
-       *dst = *src;
-}
-
-int snd_ctl_card_info_get_card(const snd_ctl_card_info_t *obj)
-{
-       assert(obj);
-       return obj->card;
-}
-
-snd_card_type_t snd_ctl_card_info_get_type(const snd_ctl_card_info_t *obj)
-{
-       assert(obj);
-       return snd_int_to_enum(obj->type);
-}
-
-const char *snd_ctl_card_info_get_id(const snd_ctl_card_info_t *obj)
-{
-       assert(obj);
-       return obj->id;
-}
-
-const char *snd_ctl_card_info_get_abbreviation(const snd_ctl_card_info_t *obj)
-{
-       assert(obj);
-       return obj->abbreviation;
-}
-
-const char *snd_ctl_card_info_get_name(const snd_ctl_card_info_t *obj)
-{
-       assert(obj);
-       return obj->name;
-}
-
-const char *snd_ctl_card_info_get_longname(const snd_ctl_card_info_t *obj)
-{
-       assert(obj);
-       return obj->longname;
-}
-
-const char *snd_ctl_card_info_get_mixerid(const snd_ctl_card_info_t *obj)
-{
-       assert(obj);
-       return obj->mixerid;
-}
-
-const char *snd_ctl_card_info_get_mixername(const snd_ctl_card_info_t *obj)
-{
-       assert(obj);
-       return obj->mixername;
-}
-
-size_t snd_ctl_event_sizeof()
-{
-       return sizeof(snd_ctl_event_t);
-}
-
-int snd_ctl_event_malloc(snd_ctl_event_t **ptr)
-{
-       assert(ptr);
-       *ptr = calloc(1, sizeof(snd_ctl_event_t));
-       if (!*ptr)
-               return -ENOMEM;
-       return 0;
-}
-
-void snd_ctl_event_free(snd_ctl_event_t *obj)
-{
-       free(obj);
-}
-
-void snd_ctl_event_copy(snd_ctl_event_t *dst, const snd_ctl_event_t *src)
-{
-       assert(dst && src);
-       *dst = *src;
-}
-
-snd_ctl_event_type_t snd_ctl_event_get_type(const snd_ctl_event_t *obj)
-{
-       assert(obj);
-       return snd_int_to_enum(obj->type);
-}
-
-size_t snd_ctl_elem_list_sizeof()
-{
-       return sizeof(snd_ctl_elem_list_t);
-}
-
-int snd_ctl_elem_list_malloc(snd_ctl_elem_list_t **ptr)
-{
-       assert(ptr);
-       *ptr = calloc(1, sizeof(snd_ctl_elem_list_t));
-       if (!*ptr)
-               return -ENOMEM;
-       return 0;
-}
-
-void snd_ctl_elem_list_free(snd_ctl_elem_list_t *obj)
-{
-       free(obj);
-}
-
-void snd_ctl_elem_list_copy(snd_ctl_elem_list_t *dst, const snd_ctl_elem_list_t *src)
-{
-       assert(dst && src);
-       *dst = *src;
-}
-
-void snd_ctl_elem_list_set_offset(snd_ctl_elem_list_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->offset = val;
-}
-
-unsigned int snd_ctl_elem_list_get_used(const snd_ctl_elem_list_t *obj)
-{
-       assert(obj);
-       return obj->used;
-}
-
-unsigned int snd_ctl_elem_list_get_count(const snd_ctl_elem_list_t *obj)
-{
-       assert(obj);
-       return obj->count;
-}
-
-void snd_ctl_elem_list_get_id(const snd_ctl_elem_list_t *obj, unsigned int idx, snd_ctl_elem_id_t *ptr)
-{
-       assert(obj && ptr);
-       assert(idx < obj->used);
-       *ptr = obj->pids[idx];
-}
-
-unsigned int snd_ctl_elem_list_get_numid(const snd_ctl_elem_list_t *obj, unsigned int idx)
-{
-       assert(obj);
-       assert(idx < obj->used);
-       return obj->pids[idx].numid;
-}
-
-snd_ctl_elem_iface_t snd_ctl_elem_list_get_interface(const snd_ctl_elem_list_t *obj, unsigned int idx)
-{
-       assert(obj);
-       assert(idx < obj->used);
-       return snd_int_to_enum(obj->pids[idx].iface);
-}
-
-unsigned int snd_ctl_elem_list_get_device(const snd_ctl_elem_list_t *obj, unsigned int idx)
-{
-       assert(obj);
-       assert(idx < obj->used);
-       return obj->pids[idx].device;
-}
-
-unsigned int snd_ctl_elem_list_get_subdevice(const snd_ctl_elem_list_t *obj, unsigned int idx)
-{
-       assert(obj);
-       assert(idx < obj->used);
-       return obj->pids[idx].subdevice;
-}
-
-const char *snd_ctl_elem_list_get_name(const snd_ctl_elem_list_t *obj, unsigned int idx)
-{
-       assert(obj);
-       assert(idx < obj->used);
-       return obj->pids[idx].name;
-}
-
-unsigned int snd_ctl_elem_list_get_index(const snd_ctl_elem_list_t *obj, unsigned int idx)
-{
-       assert(obj);
-       assert(idx < obj->used);
-       return obj->pids[idx].index;
-}
-
-size_t snd_ctl_elem_info_sizeof()
-{
-       return sizeof(snd_ctl_elem_info_t);
-}
-
-int snd_ctl_elem_info_malloc(snd_ctl_elem_info_t **ptr)
-{
-       assert(ptr);
-       *ptr = calloc(1, sizeof(snd_ctl_elem_info_t));
-       if (!*ptr)
-               return -ENOMEM;
-       return 0;
-}
-
-void snd_ctl_elem_info_free(snd_ctl_elem_info_t *obj)
-{
-       free(obj);
-}
-
-void snd_ctl_elem_info_copy(snd_ctl_elem_info_t *dst, const snd_ctl_elem_info_t *src)
-{
-       assert(dst && src);
-       *dst = *src;
-}
-
-snd_ctl_elem_type_t snd_ctl_elem_info_get_type(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return snd_int_to_enum(obj->type);
-}
-
-int snd_ctl_elem_info_is_readable(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_READ);
-}
-
-int snd_ctl_elem_info_is_writable(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_WRITE);
-}
-
-int snd_ctl_elem_info_is_volatile(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_VOLATILE);
-}
-
-int snd_ctl_elem_info_is_inactive(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE);
-}
-
-int snd_ctl_elem_info_is_locked(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_LOCK);
-}
-
-int snd_ctl_elem_info_is_indirect(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_INDIRECT);
-}
-
-unsigned int snd_ctl_elem_info_get_count(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return obj->count;
-}
-
-long snd_ctl_elem_info_get_min(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       assert(obj->type == SNDRV_CTL_ELEM_TYPE_INTEGER);
-       return obj->value.integer.min;
-}
-
-long snd_ctl_elem_info_get_max(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       assert(obj->type == SNDRV_CTL_ELEM_TYPE_INTEGER);
-       return obj->value.integer.max;
-}
-
-long snd_ctl_elem_info_get_step(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       assert(obj->type == SNDRV_CTL_ELEM_TYPE_INTEGER);
-       return obj->value.integer.step;
-}
-
-unsigned int snd_ctl_elem_info_get_items(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       assert(obj->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED);
-       return obj->value.enumerated.items;
-}
-
-void snd_ctl_elem_info_set_item(snd_ctl_elem_info_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->value.enumerated.item = val;
-}
-
-const char *snd_ctl_elem_info_get_item_name(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       assert(obj->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED);
-       return obj->value.enumerated.name;
-}
-
-void snd_ctl_elem_info_get_id(const snd_ctl_elem_info_t *obj, snd_ctl_elem_id_t *ptr)
-{
-       assert(obj && ptr);
-       *ptr = obj->id;
-}
-
-unsigned int snd_ctl_elem_info_get_numid(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return obj->id.numid;
-}
-
-snd_ctl_elem_iface_t snd_ctl_elem_info_get_interface(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return snd_int_to_enum(obj->id.iface);
-}
-
-unsigned int snd_ctl_elem_info_get_device(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return obj->id.device;
-}
-
-unsigned int snd_ctl_elem_info_get_subdevice(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return obj->id.subdevice;
-}
-
-const char *snd_ctl_elem_info_get_name(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return obj->id.name;
-}
-
-unsigned int snd_ctl_elem_info_get_index(const snd_ctl_elem_info_t *obj)
-{
-       assert(obj);
-       return obj->id.index;
-}
-
-void snd_ctl_elem_info_set_id(snd_ctl_elem_info_t *obj, const snd_ctl_elem_id_t *ptr)
-{
-       assert(obj && ptr);
-       obj->id = *ptr;
-}
-
-void snd_ctl_elem_info_set_numid(snd_ctl_elem_info_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->id.numid = val;
-}
-
-void snd_ctl_elem_info_set_interface(snd_ctl_elem_info_t *obj, snd_ctl_elem_iface_t val)
-{
-       assert(obj);
-       obj->id.iface = snd_enum_to_int(val);
-}
-
-void snd_ctl_elem_info_set_device(snd_ctl_elem_info_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->id.device = val;
-}
-
-void snd_ctl_elem_info_set_subdevice(snd_ctl_elem_info_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->id.subdevice = val;
-}
-
-void snd_ctl_elem_info_set_name(snd_ctl_elem_info_t *obj, const char *val)
-{
-       assert(obj);
-       strncpy(obj->id.name, val, sizeof(obj->id.name));
-}
-
-void snd_ctl_elem_info_set_index(snd_ctl_elem_info_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->id.index = val;
-}
-
-size_t snd_ctl_elem_value_sizeof()
-{
-       return sizeof(snd_ctl_elem_value_t);
-}
-
-int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr)
-{
-       assert(ptr);
-       *ptr = calloc(1, sizeof(snd_ctl_elem_value_t));
-       if (!*ptr)
-               return -ENOMEM;
-       return 0;
-}
-
-void snd_ctl_elem_value_free(snd_ctl_elem_value_t *obj)
-{
-       free(obj);
-}
-
-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_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_value_get_numid(const snd_ctl_elem_value_t *obj)
-{
-       assert(obj);
-       return obj->id.numid;
-}
-
-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_value_get_device(const snd_ctl_elem_value_t *obj)
-{
-       assert(obj);
-       return obj->id.device;
-}
-
-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_value_get_name(const snd_ctl_elem_value_t *obj)
-{
-       assert(obj);
-       return obj->id.name;
-}
-
-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_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_value_set_numid(snd_ctl_elem_value_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->id.numid = 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_value_set_device(snd_ctl_elem_value_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->id.device = 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_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_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val)
-{
-       assert(obj);
-       obj->id.index = val;
-}
-
-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_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_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_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_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_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_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_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_value_get_bytes(const snd_ctl_elem_value_t *obj)
-{
-       assert(obj);
-       return obj->value.bytes.data;
-}
-
-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_value_set_iec958(snd_ctl_elem_value_t *obj, const snd_aes_iec958_t *ptr)
-{
-       assert(obj && ptr);
-       obj->value.iec958 = *ptr;
-}
-
-void snd_hctl_elem_get_id(const snd_hctl_elem_t *obj, snd_ctl_elem_id_t *ptr)
-{
-       assert(obj && ptr);
-       *ptr = obj->id;
-}
-
-unsigned int snd_hctl_elem_get_numid(const snd_hctl_elem_t *obj)
-{
-       assert(obj);
-       return obj->id.numid;
-}
-
-snd_ctl_elem_iface_t snd_hctl_elem_get_interface(const snd_hctl_elem_t *obj)
-{
-       assert(obj);
-       return snd_int_to_enum(obj->id.iface);
-}
-
-unsigned int snd_hctl_elem_get_device(const snd_hctl_elem_t *obj)
-{
-       assert(obj);
-       return obj->id.device;
-}
-
-unsigned int snd_hctl_elem_get_subdevice(const snd_hctl_elem_t *obj)
-{
-       assert(obj);
-       return obj->id.subdevice;
-}
-
-const char *snd_hctl_elem_get_name(const snd_hctl_elem_t *obj)
-{
-       assert(obj);
-       return obj->id.name;
-}
-
-unsigned int snd_hctl_elem_get_index(const snd_hctl_elem_t *obj)
-{
-       assert(obj);
-       return obj->id.index;
-}
-
-void snd_hctl_elem_set_callback(snd_hctl_elem_t *obj, snd_hctl_elem_callback_t val)
-{
-       assert(obj);
-       obj->callback = val;
-}
-
-void * snd_hctl_elem_get_callback_private(const snd_hctl_elem_t *obj)
-{
-       assert(obj);
-       return obj->callback_private;
-}
-
-void snd_hctl_elem_set_callback_private(snd_hctl_elem_t *obj, void * val)
-{
-       assert(obj);
-       obj->callback_private = val;
-}
-
index 98a3fe2ce2d4453f84eaa7a0861cfa5c242e5d5a..3de354230aab6d2e7b6298d24ab47726d78b72c3 100644 (file)
@@ -1,3 +1,12 @@
+/**
+ * \file control/hcontrol.c
+ * \author Jaroslav Kysela <perex@suse.cz>
+ * \author Abramo Bagnara <abramo@alsa-project.org>
+ * \date 2000
+ *
+ * HCTL interface is designed to access preloaded and sorted primitive controls.
+ * Callbacks may be used for event handling.
+ */
 /*
  *  Control Interface - highlevel API
  *  Copyright (c) 2000 by Jaroslav Kysela <perex@suse.cz>
@@ -20,6 +29,7 @@
  *
  */
 
+#ifndef DOC_HIDDEN  
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 static int snd_hctl_compare_default(const snd_hctl_elem_t *c1,
                                    const snd_hctl_elem_t *c2);
 
+#endif
+
+/**
+ * \brief Opens an HCTL
+ * \param hctlp Returned HCTL handle
+ * \param name ASCII identifier of the underlying CTL handle
+ * \param mode Open mode (see #SND_CTL_NONBLOCK, #SND_CTL_ASYNC)
+ * \return 0 on success otherwise a negative error code
+ */
 int snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode)
 {
        snd_hctl_t *hctl;
@@ -54,6 +73,14 @@ int snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode)
        return 0;
 }
 
+/**
+ * \brief close HCTL handle
+ * \param hctl HCTL handle
+ * \return 0 on success otherwise a negative error code
+ *
+ * Closes the specified HCTL handle and frees all associated
+ * resources.
+ */
 int snd_hctl_close(snd_hctl_t *hctl)
 {
        int err;
@@ -65,37 +92,72 @@ int snd_hctl_close(snd_hctl_t *hctl)
        return err;
 }
 
+/**
+ * \brief get identifier of HCTL handle
+ * \param hctl HCTL handle
+ * \return ascii identifier of HCTL handle
+ *
+ * Returns the ASCII identifier of given HCTL handle. It's the same
+ * identifier specified in snd_hctl_open().
+ */
 const char *snd_hctl_name(snd_hctl_t *hctl)
 {
        assert(hctl);
        return snd_ctl_name(hctl->ctl);
 }
 
+/**
+ * \brief set nonblock mode
+ * \param hctl HCTL handle
+ * \param nonblock 0 = block, 1 = nonblock mode
+ * \return 0 on success otherwise a negative error code
+ */
 int snd_hctl_nonblock(snd_hctl_t *hctl, int nonblock)
 {
        assert(hctl);
        return snd_ctl_nonblock(hctl->ctl, nonblock);
 }
 
+/**
+ * \brief set async mode
+ * \param hctl HCTL handle
+ * \param sig Signal to raise: < 0 disable, 0 default (SIGIO)
+ * \param pid Process ID to signal: 0 current
+ * \return 0 on success otherwise a negative error code
+ *
+ * A signal is raised when a change happens.
+ */
 int snd_hctl_async(snd_hctl_t *hctl, int sig, pid_t pid)
 {
        assert(hctl);
        return snd_ctl_async(hctl->ctl, sig, pid);
 }
 
+/**
+ * \brief get count of poll descriptors for HCTL handle
+ * \param hctl HCTL handle
+ * \return count of poll descriptors
+ */
 int snd_hctl_poll_descriptors_count(snd_hctl_t *hctl)
 {
        assert(hctl);
        return snd_ctl_poll_descriptors_count(hctl->ctl);
 }
 
+/**
+ * \brief get poll descriptors
+ * \param hctl HCTL handle
+ * \param pfds array of poll descriptors
+ * \param space space in the poll descriptor array
+ * \return count of filled descriptors
+ */
 int snd_hctl_poll_descriptors(snd_hctl_t *hctl, struct pollfd *pfds, unsigned int space)
 {
        assert(hctl);
        return snd_ctl_poll_descriptors(hctl->ctl, pfds, space);
 }
 
-int snd_hctl_throw_event(snd_hctl_t *hctl, unsigned int mask,
+static int snd_hctl_throw_event(snd_hctl_t *hctl, unsigned int mask,
                         snd_hctl_elem_t *elem)
 {
        if (hctl->callback)
@@ -103,7 +165,7 @@ int snd_hctl_throw_event(snd_hctl_t *hctl, unsigned int mask,
        return 0;
 }
 
-int snd_hctl_elem_throw_event(snd_hctl_elem_t *elem,
+static int snd_hctl_elem_throw_event(snd_hctl_elem_t *elem,
                              unsigned int mask)
 {
        if (elem->callback)
@@ -274,6 +336,11 @@ static void snd_hctl_elem_remove(snd_hctl_t *hctl, unsigned int idx)
                        m * sizeof(snd_hctl_elem_t *));
 }
 
+/**
+ * \brief free HCTL loaded elements
+ * \param hctl HCTL handle
+ * \return 0 on success otherwise a negative error code
+ */
 int snd_hctl_free(snd_hctl_t *hctl)
 {
        while (hctl->count > 0)
@@ -300,14 +367,26 @@ static void snd_hctl_sort(snd_hctl_t *hctl)
                list_add_tail(&hctl->pelems[k]->list, &hctl->elems);
 }
 
-int snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t hsort)
+/**
+ * \brief Change HCTL compare function and reorder elements
+ * \param hctl HCTL handle
+ * \param compare Element compare function
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t compare)
 {
        assert(hctl);
-       hctl->compare = hsort == NULL ? snd_hctl_compare_default : hsort;
+       hctl->compare = compare == NULL ? snd_hctl_compare_default : compare;
        snd_hctl_sort(hctl);
        return 0;
 }
 
+/**
+ * \brief A "don't care" fast compare functions that may be used with #snd_hctl_set_compare
+ * \param c1 First HCTL element
+ * \param c2 Second HCTL element
+ * \return -1 if c1 < c2, 0 if c1 == c2, 1 if c1 > c2
+ */
 int snd_hctl_compare_fast(const snd_hctl_elem_t *c1,
                          const snd_hctl_elem_t *c2)
 {
@@ -333,6 +412,11 @@ static int snd_hctl_compare_default(const snd_hctl_elem_t *c1,
        return d;
 }
 
+/**
+ * \brief get first element for an HCTL
+ * \param hctl HCTL handle
+ * \return pointer to first element
+ */
 snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl)
 {
        assert(hctl);
@@ -341,6 +425,11 @@ snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl)
        return list_entry(hctl->elems.next, snd_hctl_elem_t, list);
 }
 
+/**
+ * \brief get last element for an HCTL
+ * \param hctl HCTL handle
+ * \return pointer to last element
+ */
 snd_hctl_elem_t *snd_hctl_last_elem(snd_hctl_t *hctl)
 {
        assert(hctl);
@@ -349,6 +438,11 @@ snd_hctl_elem_t *snd_hctl_last_elem(snd_hctl_t *hctl)
        return list_entry(hctl->elems.prev, snd_hctl_elem_t, list);
 }
 
+/**
+ * \brief get next HCTL element
+ * \param elem HCTL element
+ * \return pointer to next element
+ */
 snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem)
 {
        assert(elem);
@@ -357,6 +451,11 @@ snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem)
        return list_entry(elem->list.next, snd_hctl_elem_t, list);
 }
 
+/**
+ * \brief get previous HCTL element
+ * \param elem HCTL element
+ * \return pointer to previous element
+ */
 snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem)
 {
        assert(elem);
@@ -365,6 +464,12 @@ snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem)
        return list_entry(elem->list.prev, snd_hctl_elem_t, list);
 }
 
+/**
+ * \brief Search an HCTL element
+ * \param hctl HCTL handle
+ * \param id Element identificator
+ * \return pointer to found HCTL element or NULL if it does not exists
+ */
 snd_hctl_elem_t *snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id)
 {
        int dir;
@@ -374,6 +479,11 @@ snd_hctl_elem_t *snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *i
        return hctl->pelems[res];
 }
 
+/**
+ * \brief Load an HCTL with all elements and sort them
+ * \param hctl HCTL handle
+ * \return 0 on success otherwise a negative error code
+ */
 int snd_hctl_load(snd_hctl_t *hctl)
 {
        snd_ctl_elem_list_t list;
@@ -435,29 +545,55 @@ int snd_hctl_load(snd_hctl_t *hctl)
        return err;
 }
 
+/**
+ * \brief Set callback function for an HCTL
+ * \param hctl HCTL handle
+ * \param callback callback function
+ */
 void snd_hctl_set_callback(snd_hctl_t *hctl, snd_hctl_callback_t callback)
 {
        assert(hctl);
        hctl->callback = callback;
 }
 
+/**
+ * \brief Set callback private value for an HCTL
+ * \param hctl HCTL handle
+ * \param callback_private callback private value
+ */
 void snd_hctl_set_callback_private(snd_hctl_t *hctl, void *callback_private)
 {
        assert(hctl);
        hctl->callback_private = callback_private;
 }
 
+/**
+ * \brief Get callback private value for an HCTL
+ * \param hctl HCTL handle
+ * \return callback private value
+ */
 void *snd_hctl_get_callback_private(snd_hctl_t *hctl)
 {
        assert(hctl);
        return hctl->callback_private;
 }
 
+/**
+ * \brief Get number of loaded elements for an HCTL
+ * \param hctl HCTL handle
+ * \return elements count
+ */
 unsigned int snd_hctl_get_count(snd_hctl_t *hctl)
 {
        return hctl->count;
 }
 
+/**
+ * \brief Wait for a HCTL to become ready (i.e. at least one event pending)
+ * \param hctl HCTL handle
+ * \param timeout maximum time in milliseconds to wait
+ * \return 0 otherwise a negative error code on failure
+ */
 int snd_hctl_wait(snd_hctl_t *hctl, int timeout)
 {
        struct pollfd pfd;
@@ -470,7 +606,7 @@ int snd_hctl_wait(snd_hctl_t *hctl, int timeout)
        return 0;
 }
 
-int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
+static int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
 {
        snd_hctl_elem_t *elem;
        int res;
@@ -517,6 +653,11 @@ int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
        return 0;
 }
 
+/**
+ * \brief Handle pending HCTL events invoking callbacks
+ * \param hctl HCTL handle
+ * \return 0 otherwise a negative error code on failure
+ */
 int snd_hctl_handle_events(snd_hctl_t *hctl)
 {
        snd_ctl_event_t event;
@@ -537,6 +678,12 @@ int snd_hctl_handle_events(snd_hctl_t *hctl)
        return count;
 }
 
+/**
+ * \brief Get information for an HCTL element
+ * \param elem HCTL element
+ * \param info HCTL element information
+ * \return 0 otherwise a negative error code on failure
+ */
 int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t *info)
 {
        assert(elem);
@@ -546,6 +693,12 @@ int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t *info)
        return snd_ctl_elem_info(elem->hctl->ctl, info);
 }
 
+/**
+ * \brief Get value for an HCTL element
+ * \param elem HCTL element
+ * \param value HCTL element value
+ * \return 0 otherwise a negative error code on failure
+ */
 int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
 {
        assert(elem);
@@ -555,6 +708,12 @@ int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
        return snd_ctl_elem_read(elem->hctl->ctl, value);
 }
 
+/**
+ * \brief Set value for an HCTL element
+ * \param elem HCTL element
+ * \param value HCTL element value
+ * \return 0 otherwise a negative error code on failure
+ */
 int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
 {
        assert(elem);
@@ -564,8 +723,124 @@ int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value)
        return snd_ctl_elem_write(elem->hctl->ctl, value);
 }
 
+/**
+ * \brief Get HCTL handle for an HCTL element
+ * \param elem HCTL element
+ * \return HCTL handle
+ */
 snd_hctl_t *snd_hctl_elem_get_hctl(snd_hctl_elem_t *elem)
 {
        assert(elem);
        return elem->hctl;
 }
+
+/**
+ * \brief Get CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \param ptr Pointer to returned CTL element identificator
+ */
+void snd_hctl_elem_get_id(const snd_hctl_elem_t *obj, snd_ctl_elem_id_t *ptr)
+{
+       assert(obj && ptr);
+       *ptr = obj->id;
+}
+
+/**
+ * \brief Get element numeric identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return element numeric identificator
+ */
+unsigned int snd_hctl_elem_get_numid(const snd_hctl_elem_t *obj)
+{
+       assert(obj);
+       return obj->id.numid;
+}
+
+/**
+ * \brief Get interface part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return interface part of element identificator
+ */
+snd_ctl_elem_iface_t snd_hctl_elem_get_interface(const snd_hctl_elem_t *obj)
+{
+       assert(obj);
+       return snd_int_to_enum(obj->id.iface);
+}
+
+/**
+ * \brief Get device part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return device part of element identificator
+ */
+unsigned int snd_hctl_elem_get_device(const snd_hctl_elem_t *obj)
+{
+       assert(obj);
+       return obj->id.device;
+}
+
+/**
+ * \brief Get subdevice part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return subdevice part of element identificator
+ */
+unsigned int snd_hctl_elem_get_subdevice(const snd_hctl_elem_t *obj)
+{
+       assert(obj);
+       return obj->id.subdevice;
+}
+
+/**
+ * \brief Get name part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return name part of element identificator
+ */
+const char *snd_hctl_elem_get_name(const snd_hctl_elem_t *obj)
+{
+       assert(obj);
+       return obj->id.name;
+}
+
+/**
+ * \brief Get index part of CTL element identificator of a CTL element id/value
+ * \param obj CTL element id/value
+ * \return index part of element identificator
+ */
+unsigned int snd_hctl_elem_get_index(const snd_hctl_elem_t *obj)
+{
+       assert(obj);
+       return obj->id.index;
+}
+
+/**
+ * \brief Set callback function for an HCTL element
+ * \param obj HCTL element
+ * \param val callback function
+ */
+void snd_hctl_elem_set_callback(snd_hctl_elem_t *obj, snd_hctl_elem_callback_t val)
+{
+       assert(obj);
+       obj->callback = val;
+}
+
+/**
+ * \brief Set callback private value for an HCTL element
+ * \param obj HCTL element
+ * \param val callback private value
+ */
+void snd_hctl_elem_set_callback_private(snd_hctl_elem_t *obj, void * val)
+{
+       assert(obj);
+       obj->callback_private = val;
+}
+
+/**
+ * \brief Get callback private value for an HCTL element
+ * \param obj HCTL element
+ * \return callback private value
+ */
+void * snd_hctl_elem_get_callback_private(const snd_hctl_elem_t *obj)
+{
+       assert(obj);
+       return obj->callback_private;
+}
+
index 53b6d71d1e87fdf1faf47c85778a0a17fb328466..80416d48dbd484ccba2ce4c942fc9f11ed2c5cfb 100644 (file)
@@ -79,12 +79,10 @@ static void snd_lib_error_default(const char *file, int line, const char *functi
        va_end(arg);
 }
 
-#ifndef DOC_HIDDEN
 /**
  * Pointer to the error handler function.
  */
 snd_lib_error_handler_t *snd_lib_error = snd_lib_error_default;
-#endif
 
 /**
  * \brief Set the error handler.
index 52da5aff2d08e6e193eb2324a3d150c2c219464b..c422732ff571fac80e9421e16de0aeccf60fe31d 100644 (file)
@@ -192,12 +192,13 @@ int snd_input_stdio_attach(snd_input_t **inputp, FILE *fp, int close)
  * \brief Open a new input from a file
  * \param inputp Pointer to returned input handle
  * \param file File name
+ * \param mode fopen(3) open mode
  * \return 0 on success otherwise a negative error code
  */
-int snd_input_stdio_open(snd_input_t **inputp, const char *file)
+int snd_input_stdio_open(snd_input_t **inputp, const char *file, const char *mode)
 {
        int err;
-       FILE *fp = fopen(file, "r");
+       FILE *fp = fopen(file, mode);
        if (!fp) {
                //SYSERR("fopen");
                return -errno;
index 2b3886d9b7d9a2a15d6206c00334de5d2343afd9..af30c9afcfacd5d948c69e557d17e002600ac708 100644 (file)
@@ -187,10 +187,17 @@ int snd_output_stdio_attach(snd_output_t **outputp, FILE *fp, int close)
        return 0;
 }
        
-int snd_output_stdio_open(snd_output_t **outputp, const char *file)
+/**
+ * \brief Open a new output to a file
+ * \param outputp Pointer to returned output handle
+ * \param file File name
+ * \param mode fopen(3) open mode
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_output_stdio_open(snd_output_t **outputp, const char *file, const char *mode)
 {
        int err;
-       FILE *fp = fopen(file, "w");
+       FILE *fp = fopen(file, mode);
        if (!fp) {
                //SYSERR("fopen");
                return -errno;