From: Daniel Elstner Date: Tue, 22 Sep 2015 14:12:01 +0000 (+0200) Subject: demo: Strictly round up the number of samples to send X-Git-Tag: libsigrok-0.4.0~252 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=36cbd69e12d8957592c94420d98552bb00d67be6;hp=98c01fe1277e5a386377347635a8a7fee8abc534;p=libsigrok.git demo: Strictly round up the number of samples to send This avoids getting stuck when the time limit is less than half of the sampling interval. --- diff --git a/src/hardware/demo/demo.c b/src/hardware/demo/demo.c index 6a1a2b2a..f0edbcab 100644 --- a/src/hardware/demo/demo.c +++ b/src/hardware/demo/demo.c @@ -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)