From 0586ff0d8499be18d1f273e33eb4472a96217ecd Mon Sep 17 00:00:00 2001 From: Cameron Grant Date: Mon, 25 Nov 2002 17:03:39 +0000 Subject: if the list of supported formats is empty, fail the attach instead of panicing later. this is a band-aid pending further investigation. MFC After: 7 days Approved by: re --- sys/dev/sound/usb/uaudio_pcm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sys') diff --git a/sys/dev/sound/usb/uaudio_pcm.c b/sys/dev/sound/usb/uaudio_pcm.c index a49ee4ab872b..4ea33f3b707b 100644 --- a/sys/dev/sound/usb/uaudio_pcm.c +++ b/sys/dev/sound/usb/uaudio_pcm.c @@ -74,19 +74,23 @@ ua_chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel * ch->channel = c; ch->buffer = b; + pa_dev = device_get_parent(sc->sc_dev); + /* Create ua_playfmt[] & ua_recfmt[] */ + uaudio_query_formats(pa_dev, (u_int32_t *)&ua_playfmt, (u_int32_t *)&ua_recfmt); + if (ua_playfmt[0] == 0) { + printf("%s channel supported format list invalid\n", dir == PCMDIR_PLAY? "play" : "record"); + return NULL; + } + /* allocate PCM side DMA buffer */ if (sndbuf_alloc(ch->buffer, sc->parent_dmat, UAUDIO_PCM_BUFF_SIZE) != 0) { return NULL; } - pa_dev = device_get_parent(sc->sc_dev); buf = end = sndbuf_getbuf(b); end += sndbuf_getsize(b); uaudio_chan_set_param_pcm_dma_buff(pa_dev, buf, end, ch->channel); - /* Create ua_playfmt[] & ua_recfmt[] */ - uaudio_query_formats(pa_dev, (u_int32_t *)&ua_playfmt, (u_int32_t *)&ua_recfmt); - ch->dir = dir; #ifndef NO_RECORDING ch->hwch = 1; -- cgit v1.2.3