summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pcm
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>2001-06-17 23:23:06 +0000
committercg <cg@FreeBSD.org>2001-06-17 23:23:06 +0000
commit420f58376d042d11f15ba9760f51ad286889c0c1 (patch)
tree1e5bb7b2a2ed49fdd8be254bc876b02d79fd7d92 /sys/dev/sound/pcm
parent494b7c747502ef2db69bcbd72ba05d31126ba33f (diff)
downloadFreeBSD-src-420f58376d042d11f15ba9760f51ad286889c0c1.zip
FreeBSD-src-420f58376d042d11f15ba9760f51ad286889c0c1.tar.gz
revise dsp_clone() to return the first nonbusy channel instead of simply
cycling channel numbers. remove unused fields from struct snddev_info.
Diffstat (limited to 'sys/dev/sound/pcm')
-rw-r--r--sys/dev/sound/pcm/dsp.c22
-rw-r--r--sys/dev/sound/pcm/sndstat.c2
-rw-r--r--sys/dev/sound/pcm/sound.c5
-rw-r--r--sys/dev/sound/pcm/sound.h3
4 files changed, 17 insertions, 15 deletions
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index 4653990..81d75da 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -992,9 +992,8 @@ dsp_unregister(int unit, int channel)
static void
dsp_clone(void *arg, char *name, int namelen, dev_t *dev)
{
- struct snddev_info *d;
dev_t pdev;
- int unit, devtype;
+ int i, cont, unit, devtype;
if (*dev != NODEV)
return;
@@ -1028,13 +1027,18 @@ gotit:
if (unit == -1 || unit > devclass_get_maxunit(pcm_devclass))
return;
- d = devclass_get_softc(pcm_devclass, unit);
-
- pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(unit, devtype, d->defaultchan++));
- if (d->defaultchan >= d->chancount)
- d->defaultchan = 0;
- if (pdev->si_flags & SI_NAMED)
- *dev = pdev;
+ cont = 1;
+ for (i = 0; cont; i++) {
+ pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(unit, devtype, i));
+ if (pdev->si_flags & SI_NAMED) {
+ if ((pdev->si_drv1 == NULL) && (pdev->si_drv2 == NULL)) {
+ *dev = pdev;
+ return;
+ }
+ } else {
+ cont = 0;
+ }
+ }
}
static void
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index 030b14b..25c71ed 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -147,7 +147,7 @@ sndstat_prepare(struct sbuf *s)
snd_mtxlock(d->lock);
dev = devclass_get_device(pcm_devclass, i);
sbuf_printf(s, "pcm%d: <%s> %s", i, device_get_desc(dev), d->status);
- if (d->chancount > 0) {
+ if (!SLIST_EMPTY(&d->channels)) {
pc = rc = vc = 0;
SLIST_FOREACH(sce, &d->channels, link) {
c = sce->channel;
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index ba41858..89cd4d0 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -166,7 +166,7 @@ sysctl_hw_sndunit(SYSCTL_HANDLER_ARGS)
if (unit < 0 || unit > devclass_get_maxunit(pcm_devclass))
return EINVAL;
d = devclass_get_softc(pcm_devclass, unit);
- if (d == NULL || d->chancount == 0)
+ if (d == NULL || SLIST_EMPTY(&d->channels))
return EINVAL;
snd_unit = unit;
}
@@ -371,7 +371,6 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
d->dev = dev;
d->devinfo = devinfo;
d->chancount = 0;
- d->defaultchan = 0;
d->inprog = 0;
if (((numplay == 0) || (numrec == 0)) && (numplay != numrec))
@@ -428,7 +427,7 @@ pcm_unregister(device_t dev)
d->sysctl_tree_top = NULL;
sysctl_ctx_free(&d->sysctl_tree);
#endif
- while (d->chancount > 0)
+ while (!SLIST_EMPTY(&d->channels))
pcm_killchan(dev);
chn_kill(d->fakechan);
diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
index 886ddb7..124c9db 100644
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -108,8 +108,7 @@ struct snddev_channel {
struct snddev_info {
SLIST_HEAD(, snddev_channel) channels;
struct pcm_channel *fakechan;
- unsigned chancount, defaultchan;
- /* struct snd_mixer *mixer; */
+ unsigned chancount;
unsigned flags;
int inprog;
void *devinfo;
OpenPOWER on IntegriCloud