From 2a5dbff87ba42d84e86285c92b9afc69f1edf07b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 12 May 2015 14:33:41 -0400 Subject: [PATCH] ensure that working buffers (for gain + mixing) are large enough. Remove AudioDiskstream and AudioSource _working_buffers_size members, since they are no longer used --- libs/ardour/ardour/audio_diskstream.h | 1 - libs/ardour/ardour/audiosource.h | 2 -- libs/ardour/audio_diskstream.cc | 12 +++++++----- libs/ardour/audiosource.cc | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/libs/ardour/ardour/audio_diskstream.h b/libs/ardour/ardour/audio_diskstream.h index 9eb94b9573..33126b5baf 100644 --- a/libs/ardour/ardour/audio_diskstream.h +++ b/libs/ardour/ardour/audio_diskstream.h @@ -249,7 +249,6 @@ class LIBARDOUR_API AudioDiskstream : public Diskstream static void allocate_working_buffers(); static void free_working_buffers(); - static size_t _working_buffers_size; static Sample* _mixdown_buffer; static gain_t* _gain_buffer; diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index 095d9d2169..c02310ea28 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -109,8 +109,6 @@ class LIBARDOUR_API AudioSource : virtual public Source, static bool _build_missing_peakfiles; static bool _build_peakfiles; - static size_t _working_buffers_size; - /* these collections of working buffers for supporting playlist's reading from potentially nested/recursive sources assume SINGLE THREADED reads by the butler diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index fcb5d39bc5..8470b98e66 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -63,7 +63,6 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -size_t AudioDiskstream::_working_buffers_size = 0; Sample* AudioDiskstream::_mixdown_buffer = 0; gain_t* AudioDiskstream::_gain_buffer = 0; @@ -134,9 +133,13 @@ AudioDiskstream::~AudioDiskstream () void AudioDiskstream::allocate_working_buffers() { - _working_buffers_size = max (disk_write_chunk_frames, disk_read_chunk_frames); - _mixdown_buffer = new Sample[_working_buffers_size]; - _gain_buffer = new gain_t[_working_buffers_size]; + /* with varifill buffer refilling, we compute the read size in bytes (to optimize + for disk i/o bandwidth) and then convert back into samples. These buffers + need to reflect the maximum size we could use, which is 4MB reads, or 2M samples + using 16 bit samples. + */ + _mixdown_buffer = new Sample[2*1048576]; + _gain_buffer = new gain_t[2*1048576]; } void @@ -144,7 +147,6 @@ AudioDiskstream::free_working_buffers() { delete [] _mixdown_buffer; delete [] _gain_buffer; - _working_buffers_size = 0; _mixdown_buffer = 0; _gain_buffer = 0; } diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 566a37f5bb..025652aa3b 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -68,7 +68,6 @@ using namespace PBD; Glib::Threads::Mutex AudioSource::_level_buffer_lock; vector > AudioSource::_mixdown_buffers; vector > AudioSource::_gain_buffers; -size_t AudioSource::_working_buffers_size = 0; bool AudioSource::_build_missing_peakfiles = false; /** true if we want peakfiles (e.g. if we are displaying a GUI) */