]> sigrok.org Git - libsigrok.git/commit - hardware/alsa/api.c
alsa: Fix sample acquisition and send normalized values
authorAlexandru Gagniuc <redacted>
Sun, 23 Dec 2012 18:57:37 +0000 (12:57 -0600)
committerUwe Hermann <redacted>
Mon, 31 Dec 2012 23:37:17 +0000 (00:37 +0100)
commit729850c9e7dfa2c08c11a025d5a54b8e8e803f3c
tree72f61456a4ce51b81e23f35aa90551b7629f82e7
parent6944b2d02f23cf562574d3d1b37a2d698bdbde4e
alsa: Fix sample acquisition and send normalized values

The alsa driver requested signed 16-bit integers from ALSA, but casted them to
to an unsigned 16bit before finally casting them to a float. The end result was
that half of the wave would be clipped off.
We also requested data in little endian format. ALSA can be instructed to send
data with the correct endianness for the platform, without needing to worry
about what that is.

This patch attempts three points, which, together, fix the acquisition:
1) Request data from ALSA without specifying endianness; ALSA will handle the
endianness.
2) Simplify the int16_t to float loop by using straightforward indexes.
3) Normalize every value before sending it on the session bus.

NOTE: If testing with PulseView, it will appear as if sigrok is sending all
zeroes. sigrok is sending correct data, but since the data is normalized,
PulseView will incorrectly plot it as a straight line.

Signed-off-by: Alexandru Gagniuc <redacted>
hardware/alsa/api.c
hardware/alsa/protocol.c