ref: 3ee08beb133a2ac7d239f5f89c7651eb617517c9
parent: 8368c6f2d5b84b28533bc8715a5558db33a0d32f
author: Ulrich Klauer <ulrich@chirlu.de>
date: Thu Jan 5 13:44:57 EST 2012
alsa: determine signal precision Use snd_pcm_hw_params_get_sbits() to ask the driver for the number of significant bits, which may differ from the encoding size.
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -102,6 +102,12 @@
_(snd_pcm_hw_params_set_channels_near, (p->pcm, params, &n));
ft->signal.channels = n;
+ /* Get number of significant bits: */
+ if ((err = snd_pcm_hw_params_get_sbits(params)) > 0)
+ ft->signal.precision = min(err, SOX_SAMPLE_PRECISION);
+ else lsx_debug("snd_pcm_hw_params_get_sbits can't tell precision: %s",
+ snd_strerror(err));
+
/* Set buf_len > > sox_globals.bufsiz for no underrun: */
p->buf_len = sox_globals.bufsiz * 8 / NBYTES / ft->signal.channels;
_(snd_pcm_hw_params_get_buffer_size_min, (params, &min));