From 6aa29f3b093b02ad8a8372e5a34807ae5226f8ca Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 30 Jan 2015 12:57:58 -0500 Subject: [PATCH] make sure we allocate large enough buffers when doing a non-butler context disk buffer refill. 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 2ebc5a8d2d..f0f70638ab 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -1070,8 +1070,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));