X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Finput%2Fwav.c;h=edabd47ca95324a934d81ae9d39b30ecfe65a59f;hb=013ec84b83a64088b524bb0b3a923c98b7ae9ea4;hp=c5abf235d70864ff67da82990ef9af3a855f28e6;hpb=4f979115a4206bc1ff72c0319a340cbcad0f4b06;p=libsigrok.git diff --git a/src/input/wav.c b/src/input/wav.c index c5abf235..edabd47c 100644 --- a/src/input/wav.c +++ b/src/input/wav.c @@ -63,15 +63,15 @@ static int parse_wav_header(GString *buf, struct context *inc) samplerate = RL32(buf->str + 24); samplesize = RL16(buf->str + 32); - if (samplesize != 1 && samplesize != 2 && samplesize != 4) { - sr_err("Only 8, 16 or 32 bits per sample supported."); - return SR_ERR_DATA; - } - num_channels = RL16(buf->str + 22); if (num_channels == 0) return SR_ERR; unitsize = samplesize / num_channels; + if (unitsize != 1 && unitsize != 2 && unitsize != 4) { + sr_err("Only 8, 16 or 32 bits per sample supported."); + return SR_ERR_DATA; + } + if (fmt_code == WAVE_FORMAT_PCM) { } else if (fmt_code == WAVE_FORMAT_IEEE_FLOAT) { @@ -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