alsa: Do not use snd_pcm_hw_params_set_rate_near()

snd_pcm_hw_params_set_rate_near() will try to use the samplerate closest to the
given value, potentially starting the acquisition with a different samplerate
than the one specified.

Instead, use snd_pcm_hw_params_set_rate(). It will return an error if the
samplerate is not supported by the hardware, which is arguably better than
collecting data with a different samplerate than the one specified.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This commit is contained in:
Alexandru Gagniuc 2012-12-26 20:14:54 -06:00 committed by Uwe Hermann
parent cbc8cbd8bb
commit 0d6ff10394
1 changed files with 2 additions and 2 deletions

View File

@ -279,8 +279,8 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
sr_dbg("Setting audio samplerate to %" PRIu64 "Hz.",
devc->cur_samplerate);
ret = snd_pcm_hw_params_set_rate_near(devc->capture_handle,
devc->hw_params, (unsigned int *)&devc->cur_samplerate, 0);
ret = snd_pcm_hw_params_set_rate(devc->capture_handle, devc->hw_params,
(unsigned int)devc->cur_samplerate, 0);
if (ret < 0) {
sr_err("Can't set audio sample rate: %s.", snd_strerror(ret));
return SR_ERR;