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.
This commit is contained in:
Marcus Comstedt 2014-09-02 19:14:25 +02:00
parent c7f5219e62
commit 28d9df7292
1 changed files with 6 additions and 1 deletions

View File

@ -102,6 +102,10 @@ static int parse_wav_header(GString *buf, struct context *inc)
sr_err("Only PCM and floating point samples are supported."); sr_err("Only PCM and floating point samples are supported.");
return SR_ERR_DATA; 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 { } else {
sr_err("Only PCM and floating point samples are supported."); sr_err("Only PCM and floating point samples are supported.");
return SR_ERR_DATA; return SR_ERR_DATA;
@ -244,8 +248,9 @@ static void send_chunk(const struct sr_input *in, int offset, int num_samples)
} else { } else {
/* BINARY32 float */ /* BINARY32 float */
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
int i;
for (i = 0; i < inc->unitsize; i++) for (i = 0; i < inc->unitsize; i++)
d[i] = s[inc->unitsize - i]; d[i] = s[inc->unitsize - 1 - i];
#else #else
memcpy(d, s, inc->unitsize); memcpy(d, s, inc->unitsize);
#endif #endif