reduce stack space requirements for export and normalization

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@7003 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-04-27 14:29:44 +00:00
parent 3ee7780750
commit 91fc0c70bc
2 changed files with 18 additions and 7 deletions

View file

@ -21,9 +21,10 @@
#include <climits>
#include <cfloat>
#include <algorithm>
#include <set>
#include <boost/scoped_array.hpp>
#include <sigc++/bind.h>
#include <sigc++/class_slot.h>
@ -1330,11 +1331,11 @@ AudioRegion::exportme (Session& session, AudioExportSpecification& spec)
} else {
Sample buf[blocksize];
boost::scoped_array<Sample> buf (new Sample[blocksize]);
for (uint32_t chan = 0; chan < spec.channels; ++chan) {
if (sources[chan]->read (buf, _start + spec.pos, to_read) != to_read) {
if (sources[chan]->read (buf.get(), _start + spec.pos, to_read) != to_read) {
goto out;
}
@ -1402,7 +1403,7 @@ void
AudioRegion::normalize_to (float target_dB)
{
const nframes_t blocksize = 64 * 1024;
Sample buf[blocksize];
boost::scoped_array<Sample> buf (new Sample[blocksize]);
nframes_t fpos;
nframes_t fend;
nframes_t to_read;
@ -1431,11 +1432,11 @@ AudioRegion::normalize_to (float target_dB)
/* read it in */
if (source (n)->read (buf, fpos, to_read) != to_read) {
if (source (n)->read (buf.get(), fpos, to_read) != to_read) {
return;
}
maxamp = Session::compute_peak (buf, to_read, maxamp);
maxamp = Session::compute_peak (buf.get(), to_read, maxamp);
}
fpos += to_read;

View file

@ -346,6 +346,8 @@ AutomationList::merge_nascent (double when)
return;
}
cerr << "We have " << nascent.size() << " NI's to merge\n";
for (list<NascentInfo*>::iterator n = nascent.begin(); n != nascent.end(); ++n) {
NascentInfo* ninfo = *n;
@ -368,17 +370,22 @@ AutomationList::merge_nascent (double when)
if (!preexisting) {
cerr << "no prexisting - merge\n";
events = nascent_events;
} else if (ninfo->end_time < events.front()->when) {
/* all points in nascent are before the first existing point */
cerr << "all before first, prepend\n";
events.insert (events.begin(), nascent_events.begin(), nascent_events.end());
} else if (ninfo->start_time > events.back()->when) {
/* all points in nascent are after the last existing point */
cerr << "all after last, append\n";
events.insert (events.end(), nascent_events.begin(), nascent_events.end());
@ -413,13 +420,16 @@ AutomationList::merge_nascent (double when)
if (range_begin != events.begin()) {
/* clamp point before */
cerr << "Add pre-clamp\n";
events.insert (range_begin, point_factory (ninfo->start_time, unlocked_eval (ninfo->start_time)));
}
cerr << "merge into event list\n";
events.insert (range_begin, nascent_events.begin(), nascent_events.end());
if (range_end != events.end()) {
/* clamp point after */
cerr << "Add post-clamp\n";
events.insert (range_begin, point_factory (ninfo->end_time, end_value));
}