From 833f7023485f5869598f9e6e3635e859ca63bd6d Mon Sep 17 00:00:00 2001 From: Cameron Grant Date: Thu, 6 Jan 2000 04:11:36 +0000 Subject: [PATCH] allow mixer-only devices - ie, devices with no play/rec channels --- sys/dev/sound/pcm/sound.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 84ba6af8b329..b9368b8870f1 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);