Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151841534
D54141.id168889.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D54141.id168889.diff
View Options
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
@@ -31,7 +31,12 @@
#ifndef _SNDSTAT_H_
#define _SNDSTAT_H_
-int sndstat_register(device_t dev, char *str);
+enum sndstat_type {
+ SNDST_TYPE_PCM,
+ SNDST_TYPE_MIDI,
+};
+
+void 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
@@ -52,9 +52,6 @@
#include "feeder_if.h"
-#define SS_TYPE_PCM 1
-#define SS_TYPE_MIDI 2
-
static d_open_t sndstat_open;
static void sndstat_close(void *);
static d_read_t sndstat_read;
@@ -75,7 +72,8 @@
TAILQ_ENTRY(sndstat_entry) link;
device_t dev;
char *str;
- int type, unit;
+ enum sndstat_type type;
+ int unit;
};
struct sndstat_userdev {
@@ -688,22 +686,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) {
@@ -1154,22 +1156,14 @@
/************************************************************************/
-int
-sndstat_register(device_t dev, char *str)
+void
+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;
@@ -1195,8 +1189,6 @@
TAILQ_INSERT_BEFORE(pre, ent, link);
}
SNDSTAT_UNLOCK();
-
- return (0);
}
int
@@ -1388,20 +1380,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");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 12, 1:03 AM (11 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31319522
Default Alt Text
D54141.id168889.diff (4 KB)
Attached To
Mode
D54141: sound: Take device type into account in sndstat
Attached
Detach File
Event Timeline
Log In to Comment