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
This commit is contained in:
parent
027f0e156a
commit
d99b5dfa37
@ -21,7 +21,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/scoped_array.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
@ -1538,7 +1537,7 @@ AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecn
|
||||
}
|
||||
|
||||
Points* points = get_canvas_points ("xfade edit redraw", npoints);
|
||||
boost::scoped_ptr<float> vec (new float[npoints]);
|
||||
boost::scoped_array<float> vec (new float[npoints]);
|
||||
|
||||
ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define __ardour_audio_source_h__
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/shared_array.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
|
||||
#include <time.h>
|
||||
@ -116,8 +117,8 @@ class AudioSource : virtual public Source,
|
||||
thread, or a lock around calls that use them.
|
||||
*/
|
||||
|
||||
static std::vector<boost::shared_ptr<Sample> > _mixdown_buffers;
|
||||
static std::vector<boost::shared_ptr<gain_t> > _gain_buffers;
|
||||
static std::vector<boost::shared_array<Sample> > _mixdown_buffers;
|
||||
static std::vector<boost::shared_array<gain_t> > _gain_buffers;
|
||||
static Glib::Threads::Mutex _level_buffer_lock;
|
||||
|
||||
static void ensure_buffers_for_level (uint32_t, framecnt_t);
|
||||
|
@ -164,8 +164,8 @@ ARDOUR::framecnt_t
|
||||
AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, framepos_t start,
|
||||
framecnt_t cnt, unsigned chan_n)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("Playlist %1 read @ %2 for %3, channel %4, regions %5\n",
|
||||
name(), start, cnt, chan_n, regions.size()));
|
||||
DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("Playlist %1 read @ %2 for %3, channel %4, regions %5 mixdown @ %6 gain @ %7\n",
|
||||
name(), start, cnt, chan_n, regions.size(), mixdown_buffer, gain_buffer));
|
||||
|
||||
/* optimizing this memset() away involves a lot of conditionals
|
||||
that may well cause more of a hit due to cache misses
|
||||
|
@ -127,8 +127,8 @@ AudioPlaylistSource::set_state (const XMLNode& node, int version, bool with_desc
|
||||
framecnt_t
|
||||
AudioPlaylistSource::read_unlocked (Sample* dst, framepos_t start, framecnt_t cnt) const
|
||||
{
|
||||
boost::shared_ptr<Sample> sbuf;
|
||||
boost::shared_ptr<gain_t> gbuf;
|
||||
boost::shared_array<Sample> sbuf;
|
||||
boost::shared_array<gain_t> gbuf;
|
||||
framecnt_t to_read;
|
||||
framecnt_t to_zero;
|
||||
|
||||
|
@ -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]));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user