make sure we allocate large enough buffers when doing a non-butler context disk buffe...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 30 Jan 2015 17:57:58 +0000 (12:57 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 29 Jun 2015 18:18:13 +0000 (14:18 -0400)
The size of the buffer now needs to reflect that we calculate read
refills in bytes, and if we are not using 32 bit float sample format
on disk, that can translate into > 1M samples.

libs/ardour/audio_diskstream.cc

index e36f905d7cb60a90671fb375002e223da2afbcda..ed7f21cc1661a32b68a4efbfd2c7d20ee015c07a 100644 (file)
@@ -1079,8 +1079,14 @@ AudioDiskstream::read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer,
 int
 AudioDiskstream::_do_refill_with_alloc (bool partial_fill)
 {
-       Sample* mix_buf  = new Sample[1048576];
-       float*  gain_buf = new float[1048576];
+       /* We limit disk reads to at most 4MB chunks, which with floating point
+          samples would be 1M samples. But we might use 16 or 14 bit samples,
+          in which case 4MB is more samples than that. Therefore size this for
+          the smallest sample value .. 4MB = 2M samples (16 bit).
+       */
+
+       Sample* mix_buf  = new Sample[2*1048576];
+       float*  gain_buf = new float[2*1048576];
 
        int ret = _do_refill (mix_buf, gain_buf, (partial_fill ? disk_read_chunk_frames : 0));