From: Aurelien Jacobs Date: Mon, 17 Nov 2014 10:38:37 +0000 (+0100) Subject: demo: Fix analog output at low samplerate. X-Git-Tag: libsigrok-0.4.0~765 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=62f155f0c784509dbec98fc7c80b03284a271237;p=libsigrok.git demo: Fix analog output at low samplerate. --- diff --git a/src/hardware/demo/demo.c b/src/hardware/demo/demo.c index 42d1d788..21715ea0 100644 --- a/src/hardware/demo/demo.c +++ b/src/hardware/demo/demo.c @@ -671,6 +671,7 @@ static int prepare_data(int fd, int revents, void *cb_data) struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; struct analog_gen *ag; + int ag_pattern_pos; GHashTableIter iter; void *value; uint64_t logic_todo, analog_todo, expected_samplenum, analog_sent, sending_now; @@ -722,13 +723,9 @@ static int prepare_data(int fd, int revents, void *cb_data) ag = value; packet.type = SR_DF_ANALOG; packet.payload = &ag->packet; - - /* FIXME we should make sure we output a whole - * period of data before we send out again the - * beginning of our buffer. A ring buffer would - * help here as well */ - - sending_now = MIN(analog_todo, ag->num_samples); + ag_pattern_pos = devc->analog_counter % ag->num_samples; + sending_now = MIN(analog_todo, ag->num_samples-ag_pattern_pos); + ag->packet.data = ag->pattern_data + ag_pattern_pos; ag->packet.num_samples = sending_now; sr_session_send(sdi, &packet);