]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: add snd_use_case_parse_ctl_elem_id()
authorJaroslav Kysela <perex@perex.cz>
Tue, 5 Nov 2019 19:04:54 +0000 (20:04 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 14 Nov 2019 14:00:40 +0000 (15:00 +0100)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
include/use-case.h
src/ucm/main.c

index 37d0572a05bfc2ca3aed21a356ce488fcda19956..109502aa842f89181a4366fa17f41f651bfc23d5 100644 (file)
@@ -439,6 +439,17 @@ static __inline__ int snd_use_case_verb_list(snd_use_case_mgr_t *uc_mgr,
        return snd_use_case_get_list(uc_mgr, "_verbs", list);
 }
 
+/**
+ * \brief Parse control element identifier
+ * \param elem_id Element identifier
+ * \param ucm_id Use case identifier
+ * \param value String value to be parsed
+ * \return Zero if success, otherwise a negative error code
+ */
+int snd_use_case_parse_ctl_elem_id(snd_ctl_elem_id_t *dst,
+                                  const char *ucm_id, char *value);
+
+
 /**
  *  \}
  */
index 25c02e1e09879dc6cc58329a97e87c17a8f8adde..773c72583796e357c0f05219abb52ec57b0c3114 100644 (file)
@@ -1920,3 +1920,26 @@ int snd_use_case_set(snd_use_case_mgr_t *uc_mgr,
        pthread_mutex_unlock(&uc_mgr->mutex);
         return err;
 }
+
+/**
+ * \brief Parse control element identifier
+ * \param elem_id Element identifier
+ * \param ucm_id Use case identifier
+ * \param value String value to be parsed
+ * \return Zero if success, otherwise a negative error code
+ */
+int snd_use_case_parse_ctl_elem_id(snd_ctl_elem_id_t *dst,
+                                  const char *ucm_id, char *value)
+{
+       snd_ctl_elem_iface_t iface;
+
+       snd_ctl_elem_id_clear(dst);
+       if (strcasestr(ucm_id, "name="))
+               return __snd_ctl_ascii_elem_id_parse(dst, value, NULL);
+       iface = SND_CTL_ELEM_IFACE_MIXER;
+       if (strcasecmp(ucm_id, "JackControl") == 0)
+               iface = SND_CTL_ELEM_IFACE_CARD;
+       snd_ctl_elem_id_set_interface(dst, iface);
+       snd_ctl_elem_id_set_name(dst, value);
+       return 0;
+}