]> git.alsa-project.org Git - alsa-lib.git/commitdiff
rawmidi: do not abort when seeing the hint node
authorClemens Ladisch <clemens@ladisch.de>
Fri, 27 Oct 2006 08:54:08 +0000 (10:54 +0200)
committerClemens Ladisch <clemens@ladisch.de>
Fri, 27 Oct 2006 08:54:08 +0000 (10:54 +0200)
Add the hint node to the nodes that are allowed in rawmidi definitions,
and factor out the detection of such nodes into a common function.

src/rawmidi/rawmidi.c
src/rawmidi/rawmidi_hw.c
src/rawmidi/rawmidi_local.h
src/rawmidi/rawmidi_virt.c

index 87ef91c9c691824a5d5aa8c18a01337e4018f3d3..7f45742b97f676174d3b0b05e2345cec4f7d40bc 100644 (file)
@@ -987,3 +987,19 @@ 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);
 }
+
+int snd_rawmidi_conf_generic_id(const char *id)
+{
+       static const char *ids[] = {
+               "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;
+}
index 2f7d9a294f805a0f171e9017e48a7fd86cd5e31e..07d6aa64d7117edb04868e33b467c1628c773c61 100644 (file)
@@ -337,9 +337,7 @@ int _snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
                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_rawmidi_conf_generic_id(id))
                        continue;
                if (strcmp(id, "card") == 0) {
                        err = snd_config_get_integer(n, &card);
index 80a2524bb6ed93e688c2476672d5cfc5dc07d2ae..4918c25d67adfaf50545338bce91a2f9e746e1e3 100644 (file)
@@ -57,3 +57,5 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **input, snd_rawmidi_t **output,
 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);
index a06476aa3e625515a40074ccec160ac3665ec711..a221f986a6c753b7562d655c9d3bbec7a34ab847 100644 (file)
@@ -411,9 +411,7 @@ int _snd_rawmidi_virtual_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
                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_rawmidi_conf_generic_id(id))
                        continue;
                if (strcmp(id, "slave") == 0) {
                        err = snd_config_get_string(n, &slave_str);