don't panic if channel init fails, report and fail gracefully

This commit is contained in:
Cameron Grant 2000-01-05 20:44:41 +00:00
parent 4c641908e9
commit bbb5bf3d69
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=55483
2 changed files with 10 additions and 3 deletions

View File

@ -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. */

View File

@ -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),