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.
This commit is contained in:
Clemens Ladisch 2006-10-27 10:54:08 +02:00
parent ddf9599542
commit 252fd43461
4 changed files with 20 additions and 6 deletions

View 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;
}

View 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);

View 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);

View 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);