- /* Send header packet to the session bus. */
- std_session_send_df_header(in->sdi, LOG_PREFIX);
-
- /* Send the samplerate. */
- packet.type = SR_DF_META;
- packet.payload = &meta;
- src = sr_config_new(SR_CONF_SAMPLERATE,
- g_variant_new_uint64(ctx->samplerate));
- meta.config = g_slist_append(NULL, src);
+ s = in->buf->str + offset;
+ d = (char *)fdata;
+ memset(fdata, 0, CHUNK_SIZE);
+ total_samples = num_samples * inc->num_channels;
+ for (samplenum = 0; samplenum < total_samples; samplenum++) {
+ if (inc->fmt_code == WAVE_FORMAT_PCM_) {
+ switch (inc->unitsize) {
+ case 1:
+ /* 8-bit PCM samples are unsigned. */
+ fdata[samplenum] = *(uint8_t*)(s) / (float)255;
+ break;
+ case 2:
+ fdata[samplenum] = RL16S(s) / (float)INT16_MAX;
+ break;
+ case 4:
+ fdata[samplenum] = RL32S(s) / (float)INT32_MAX;
+ break;
+ }
+ } else {
+ /* BINARY32 float */
+#ifdef WORDS_BIGENDIAN
+ int i;
+ for (i = 0; i < inc->unitsize; i++)
+ d[i] = s[inc->unitsize - 1 - i];
+#else
+ memcpy(d, s, inc->unitsize);
+#endif
+ }
+ s += inc->unitsize;
+ d += inc->unitsize;
+ }
+ packet.type = SR_DF_ANALOG_OLD;
+ packet.payload = &analog;
+ analog.channels = in->sdi->channels;
+ analog.num_samples = num_samples;
+ analog.mq = 0;
+ analog.mqflags = 0;
+ analog.unit = 0;
+ analog.data = fdata;