Demo: Implement multi-frame development feature
This commit is contained in:
parent
b7602846fd
commit
f55bea7626
|
@ -453,6 +453,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
|||
|
||||
std_session_send_df_header(sdi);
|
||||
|
||||
if (SAMPLES_PER_FRAME > 0)
|
||||
std_session_send_frame_begin(sdi);
|
||||
|
||||
/* We use this timestamp to decide how many more samples to send. */
|
||||
devc->start_us = g_get_monotonic_time();
|
||||
devc->spent_us = 0;
|
||||
|
@ -464,6 +467,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
|||
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
||||
{
|
||||
sr_session_source_remove(sdi->session, -1);
|
||||
|
||||
if (SAMPLES_PER_FRAME > 0)
|
||||
std_session_send_frame_end(sdi);
|
||||
|
||||
std_session_send_df_end(sdi);
|
||||
|
||||
return SR_OK;
|
||||
|
|
|
@ -459,12 +459,17 @@ SR_PRIV int demo_prepare_data(int fd, int revents, void *cb_data)
|
|||
/* 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;
|
||||
|
||||
if (SAMPLES_PER_FRAME > 0)
|
||||
samples_todo = SAMPLES_PER_FRAME;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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.
|
||||
|
@ -534,6 +539,11 @@ SR_PRIV int demo_prepare_data(int fd, int revents, void *cb_data)
|
|||
}
|
||||
sr_dbg("Requested number of samples reached.");
|
||||
sr_dev_acquisition_stop(sdi);
|
||||
} else {
|
||||
if (SAMPLES_PER_FRAME > 0) {
|
||||
std_session_send_frame_end(sdi);
|
||||
std_session_send_frame_begin(sdi);
|
||||
}
|
||||
}
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#define LOGIC_BUFSIZE 4096
|
||||
/* Size of the analog pattern space per channel. */
|
||||
#define ANALOG_BUFSIZE 4096
|
||||
/* This is a development feature: it starts a new frame every n samples. */
|
||||
#define SAMPLES_PER_FRAME 0
|
||||
|
||||
struct dev_context {
|
||||
uint64_t cur_samplerate;
|
||||
|
|
Loading…
Reference in New Issue