At Sat, 27 Jan 2007 14:24:45 +0100, Gregor Jasny wrote: > > Hi, > > I've tried to write a patch for bug #2724. The problem is that some > Logitech webcams have interface alternatives with a rate of 0: (snip) > I've tried to track down the origin of -1 in constraint_list->list but got > lost in the depths of the hw param stuff. Good catch. How about the patch below? Can it at least avoid Oops with rates == 0 (even without your patch)? > The attached patch skips all alternatives with no valid rates. With this > patch my Quickcam 5000 works like a charm. But I'm unsure if this is the > right approach to fix this bug. This is the right fix, too. Of course, pcm-core should be more robust, but the cause of the bug is the bogus entry. The patch looks fine to me. Please provide a proper changelog and a sign-off for merging. Thanks, Takashi diff -r 3be2f03501ef core/pcm_native.c --- a/core/pcm_native.c Tue Jan 30 17:30:55 2007 +0100 +++ b/core/pcm_native.c Tue Jan 30 17:47:49 2007 +0100 @@ -1798,6 +1798,8 @@ static int snd_pcm_hw_rule_rate(struct s struct snd_pcm_hw_rule *rule) { struct snd_pcm_hardware *hw = rule->private; + if (!hw->rates) + return -EINVAL; return snd_interval_list(hw_param_interval(params, rule->var), ARRAY_SIZE(rates), rates, hw->rates); } @@ -1959,52 +1961,83 @@ int snd_pcm_hw_constraints_complete(stru mask |= 1 << SNDRV_PCM_ACCESS_MMAP_COMPLEX; } err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); - snd_assert(err >= 0, return -EINVAL); + if (err < 0) { + snd_printd("cannot set access mask\n"); + return err; + } err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); - snd_assert(err >= 0, return -EINVAL); + if (err < 0) { + snd_printd("cannot set format mask\n"); + return err; + } err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, 1 << SNDRV_PCM_SUBFORMAT_STD); - snd_assert(err >= 0, return -EINVAL); + if (err < 0) { + snd_printd("cannot set subformat mask\n"); + return err; + } err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, hw->channels_min, hw->channels_max); - snd_assert(err >= 0, return -EINVAL); + if (err < 0) { + snd_printd("cannot set channels minmax\n"); + return err; + } err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, hw->rate_min, hw->rate_max); - snd_assert(err >= 0, return -EINVAL); + if (err < 0) { + snd_printd("cannot set rate minmax\n"); + return err; + } err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, hw->period_bytes_min, hw->period_bytes_max); - snd_assert(err >= 0, return -EINVAL); + if (err < 0) { + snd_printd("cannot set periods_bytes minmax\n"); + return err; + } err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, hw->periods_min, hw->periods_max); - snd_assert(err >= 0, return -EINVAL); + if (err < 0) { + snd_printd("cannot set periods minmax\n"); + return err; + } err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, hw->period_bytes_min, hw->buffer_bytes_max); - snd_assert(err >= 0, return -EINVAL); + if (err < 0) { + snd_printd("cannot set buffer_bytes minmax\n"); + return err; + } err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, snd_pcm_hw_rule_buffer_bytes_max, substream, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, -1); - if (err < 0) + if (err < 0) { + snd_printd("cannot set buffer_bytes limit\n"); return err; + } /* FIXME: remove */ if (runtime->dma_bytes) { err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes); - snd_assert(err >= 0, return -EINVAL); + if (err < 0) { + snd_printd("cannot set dma_bytes limit\n"); + return err; + } } if (!(hw->rates & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))) { err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, snd_pcm_hw_rule_rate, hw, SNDRV_PCM_HW_PARAM_RATE, -1); - if (err < 0) + if (err < 0) { + snd_printd("cannot set rate mask\n"); return err; + } } /* FIXME: this belong to lowlevel */ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/alsa-devel