reduce stack space requirements for export and normalization
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Apr 2010 14:29:44 +0000 (14:29 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Apr 2010 14:29:44 +0000 (14:29 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@7003 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/audioregion.cc
libs/ardour/automation_event.cc

index 301e605a3e6cf657e0cd67c0d04ca4552b1df025..c329a26b1cc6855bedaec2f09588294d250c96e6 100644 (file)
 #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;
index cd683a2cab7a958a8626c6257875ed7144eee8a0..28b7dde050b6b94ea5eacbf7bc5d6ddcaed859b6 100644 (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));
                                 }