- /*
- * Pipistrello OLS sends its sample buffer backwards.
- * store it in reverse order here, so we can dump
- * this on the session bus later.
- */
- offset = (devc->limit_samples - devc->num_samples) * 4;
- for (i = 0; i <= devc->rle_count; i++) {
- memcpy(devc->raw_sample_buf + offset + (i * 4),
- devc->sample, 4);
+ if (num_channels < 4) {
+ /*
+ * Some channel groups may have been turned
+ * off, to speed up transfer between the
+ * hardware and the PC. Expand that here before
+ * submitting it over the session bus --
+ * whatever is listening on the bus will be
+ * expecting a full 32-bit sample, based on
+ * the number of channels.
+ */
+ j = 0;
+ memset(devc->tmp_sample, 0, 4);
+ for (i = 0; i < 4; i++) {
+ if (((devc->flag_reg >> 2) & (1 << i)) == 0) {
+ /*
+ * This channel group was
+ * enabled, copy from received
+ * sample.
+ */
+ devc->tmp_sample[i] = devc->sample[j++];
+ }
+ }
+ memcpy(devc->sample, devc->tmp_sample, 4);
+ sr_spew("Expanded sample: 0x%.8x.", sample);
+ }
+
+ /*
+ * Pipistrello OLS sends its sample buffer backwards.
+ * store it in reverse order here, so we can dump
+ * this on the session bus later.
+ */
+ offset = (devc->limit_samples - devc->num_samples) * 4;
+ for (i = 0; i <= devc->rle_count; i++) {
+ memcpy(devc->raw_sample_buf + offset + (i * 4),
+ devc->sample, 4);
+ }
+ memset(devc->sample, 0, 4);
+ devc->num_bytes = 0;
+ devc->rle_count = 0;