]> sigrok.org Git - libsigrok.git/commitdiff
demo: Strictly round up the number of samples to send
authorDaniel Elstner <redacted>
Tue, 22 Sep 2015 14:12:01 +0000 (16:12 +0200)
committerDaniel Elstner <redacted>
Tue, 22 Sep 2015 14:12:01 +0000 (16:12 +0200)
This avoids getting stuck when the time limit is less than
half of the sampling interval.

src/hardware/demo/demo.c

index 6a1a2b2a2f552edb21fd27f8b81d701b3ae69ead..f0edbcab1c8c3f7ca2f246f9f38230fa76692513 100644 (file)
@@ -770,7 +770,7 @@ static int prepare_data(int fd, int revents, void *cb_data)
                todo_us = MAX(0, elapsed_us - devc->spent_us);
 
        /* How many samples are outstanding since the last round? */
-       samples_todo = (todo_us * devc->cur_samplerate + G_USEC_PER_SEC / 2)
+       samples_todo = (todo_us * devc->cur_samplerate + G_USEC_PER_SEC - 1)
                        / G_USEC_PER_SEC;
        if (devc->limit_samples > 0) {
                if (devc->limit_samples < devc->sent_samples)