]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Allow hint for ctl, hwdep, timer and seq
authorTakashi Iwai <tiwai@suse.de>
Thu, 30 Apr 2015 12:52:35 +0000 (14:52 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 30 Apr 2015 12:52:35 +0000 (14:52 +0200)
Like pcm and rawmidi, each object parser needs to accept the hint
component.  Now a new local function _snd_conf_generic_id() was
introduced to replace each call of "comment" and "type" field checks.

Also, the two existing identical functions for pcm and rawmidi are
removed and the new function is used commonly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
12 files changed:
include/local.h
src/confmisc.c
src/control/control_hw.c
src/control/control_shm.c
src/hwdep/hwdep_hw.c
src/pcm/pcm.c
src/pcm/pcm_local.h
src/rawmidi/rawmidi.c
src/rawmidi/rawmidi_local.h
src/seq/seq_hw.c
src/timer/timer_hw.c
src/timer/timer_query_hw.c

index 2fe9a273f0b057b66a4d1be67744a8512df1e409..660081638a1c0878277043b7fd5b9a9cfb8fb1e9 100644 (file)
@@ -348,4 +348,6 @@ int snd_config_search_alias_hooks(snd_config_t *config,
                                   const char *base, const char *key,
                                  snd_config_t **result);
 
+int _snd_conf_generic_id(const char *id);
+
 #endif
index af686bea323c6ec8ac8bdb2e1e02e1c01148fd9c..1fb4f282217e45f94d16ffb2d895adb15f96fe9e 100644 (file)
@@ -1302,3 +1302,16 @@ int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
 #ifndef DOC_HIDDEN
 SND_DLSYM_BUILD_VERSION(snd_func_refer, SND_CONFIG_DLSYM_VERSION_EVALUATE);
 #endif
+
+#ifndef DOC_HIDDEN
+int _snd_conf_generic_id(const char *id)
+{
+       static const char ids[3][8] = { "comment", "type", "hint" };
+       unsigned int k;
+       for (k = 0; k < sizeof(ids) / sizeof(ids[0]); ++k) {
+               if (strcmp(id, ids[k]) == 0)
+                       return 1;
+       }
+       return 0;
+}
+#endif
index dfc9dcd51e20acf68669d73300af26e55dc364d5..7d23151c7d75d78390ec4312a09ff1e7f9d82924 100644 (file)
@@ -446,9 +446,7 @@ int _snd_ctl_hw_open(snd_ctl_t **handlep, char *name, snd_config_t *root ATTRIBU
                const char *id;
                if (snd_config_get_id(n, &id) < 0)
                        continue;
-               if (strcmp(id, "comment") == 0)
-                       continue;
-               if (strcmp(id, "type") == 0)
+               if (_snd_conf_generic_id(id))
                        continue;
                if (strcmp(id, "card") == 0) {
                        err = snd_config_get_integer(n, &card);
index 40bc705d8036086c43bee959ebfec41615c3a1dc..bd07d4af503aeafd826d9a009280f8c4085f47ed 100644 (file)
@@ -551,10 +551,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c
                const char *id;
                if (snd_config_get_id(n, &id) < 0)
                        continue;
-               if (strcmp(id, "comment") == 0)
-                       continue;
-               if (strcmp(id, "type") == 0)
-                       continue;
+               if (_snd_conf_generic_id(id))
                if (strcmp(id, "server") == 0) {
                        err = snd_config_get_string(n, &server);
                        if (err < 0) {
@@ -597,7 +594,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c
                const char *id;
                if (snd_config_get_id(n, &id) < 0)
                        continue;
-               if (strcmp(id, "comment") == 0)
+               if (_snd_conf_generic_id(id))
                        continue;
                if (strcmp(id, "host") == 0)
                        continue;
index 4314e32bade67ecfa330ab129575da0fbfc43063..12528c55bac7c6ae52156da0213cb36bcea6cb12 100644 (file)
@@ -158,9 +158,7 @@ int _snd_hwdep_hw_open(snd_hwdep_t **hwdep, char *name,
                const char *id;
                if (snd_config_get_id(n, &id) < 0)
                        continue;
-               if (strcmp(id, "comment") == 0)
-                       continue;
-               if (strcmp(id, "type") == 0)
+               if (_snd_conf_generic_id(id))
                        continue;
                if (strcmp(id, "card") == 0) {
                        err = snd_config_get_integer(n, &card);
index e74e02fc568f14d4e8006d9d5ab5cb1130eeee68..bc18954b92da124bafd3a67913bd3c8900dd012f 100644 (file)
@@ -7059,18 +7059,6 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
        return err;
 }
                
-
-int snd_pcm_conf_generic_id(const char *id)
-{
-       static const char ids[3][8] = { "comment", "type", "hint" };
-       unsigned int k;
-       for (k = 0; k < sizeof(ids) / sizeof(ids[0]); ++k) {
-               if (strcmp(id, ids[k]) == 0)
-                       return 1;
-       }
-       return 0;
-}
-
 static void snd_pcm_set_ptr(snd_pcm_t *pcm, snd_pcm_rbptr_t *rbptr,
                            volatile snd_pcm_uframes_t *hw_ptr, int fd, off_t offset)
 {
index 394505f978ace3b2de052c4d3102f473c543577e..326618ecd0c0e3ce910db78decb96a0fe29e20a5 100644 (file)
@@ -262,8 +262,6 @@ struct _snd_pcm {
        snd1_pcm_areas_from_bufs
 #define snd_pcm_open_named_slave \
        snd1_pcm_open_named_slave
-#define snd_pcm_conf_generic_id \
-       snd1_pcm_conf_generic_id
 #define snd_pcm_hw_open_fd \
        snd1_pcm_hw_open_fd
 #define snd_pcm_wait_nocheck \
@@ -882,7 +880,8 @@ snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *root,
        return snd_pcm_open_named_slave(pcmp, NULL, root, conf, stream,
                                        mode, parent_conf);
 }
-int snd_pcm_conf_generic_id(const char *id);
+
+#define snd_pcm_conf_generic_id(id) _snd_conf_generic_id(id)
 
 int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, int mmap_emulation, int sync_ptr_ioctl);
 int __snd_pcm_mmap_emul_open(snd_pcm_t **pcmp, const char *name,
index ac699b439b11581ccee5873c9f7d04d9f30260c1..0c89b8b984b9e58049e42f0e423c369f61806a6f 100644 (file)
@@ -990,21 +990,3 @@ ssize_t snd_rawmidi_read(snd_rawmidi_t *rawmidi, void *buffer, size_t size)
        assert(buffer || size == 0);
        return (rawmidi->ops->read)(rawmidi, buffer, size);
 }
-
-#ifndef DOC_HIDDEN
-int snd_rawmidi_conf_generic_id(const char *id)
-{
-       static const char ids[][8] = {
-               "comment",
-               "type",
-               "hint",
-       };
-       unsigned int k;
-
-       for (k = 0; k < sizeof ids / sizeof *ids; ++k) {
-               if (strcmp(id, ids[k]) == 0)
-                       return 1;
-       }
-       return 0;
-}
-#endif
index 3388502cece0eb885f496c89a7f4ae110662cf78..8992771eb5d35d05bf6c260eb8f0f4120cd36ee2 100644 (file)
@@ -58,4 +58,4 @@ int snd_rawmidi_virtual_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
                             const char *name, snd_seq_t *seq_handle, int port,
                             int merge, int mode);
 
-int snd_rawmidi_conf_generic_id(const char *id);
+#define snd_rawmidi_conf_generic_id(id)        _snd_conf_generic_id(id)
index 6cb31d6f4c2503b330e4a6cfdd551d2908429719..d033367389444e3a9c0a4ccffd8f1efb8bd0ddb3 100644 (file)
@@ -546,9 +546,7 @@ int _snd_seq_hw_open(snd_seq_t **handlep, char *name,
                const char *id;
                if (snd_config_get_id(n, &id) < 0)
                        continue;
-               if (strcmp(id, "comment") == 0)
-                       continue;
-               if (strcmp(id, "type") == 0)
+               if (_snd_conf_generic_id(id))
                        continue;
                return -EINVAL;
        }
index aa6a0b1b42f108051a60ce28c261b84e7d163683..e833fc8cbb4124e4139dd0bbc87cc75f8f765706 100644 (file)
@@ -299,9 +299,7 @@ int _snd_timer_hw_open(snd_timer_t **timer, char *name,
                const char *id;
                if (snd_config_get_id(n, &id) < 0)
                        continue;
-               if (strcmp(id, "comment") == 0)
-                       continue;
-               if (strcmp(id, "type") == 0)
+               if (_snd_conf_generic_id(id))
                        continue;
                if (strcmp(id, "class") == 0) {
                        err = snd_config_get_integer(n, &dev_class);
index 9f62b78aeb2e1348739298263c3cd6bc31f6ffbc..289ca52f2afa8b9ffea312e7139e50df434f5a7d 100644 (file)
@@ -134,9 +134,7 @@ int _snd_timer_query_hw_open(snd_timer_query_t **timer, char *name,
                const char *id;
                if (snd_config_get_id(n, &id) < 0)
                        continue;
-               if (strcmp(id, "comment") == 0)
-                       continue;
-               if (strcmp(id, "type") == 0)
+               if (_snd_conf_generic_id(id))
                        continue;
                SNDERR("Unexpected field %s", id);
                return -EINVAL;