case SF_S16_BE: return SND_PCM_FORMAT_S16_BE;
case SF_U16_LE: return SND_PCM_FORMAT_U16_LE;
case SF_U16_BE: return SND_PCM_FORMAT_U16_BE;
+ case SF_FLOAT_LE: return SND_PCM_FORMAT_FLOAT_LE;
+ case SF_FLOAT_BE: return SND_PCM_FORMAT_FLOAT_BE;
default: return SND_PCM_FORMAT_S16_LE;
}
}
case SF_U8:
case SF_U16_LE:
case SF_U16_BE:
+ case SF_FLOAT_LE:
+ case SF_FLOAT_BE:
return -E_BAD_SAMPLE_FORMAT;
case SF_S8:
/* no need to set byte_format */
unsigned char *a;
size_t sz;
int ret;
- uint16_t bps; /* bits per sample */
+ uint16_t format_code, bps; /* bits per sample */
const char *sample_formats[] = {SAMPLE_FORMATS};
if (!btrn)
cwc->state = CWS_HAVE_HEADER;
/* Only set those values which have not already been set. */
cwc->channels = a[22];
+ format_code = read_u16(a + 20);
+ if (format_code != 1 && format_code != 3) {
+ cwc->state = CWS_NO_HEADER;
+ goto out;
+ }
cwc->sample_rate = read_u32(a + 24);
bps = read_u16(a + 34);
- if (bps != 8 && bps != 16) {
+ if (bps != 8 && bps != 16 && bps != 32) {
PARA_WARNING_LOG("%u bps not supported, assuming 16\n",
bps);
bps = 16;
}
+ if ((bps < 32 && format_code != 1) || (bps == 32 && format_code != 3)) {
+ PARA_WARNING_LOG("invalid bps/format_code (%u/%u)\n",
+ bps, format_code);
+ cwc->state = CWS_NO_HEADER;
+ goto out;
+ }
/*
* 8-bit samples are stored as unsigned bytes, ranging from 0
* to 255. 16-bit samples are stored as 2's-complement signed
*/
if (bps == 8)
cwc->sample_format = SF_U8;
- else
+ else if (bps == 16)
cwc->sample_format = (a[3] == 'F')?
SF_S16_LE : SF_S16_BE;
+ else /* 32 bit */
+ cwc->sample_format = (a[3] == 'F')?
+ SF_FLOAT_LE : SF_FLOAT_BE;
PARA_NOTICE_LOG("%uHz, %s, %s\n", cwc->sample_rate,
cwc->channels == 1? "mono" : "stereo",
sample_formats[cwc->sample_format]);
SAMPLE_FORMAT_S16_LE = "S16_LE",
SAMPLE_FORMAT_S16_BE = "S16_BE",
SAMPLE_FORMAT_U16_LE = "U16_LE",
- SAMPLE_FORMAT_U16_BE = "U16_BE"
+ SAMPLE_FORMAT_U16_BE = "U16_BE",
+ SAMPLE_FORMAT_FLOAT_LE = "FLOAT_LE",
+ SAMPLE_FORMAT_FLOAT_BE = "FLOAT_BE"
}
default_val = S16_LE
[help]
SAMPLE_FORMAT(SF_S16_BE, "16 bit signed, big endian"), \
SAMPLE_FORMAT(SF_U16_LE, "16 bit unsigned, little endian"), \
SAMPLE_FORMAT(SF_U16_BE, "16 bit unsigned, big endian"), \
+ SAMPLE_FORMAT(SF_FLOAT_LE, "32 bit float, little endian"), \
+ SAMPLE_FORMAT(SF_FLOAT_BE, "32 bit float, big endian"), \
/** \cond sample_format */
#define SAMPLE_FORMAT(a, b) a