break;
case PATTERN_INC:
for (i = 0; i < size; i++) {
- for (j = 0; j < devc->logic_unitsize; j++) {
+ for (j = 0; j < devc->logic_unitsize; j++)
devc->logic_data[i + j] = devc->step;
- }
devc->step++;
}
break;
ag->packet.data = ag->pattern_data + ag_pattern_pos;
ag->packet.num_samples = sending_now;
sr_session_send(sdi, &packet);
- sr_dbg("DBG: %s() sending now: %lu", __func__, (unsigned long)sending_now);
/* Whichever channel group gets there first. */
*analog_sent = MAX(*analog_sent, sending_now);
/* How many samples are outstanding since the last round? */
samples_todo = (todo_us * devc->cur_samplerate + G_USEC_PER_SEC - 1)
/ G_USEC_PER_SEC;
- sr_dbg("DBG: %s() samples_todo before adjustment: %lu", __func__, (unsigned long)samples_todo);
+
if (devc->limit_samples > 0) {
if (devc->limit_samples < devc->sent_samples)
samples_todo = 0;
else if (devc->limit_samples - devc->sent_samples < samples_todo)
samples_todo = devc->limit_samples - devc->sent_samples;
}
- sr_dbg("DBG: %s() samples_todo after adjustment: %lu", __func__, (unsigned long)samples_todo);
+
+ if (samples_todo == 0)
+ return G_SOURCE_CONTINUE;
+
+#if (SAMPLES_PER_FRAME > 0) /* Avoid "comparison < 0 always false" warning. */
+ /* Never send more samples than a frame can fit... */
+ samples_todo = MIN(samples_todo, SAMPLES_PER_FRAME);
+ /* ...or than we need to finish the current frame. */
+ samples_todo = MIN(samples_todo, SAMPLES_PER_FRAME - devc->sent_frame_samples);
+#endif
+
/* Calculate the actual time covered by this run back from the sample
* count, rounded towards zero. This avoids getting stuck on a too-low
* time delta with no samples being sent due to round-off.
send_analog_packet(value, sdi, &analog_sent,
devc->sent_samples + analog_done,
samples_todo - analog_done);
- sr_dbg("DBG: %s() analog_sent: %lu", __func__, (unsigned long)analog_sent);
}
analog_done += analog_sent;
- sr_dbg("DBG: %s() analog_done: %lu", __func__, (unsigned long)analog_done);
}
}
/* At this point, both logic_done and analog_done should be
return G_SOURCE_REMOVE;
}
devc->sent_samples += samples_todo;
+ devc->sent_frame_samples += samples_todo;
devc->spent_us += todo_us;
+#if (SAMPLES_PER_FRAME > 0) /* Avoid "comparison >= 0 always true" warning. */
+ if (devc->sent_frame_samples >= SAMPLES_PER_FRAME) {
+ std_session_send_frame_end(sdi);
+ devc->sent_frame_samples = 0;
+ }
+#endif
+
if ((devc->limit_samples > 0 && devc->sent_samples >= devc->limit_samples)
|| (limit_us > 0 && devc->spent_us >= limit_us)) {
}
sr_dbg("Requested number of samples reached.");
sr_dev_acquisition_stop(sdi);
+ } else {
+#if (SAMPLES_PER_FRAME > 0)
+ if (devc->sent_frame_samples == 0)
+ std_session_send_frame_begin(sdi);
+#endif
}
return G_SOURCE_CONTINUE;