]> sigrok.org Git - libsigrok.git/commitdiff
alsa: Do not use snd_pcm_hw_params_set_rate_near()
authorAlexandru Gagniuc <redacted>
Thu, 27 Dec 2012 02:14:54 +0000 (20:14 -0600)
committerUwe Hermann <redacted>
Mon, 31 Dec 2012 23:37:17 +0000 (00:37 +0100)
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 <redacted>
hardware/alsa/api.c

index a73bfefaec6fc488b2e3e52b37e9b26a6aba7b5f..22611ca82973cf2c9ee597911d0c801000e20c96 100644 (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;