From: Clemens Ladisch Date: Mon, 4 Dec 2006 17:14:13 +0000 (+0100) Subject: direct pcm plugins: fix channel number selection X-Git-Tag: v1.0.14rc1~3 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=9819099e0e102cdb593d61b9d0c2508159bd9650;p=alsa-lib.git direct pcm plugins: fix channel number selection The code to set the number of channels did not work when the requested channel count was not available and when the min/max channel counts were not identical. Replacing the entire selection code with snd_pcm_hw_params_set_channels_near() gives the same result in the cases where it previously worked, and works in all other cases. --- diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index 07567102..f189181f 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -899,28 +899,10 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str } params->format = format; } - ret = snd_pcm_hw_params_set_channels(spcm, hw_params, params->channels); + ret = INTERNAL(snd_pcm_hw_params_set_channels_near)(spcm, hw_params, (unsigned int *)¶ms->channels); if (ret < 0) { - unsigned int min, max; - ret = INTERNAL(snd_pcm_hw_params_get_channels_min)(hw_params, &min); - if (ret < 0) { - SNDERR("cannot obtain minimal count of channels"); - return ret; - } - ret = INTERNAL(snd_pcm_hw_params_get_channels_min)(hw_params, &max); - if (ret < 0) { - SNDERR("cannot obtain maximal count of channels"); - return ret; - } - if (min == max) { - ret = snd_pcm_hw_params_set_channels(spcm, hw_params, min); - if (ret >= 0) - params->channels = min; - } - if (ret < 0) { - SNDERR("requested count of channels is not available"); - return ret; - } + SNDERR("requested count of channels is not available"); + return ret; } ret = INTERNAL(snd_pcm_hw_params_set_rate_near)(spcm, hw_params, (unsigned int *)¶ms->rate, 0); if (ret < 0) {