+ /* total_space is in samples. We want to optimize read sizes in various sizes using bytes */
+
+ const size_t bits_per_sample = format_data_width (_session.config.get_native_file_data_format());
+ size_t total_bytes = total_space * bits_per_sample / 8;
+
+ /* chunk size range is 256kB to 4MB. Bigger is faster in terms of MB/sec, but bigger chunk size always takes longer
+ */
+ size_t byte_size_for_read = max ((size_t) (256 * 1024), min ((size_t) (4 * 1048576), total_bytes));
+
+ /* find nearest (lower) multiple of 16384 */
+
+ byte_size_for_read = (byte_size_for_read / 16384) * 16384;
+
+ /* now back to samples */
+
+ framecnt_t samples_to_read = byte_size_for_read / (bits_per_sample / 8);
+
+ //cerr << name() << " will read " << byte_size_for_read << " out of total bytes " << total_bytes << " in buffer of "
+ // << c->front()->playback_buf->bufsize() * bits_per_sample / 8 << " bps = " << bits_per_sample << endl;
+ // cerr << name () << " read samples = " << samples_to_read << " out of total space " << total_space << " in buffer of " << c->front()->playback_buf->bufsize() << " samples\n";
+
+ // uint64_t before = g_get_monotonic_time ();
+ // uint64_t elapsed;
+