diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -427,7 +427,7 @@ else if (snd_unit_auto == 1) snd_unit = pcm_best_unit(snd_unit); - sndstat_register(dev, d->status); + sndstat_register(dev, SNDST_TYPE_PCM, d->status); return (dsp_make_dev(dev)); } diff --git a/sys/dev/sound/sndstat.h b/sys/dev/sound/sndstat.h --- a/sys/dev/sound/sndstat.h +++ b/sys/dev/sound/sndstat.h @@ -1,7 +1,12 @@ #ifndef _SNDSTAT_H_ #define _SNDSTAT_H_ -int sndstat_register(device_t dev, char *str); +enum sndstat_type { + SNDST_TYPE_PCM, + SNDST_TYPE_MIDI, +}; + +int sndstat_register(device_t dev, enum sndstat_type type, char *str); int sndstat_unregister(device_t dev); #endif /* _SNDSTAT_H_ */ diff --git a/sys/dev/sound/sndstat.c b/sys/dev/sound/sndstat.c --- a/sys/dev/sound/sndstat.c +++ b/sys/dev/sound/sndstat.c @@ -688,22 +688,26 @@ return (ENOMEM); TAILQ_FOREACH(ent, &sndstat_devlist, link) { - struct snddev_info *d; - nvlist_t *di; + if (ent->type == SNDST_TYPE_PCM) { + struct snddev_info *d; + nvlist_t *di; - d = device_get_softc(ent->dev); - if (!PCM_REGISTERED(d)) - continue; + d = device_get_softc(ent->dev); + if (!PCM_REGISTERED(d)) + continue; - err = sndstat_build_sound4_nvlist(d, &di); - if (err) - goto done; + err = sndstat_build_sound4_nvlist(d, &di); + if (err) + goto done; - nvlist_append_nvlist_array(nvl, SNDST_DSPS, di); - nvlist_destroy(di); - err = nvlist_error(nvl); - if (err) - goto done; + nvlist_append_nvlist_array(nvl, SNDST_DSPS, di); + nvlist_destroy(di); + err = nvlist_error(nvl); + if (err) + goto done; + } else if (ent->type == SNDST_TYPE_MIDI) { + /* TODO */ + } } TAILQ_FOREACH(pf, &sndstat_filelist, entry) { @@ -1155,21 +1159,13 @@ /************************************************************************/ int -sndstat_register(device_t dev, char *str) +sndstat_register(device_t dev, enum sndstat_type type, char *str) { struct sndstat_entry *ent; struct sndstat_entry *pre; - const char *devtype; - int type, unit; + int unit; unit = device_get_unit(dev); - devtype = device_get_name(dev); - if (!strcmp(devtype, "pcm")) - type = SS_TYPE_PCM; - else if (!strcmp(devtype, "midi")) - type = SS_TYPE_MIDI; - else - return (EINVAL); ent = malloc(sizeof *ent, M_DEVBUF, M_WAITOK | M_ZERO); ent->dev = dev; @@ -1388,20 +1384,24 @@ /* generate list of installed devices */ k = 0; TAILQ_FOREACH(ent, &sndstat_devlist, link) { - d = device_get_softc(ent->dev); - if (!PCM_REGISTERED(d)) - continue; - if (!k++) - sbuf_printf(s, "Installed devices:\n"); - sbuf_printf(s, "%s:", device_get_nameunit(ent->dev)); - sbuf_printf(s, " <%s>", device_get_desc(ent->dev)); - if (snd_verbose > 0) - sbuf_printf(s, " %s", ent->str); - /* XXX Need Giant magic entry ??? */ - PCM_ACQUIRE_QUICK(d); - sndstat_prepare_pcm(s, ent->dev, snd_verbose); - PCM_RELEASE_QUICK(d); - sbuf_printf(s, "\n"); + if (ent->type == SNDST_TYPE_PCM) { + d = device_get_softc(ent->dev); + if (!PCM_REGISTERED(d)) + continue; + if (!k++) + sbuf_printf(s, "Installed devices:\n"); + sbuf_printf(s, "%s:", device_get_nameunit(ent->dev)); + sbuf_printf(s, " <%s>", device_get_desc(ent->dev)); + if (snd_verbose > 0) + sbuf_printf(s, " %s", ent->str); + /* XXX Need Giant magic entry ??? */ + PCM_ACQUIRE_QUICK(d); + sndstat_prepare_pcm(s, ent->dev, snd_verbose); + PCM_RELEASE_QUICK(d); + sbuf_printf(s, "\n"); + } else if (ent->type == SNDST_TYPE_MIDI) { + /* TODO */ + } } if (k == 0) sbuf_printf(s, "No devices installed.\n");