- struct sr_dev_inst *sdi;
- struct sr_datafeed_packet *packet;
- struct sr_datafeed_header *header;
+ return samplerate / 1000;
+}
+
+static size_t get_buffer_size(struct context *ctx)
+{
+ size_t s;
+
+ /* The buffer should be large enough to hold 10ms of data and a multiple
+ * of 512. */
+ s = 10 * to_bytes_per_ms(ctx->cur_samplerate);
+ return (s + 511) & ~511;
+}
+
+static unsigned int get_number_of_transfers(struct context *ctx)
+{
+ unsigned int n;
+
+ /* Total buffer size should be able to hold about 500ms of data */
+ n = 500 * to_bytes_per_ms(ctx->cur_samplerate) / get_buffer_size(ctx);
+
+ if (n > NUM_SIMUL_TRANSFERS)
+ return NUM_SIMUL_TRANSFERS;
+
+ return n;
+}
+
+static unsigned int get_timeout(struct context *ctx)
+{
+ size_t total_size;
+ unsigned int timeout;
+
+ total_size = get_buffer_size(ctx) * get_number_of_transfers(ctx);
+ timeout = total_size / to_bytes_per_ms(ctx->cur_samplerate);
+ return timeout + timeout / 4; /* Leave a headroom of 25% percent */
+}
+
+static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+ void *cb_data)
+{
+ struct sr_datafeed_packet packet;
+ struct sr_datafeed_header header;
+ struct sr_datafeed_meta_logic meta;