From: Alexandru Gagniuc Date: Thu, 27 Dec 2012 02:14:54 +0000 (-0600) Subject: alsa: Do not use snd_pcm_hw_params_set_rate_near() X-Git-Tag: dsupstream~391 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0d6ff1039447c35fa8b423ee02468e62a5064cab;p=libsigrok.git 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 --- diff --git a/hardware/alsa/api.c b/hardware/alsa/api.c index a73bfefa..22611ca8 100644 --- a/hardware/alsa/api.c +++ b/hardware/alsa/api.c @@ -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;