diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-03-21 10:14:01 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-03-21 10:14:01 -0400 |
commit | d99b5dfa37c7248e24a0266188752dfa6c9bb3f6 (patch) | |
tree | 8a06cf8d3ce0c7d0ec25deb4f536ef24e1ccddc6 /libs/ardour/audiosource.cc | |
parent | 027f0e156a4ed764b4a507b8bf81e0764ec0b6d2 (diff) |
fix nasty crash when using double-nested compound (consolidated) regions caused by not (re)allocating enough mixdown buffers; fix up various warnings from valgrind about mismatching operator delete[] by using shared_array<T> rather than shared_ptr<T>, as should have been the case all along
Diffstat (limited to 'libs/ardour/audiosource.cc')
-rw-r--r-- | libs/ardour/audiosource.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 4deb053cd8..5b60c577ee 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -47,8 +47,8 @@ using namespace ARDOUR; using namespace PBD; Glib::Threads::Mutex AudioSource::_level_buffer_lock; -vector<boost::shared_ptr<Sample> > AudioSource::_mixdown_buffers; -vector<boost::shared_ptr<gain_t> > AudioSource::_gain_buffers; +vector<boost::shared_array<Sample> > AudioSource::_mixdown_buffers; +vector<boost::shared_array<gain_t> > AudioSource::_gain_buffers; size_t AudioSource::_working_buffers_size = 0; bool AudioSource::_build_missing_peakfiles = false; @@ -984,11 +984,19 @@ AudioSource::ensure_buffers_for_level_locked (uint32_t level, framecnt_t frame_r { framecnt_t nframes = (framecnt_t) floor (Config->get_audio_playback_buffer_seconds() * frame_rate); + /* this may be called because either "level" or "frame_rate" have + * changed. and it may be called with "level" smaller than the current + * number of buffers, because a new compound region has been created at + * a more shallow level than the deepest one we currently have. + */ + + uint32_t limit = max ((size_t) level, _mixdown_buffers.size()); + _mixdown_buffers.clear (); _gain_buffers.clear (); - while (_mixdown_buffers.size() < level) { - _mixdown_buffers.push_back (boost::shared_ptr<Sample> (new Sample[nframes])); - _gain_buffers.push_back (boost::shared_ptr<gain_t> (new gain_t[nframes])); + for (uint32_t n = 0; n < limit; ++n) { + _mixdown_buffers.push_back (boost::shared_array<Sample> (new Sample[nframes])); + _gain_buffers.push_back (boost::shared_array<gain_t> (new gain_t[nframes])); } } |