summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>2000-01-05 20:44:41 +0000
committercg <cg@FreeBSD.org>2000-01-05 20:44:41 +0000
commit9a79ef7dd310743106d3a084a52c28448b3c446f (patch)
tree9baa3ff4737e1c963026e9f3ed808587417305b0 /sys/dev
parent76f0b8f00793864b5f15df5fcf7f8b6de7006e64 (diff)
downloadFreeBSD-src-9a79ef7dd310743106d3a084a52c28448b3c446f.zip
FreeBSD-src-9a79ef7dd310743106d3a084a52c28448b3c446f.tar.gz
don't panic if channel init fails, report and fail gracefully
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/sound/pcm/channel.c3
-rw-r--r--sys/dev/sound/pcm/sound.c10
2 files changed, 10 insertions, 3 deletions
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index 3f48edd..a8d0466 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -1021,7 +1021,8 @@ chn_init(pcm_channel *c, void *devinfo, int dir)
c->feeder = &feeder_root;
c->buffer.chan = -1;
c->devinfo = c->init(devinfo, &c->buffer, c, dir);
- if (c->devinfo == NULL) panic("c->init() failed");
+ if (c->devinfo == NULL)
+ return 1;
chn_setdir(c, dir);
/* And the secondary buffer. */
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index db31071..84ba6af 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -101,9 +101,15 @@ pcm_addchan(device_t dev, int dir, pcm_channel *templ, void *devinfo)
snddev_info *d = device_get_softc(dev);
pcm_channel *ch;
- ch = (dir == PCMDIR_PLAY)? &d->play[d->playcount++] : &d->rec[d->reccount++];
+ ch = (dir == PCMDIR_PLAY)? &d->play[d->playcount] : &d->rec[d->reccount];
*ch = *templ;
- chn_init(ch, devinfo, dir);
+ if (chn_init(ch, devinfo, dir)) {
+ device_printf(dev, "chn_init() for %s:%d failed\n",
+ (dir == PCMDIR_PLAY)? "play" : "record",
+ (dir == PCMDIR_PLAY)? d->playcount : d->reccount);
+ return 1;
+ }
+ if (dir == PCMDIR_PLAY) d->playcount++; else d->reccount++;
make_dev(&snd_cdevsw, PCMMKMINOR(unit, SND_DEV_DSP, d->chancount),
UID_ROOT, GID_WHEEL, 0666, "dsp%d.%d", unit, d->chancount);
make_dev(&snd_cdevsw, PCMMKMINOR(unit, SND_DEV_AUDIO, d->chancount),
OpenPOWER on IntegriCloud