diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2006-10-27 10:54:08 +0200 |
---|---|---|
committer | Clemens Ladisch <clemens@ladisch.de> | 2006-10-27 10:54:08 +0200 |
commit | 252fd434613a3f48479737e9fe2772b5a3e1fa4f (patch) | |
tree | 4e2207d7c45258d200dce2bd6652eac8b66b9792 /src/rawmidi | |
parent | ddf9599542692ab3747f138ac73a777adde2de64 (diff) | |
download | alsa-lib-252fd434613a3f48479737e9fe2772b5a3e1fa4f.tar.gz |
rawmidi: do not abort when seeing the hint node
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.
Diffstat (limited to 'src/rawmidi')
-rw-r--r-- | src/rawmidi/rawmidi.c | 16 | ||||
-rw-r--r-- | src/rawmidi/rawmidi_hw.c | 4 | ||||
-rw-r--r-- | src/rawmidi/rawmidi_local.h | 2 | ||||
-rw-r--r-- | src/rawmidi/rawmidi_virt.c | 4 |
4 files changed, 20 insertions, 6 deletions
diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 87ef91c9..7f45742b 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -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; +} diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c index 2f7d9a29..07d6aa64 100644 --- a/src/rawmidi/rawmidi_hw.c +++ b/src/rawmidi/rawmidi_hw.c @@ -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); diff --git a/src/rawmidi/rawmidi_local.h b/src/rawmidi/rawmidi_local.h index 80a2524b..4918c25d 100644 --- a/src/rawmidi/rawmidi_local.h +++ b/src/rawmidi/rawmidi_local.h @@ -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); diff --git a/src/rawmidi/rawmidi_virt.c b/src/rawmidi/rawmidi_virt.c index a06476aa..a221f986 100644 --- a/src/rawmidi/rawmidi_virt.c +++ b/src/rawmidi/rawmidi_virt.c @@ -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); |