#define MIN_DATA_CHUNK_OFFSET 45
/* Expect to find the "data" chunk within this offset from the start. */
-#define MAX_DATA_CHUNK_OFFSET 256
+#define MAX_DATA_CHUNK_OFFSET 1024
#define WAVE_FORMAT_PCM_ 0x0001
#define WAVE_FORMAT_IEEE_FLOAT_ 0x0003
offset += 8 + RL32(buf->str + offset + 4);
}
+ if (offset > MAX_DATA_CHUNK_OFFSET)
+ return -1;
+
return offset;
}
struct sr_datafeed_analog_old analog;
struct context *inc;
float fdata[CHUNK_SIZE];
- uint64_t sample;
int total_samples, samplenum;
char *s, *d;
total_samples = num_samples * inc->num_channels;
for (samplenum = 0; samplenum < total_samples; samplenum++) {
if (inc->fmt_code == WAVE_FORMAT_PCM_) {
- sample = 0;
- memcpy(&sample, s, inc->unitsize);
- switch (inc->samplesize) {
+ switch (inc->unitsize) {
case 1:
/* 8-bit PCM samples are unsigned. */
- fdata[samplenum] = (uint8_t)sample / (float)255;
+ fdata[samplenum] = *(uint8_t*)(s) / (float)255;
break;
case 2:
- fdata[samplenum] = RL16S(&sample) / (float)INT16_MAX;
+ fdata[samplenum] = RL16S(s) / (float)INT16_MAX;
break;
case 4:
- fdata[samplenum] = RL32S(&sample) / (float)INT32_MAX;
+ fdata[samplenum] = RL32S(s) / (float)INT32_MAX;
break;
}
} else {
struct sr_config *src;
int offset, chunk_samples, total_samples, processed, max_chunk_samples;
int num_samples, i;
- char channelname[8];
inc = in->priv;
if (!inc->started) {
- for (i = 0; i < inc->num_channels; i++) {
- snprintf(channelname, 8, "CH%d", i + 1);
- sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
- }
-
std_session_send_df_header(in->sdi, LOG_PREFIX);
packet.type = SR_DF_META;
{
struct context *inc;
int ret;
+ char channelname[8];
g_string_append_len(in->buf, buf->str, buf->len);
else if (ret != SR_OK)
return ret;
+ for (int i = 0; i < inc->num_channels; i++) {
+ snprintf(channelname, 8, "CH%d", i + 1);
+ sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
+ }
+
/* sdi is ready, notify frontend. */
in->sdi_ready = TRUE;
return SR_OK;