summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>2000-01-06 04:11:36 +0000
committercg <cg@FreeBSD.org>2000-01-06 04:11:36 +0000
commit2da2a05a1b1644df6246dc2905820500809a71f8 (patch)
tree7e6d1cff7a4ad04371dd1d55d45d65c935323b5b /sys/dev
parentb5c109c1291c4e03464f6269b07b50999edc22db (diff)
downloadFreeBSD-src-2da2a05a1b1644df6246dc2905820500809a71f8.zip
FreeBSD-src-2da2a05a1b1644df6246dc2905820500809a71f8.tar.gz
allow mixer-only devices - ie, devices with no play/rec channels
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/sound/pcm/sound.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index 84ba6af..b9368b8 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -163,24 +163,34 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
}
make_dev(&snd_cdevsw, PCMMKMINOR(unit, SND_DEV_CTL, 0),
UID_ROOT, GID_WHEEL, 0666, "mixer%d", unit);
+
d->devinfo = devinfo;
d->chancount = d->playcount = d->reccount = 0;
sz = (numplay + numrec) * sizeof(pcm_channel *);
- d->aplay = (pcm_channel **)malloc(sz, M_DEVBUF, M_NOWAIT);
- if (!d->aplay) goto no;
- d->arec = (pcm_channel **)malloc(sz, M_DEVBUF, M_NOWAIT);
- if (!d->arec) goto no;
- bzero(d->aplay, sz);
- bzero(d->arec, sz);
-
- d->play = (pcm_channel *)malloc(numplay * sizeof(pcm_channel),
- M_DEVBUF, M_NOWAIT);
- if (!d->play) goto no;
- d->rec = (pcm_channel *)malloc(numrec * sizeof(pcm_channel),
- M_DEVBUF, M_NOWAIT);
- if (!d->rec) goto no;
- bzero(d->play, numplay * sizeof(pcm_channel));
- bzero(d->rec, numrec * sizeof(pcm_channel));
+
+ if (sz > 0) {
+ d->aplay = (pcm_channel **)malloc(sz, M_DEVBUF, M_NOWAIT);
+ if (!d->aplay) goto no;
+ bzero(d->aplay, sz);
+
+ d->arec = (pcm_channel **)malloc(sz, M_DEVBUF, M_NOWAIT);
+ if (!d->arec) goto no;
+ bzero(d->arec, sz);
+ }
+
+ if (numplay > 0) {
+ d->play = (pcm_channel *)malloc(numplay * sizeof(pcm_channel),
+ M_DEVBUF, M_NOWAIT);
+ if (!d->play) goto no;
+ bzero(d->play, numplay * sizeof(pcm_channel));
+ }
+
+ if (numrec > 0) {
+ d->rec = (pcm_channel *)malloc(numrec * sizeof(pcm_channel),
+ M_DEVBUF, M_NOWAIT);
+ if (!d->rec) goto no;
+ bzero(d->rec, numrec * sizeof(pcm_channel));
+ }
fkchan_setup(&d->fakechan);
chn_init(&d->fakechan, NULL, 0);
OpenPOWER on IntegriCloud