+ if (fmt_code == WAVE_FORMAT_PCM_) {
+ } else if (fmt_code == WAVE_FORMAT_IEEE_FLOAT_) {
+ if (unitsize != 4) {
+ sr_err("only 32-bit floats supported.");
+ return SR_ERR_DATA;
+ }
+ } else if (fmt_code == WAVE_FORMAT_EXTENSIBLE_) {
+ if (buf->len < 70)
+ /* Not enough for extensible header and next chunk. */
+ return SR_ERR_NA;
+
+ if (RL16(buf->str + 16) != 40) {
+ sr_err("WAV extensible format chunk must be 40 bytes.");
+ return SR_ERR;
+ }
+ if (RL16(buf->str + 36) != 22) {
+ sr_err("WAV extension must be 22 bytes.");
+ return SR_ERR;
+ }
+ if (RL16(buf->str + 34) != RL16(buf->str + 38)) {
+ sr_err("Reduced valid bits per sample not supported.");
+ return SR_ERR_DATA;
+ }
+ /* Real format code is the first two bytes of the GUID. */
+ fmt_code = RL16(buf->str + 44);
+ if (fmt_code != WAVE_FORMAT_PCM_ && fmt_code != WAVE_FORMAT_IEEE_FLOAT_) {
+ 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;
+ }
+
+ if (inc) {
+ inc->fmt_code = fmt_code;
+ inc->samplerate = samplerate;
+ inc->samplesize = samplesize;
+ inc->num_channels = num_channels;
+ inc->unitsize = unitsize;
+ inc->found_data = FALSE;
+ }