From: Marcus Comstedt Date: Tue, 2 Sep 2014 17:14:25 +0000 (+0200) Subject: input/wav: Fix broken handling of float32 samples on big endian X-Git-Tag: libsigrok-0.4.0~1056 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=28d9df729254d998e152d7cec665a9db47c79c4d;p=libsigrok.git input/wav: Fix broken handling of float32 samples on big endian Also, make sure that floats are 32 bit even in the case of an extensible header. --- diff --git a/src/input/wav.c b/src/input/wav.c index c5abf235..fd1920e5 100644 --- a/src/input/wav.c +++ b/src/input/wav.c @@ -102,6 +102,10 @@ static int parse_wav_header(GString *buf, struct context *inc) sr_err("Only PCM and floating point samples are supported."); return SR_ERR_DATA; } + if (fmt_code == WAVE_FORMAT_IEEE_FLOAT && unitsize != 4) { + sr_err("only 32-bit floats supported."); + return SR_ERR_DATA; + } } else { sr_err("Only PCM and floating point samples are supported."); return SR_ERR_DATA; @@ -244,8 +248,9 @@ static void send_chunk(const struct sr_input *in, int offset, int num_samples) } else { /* BINARY32 float */ #ifdef WORDS_BIGENDIAN + int i; for (i = 0; i < inc->unitsize; i++) - d[i] = s[inc->unitsize - i]; + d[i] = s[inc->unitsize - 1 - i]; #else memcpy(d, s, inc->unitsize); #endif