Skip to content

Commit 506c203

Browse files
committed
ALSA: usb-audio: Fix hw constraints dependencies
Since the recent refactoring, it's been reported that some USB-audio devices (typically webcams) are no longer detected properly by PulseAudio. The debug session revealed that it's failing at probing by PA to try the sample rate 44.1kHz while the device has discrete sample rates other than 44.1kHz. But the puzzle was that arecord works as is, and some other devices with the discrete rates work, either. After all, this turned out to be the lack of the dependencies in a few hw constraint rules: snd_pcm_hw_rule_add() has the (variable) arguments specifying the dependent parameters, and some functions didn't set the target parameter itself as the dependencies. This resulted in an invalid parameter that could be generated only in a certain call pattern. This bug itself has been present in the code, but it didn't trigger errors just because the rules were casually avoiding such a corner case. After the recent refactoring and cleanup, however, the hw constraints work "as expected", and the problem surfaced now. For fixing the problem above, this patch adds the missing dependent parameters to each snd_pcm_hw_rule() call. Fixes: bc4e94a ("ALSA: usb-audio: Handle discrete rates properly in hw constraints") BugLink: http://bugzilla.opensuse.org/show_bug.cgi?id=1181014 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 2b73649 commit 506c203

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sound/usb/pcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
981981

982982
err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
983983
hw_rule_rate, subs,
984+
SNDRV_PCM_HW_PARAM_RATE,
984985
SNDRV_PCM_HW_PARAM_FORMAT,
985986
SNDRV_PCM_HW_PARAM_CHANNELS,
986987
param_period_time_if_needed,
@@ -990,6 +991,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
990991

991992
err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
992993
hw_rule_channels, subs,
994+
SNDRV_PCM_HW_PARAM_CHANNELS,
993995
SNDRV_PCM_HW_PARAM_FORMAT,
994996
SNDRV_PCM_HW_PARAM_RATE,
995997
param_period_time_if_needed,
@@ -998,6 +1000,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
9981000
return err;
9991001
err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT,
10001002
hw_rule_format, subs,
1003+
SNDRV_PCM_HW_PARAM_FORMAT,
10011004
SNDRV_PCM_HW_PARAM_RATE,
10021005
SNDRV_PCM_HW_PARAM_CHANNELS,
10031006
param_period_time_if_needed,

0 commit comments

Comments
 (0)