re-work bounce/freeze. Freezer stops at first active delivery.
authorRobin Gareus <robin@gareus.org>
Tue, 3 Jun 2014 19:08:45 +0000 (21:08 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 4 Jun 2014 00:19:46 +0000 (02:19 +0200)
amend to 8f52bf7d9f

libs/ardour/ardour/audio_track.h
libs/ardour/ardour/auditioner.h
libs/ardour/ardour/midi_track.h
libs/ardour/ardour/route.h
libs/ardour/ardour/session.h
libs/ardour/ardour/track.h
libs/ardour/audio_track.cc
libs/ardour/export_channel.cc
libs/ardour/midi_track.cc
libs/ardour/route.cc
libs/ardour/session.cc

index 1ecec88f8986f3d8431f567978bbfb96ddff45a9..0bc8be81f45b066ac8f8d2b57a4cb954a247f353 100644 (file)
@@ -58,7 +58,7 @@ class LIBARDOUR_API AudioTrack : public Track
        boost::shared_ptr<Region> bounce_range (framepos_t start, framepos_t end, InterThreadInfo&, 
                                                boost::shared_ptr<Processor> endpoint, bool include_endpoint);
        int export_stuff (BufferSet& bufs, framepos_t start_frame, framecnt_t nframes,
-                         boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export);
+                         boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze);
 
        int set_state (const XMLNode&, int version);
 
index 6aeda90eb814acba6f02c3cbd29c3295bb79ad74..452f7eb2462ba6e856d152f85b3739863f3f5157 100644 (file)
@@ -97,7 +97,7 @@ class LIBARDOUR_API Auditioner : public Track
        boost::shared_ptr<Region> bounce_range (framepos_t, framepos_t, InterThreadInfo&, boost::shared_ptr<Processor>, bool)
                { return boost::shared_ptr<Region> (); }
 
-       int export_stuff (BufferSet&, framepos_t, framecnt_t, boost::shared_ptr<Processor>, bool, bool)
+       int export_stuff (BufferSet&, framepos_t, framecnt_t, boost::shared_ptr<Processor>, bool, bool, bool)
                { return -1; }
 
        boost::shared_ptr<Diskstream> diskstream_factory (XMLNode const &)
index cf6d3f7b6476c8fbc1eb4007e4adaf50e6a766a5..1acec0346eb4ecf7cc75322da26bcf9df9be41fd 100644 (file)
@@ -72,7 +72,8 @@ public:
                          framecnt_t                   end_frame,
                          boost::shared_ptr<Processor> endpoint,
                          bool                         include_endpoint,
-                         bool                         for_export);
+                         bool                         for_export,
+                         bool                         for_freeze);
 
        int set_state (const XMLNode&, int version);
 
index 9235ed32b6c0b7d31e1c2247fb7172176c160195..7eb115490d8cecbb8a83546c051903b8f487cbb9 100644 (file)
@@ -473,10 +473,10 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
        virtual void bounce_process (BufferSet& bufs,
                                     framepos_t start_frame, framecnt_t nframes,
                                                                                                                         boost::shared_ptr<Processor> endpoint, bool include_endpoint,
-                                    bool for_export);
+                                    bool for_export, bool for_freeze);
 
-       framecnt_t   bounce_get_latency (boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export) const;
-       ChanCount    bounce_get_output_streams (ChanCount &cc, boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export) const;
+       framecnt_t   bounce_get_latency (boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) const;
+       ChanCount    bounce_get_output_streams (ChanCount &cc, boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) const;
 
        boost::shared_ptr<IO> _input;
        boost::shared_ptr<IO> _output;
index 89c33f23ece81ad5c5ce9e7b74bc04aa927d288f..08d0ec1e4e12cbbc91ad373242550ab45bed06cb 100644 (file)
@@ -608,7 +608,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
 
        boost::shared_ptr<Region> write_one_track (AudioTrack&, framepos_t start, framepos_t end,
                                                   bool overwrite, std::vector<boost::shared_ptr<Source> >&, InterThreadInfo& wot,
-                                                  boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export);
+                                                  boost::shared_ptr<Processor> endpoint,
+                                                        bool include_endpoint, bool for_export, bool for_freeze);
        int freeze_all (InterThreadInfo&);
 
        /* session-wide solo/mute/rec-enable */
index ee74fee46e883711e3484e19d8c662b53bbada4f..736ca8c6dd8662ae9a20e94122a67bc6feb65da8 100644 (file)
@@ -96,7 +96,7 @@ class LIBARDOUR_API Track : public Route, public PublicDiskstream
        virtual boost::shared_ptr<Region> bounce_range (framepos_t start, framepos_t end, InterThreadInfo&, 
                                                        boost::shared_ptr<Processor> endpoint, bool include_endpoint) = 0;
        virtual int export_stuff (BufferSet& bufs, framepos_t start_frame, framecnt_t nframes,
-                                 boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export) = 0;
+                                 boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze) = 0;
 
        XMLNode&    get_state();
        XMLNode&    get_template();
index 61b6e56bb6676d871d884607e6d3b03a99d4a1af..13d5c43dda312d392e93199defdbd6a6b94f858c 100644 (file)
@@ -383,7 +383,7 @@ AudioTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram
 
 int
 AudioTrack::export_stuff (BufferSet& buffers, framepos_t start, framecnt_t nframes,
-                         boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export)
+                         boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze)
 {
        boost::scoped_array<gain_t> gain_buffer (new gain_t[nframes]);
        boost::scoped_array<Sample> mix_buffer (new Sample[nframes]);
@@ -417,7 +417,7 @@ AudioTrack::export_stuff (BufferSet& buffers, framepos_t start, framecnt_t nfram
                }
        }
 
-       bounce_process (buffers, start, nframes, endpoint, include_endpoint, for_export);
+       bounce_process (buffers, start, nframes, endpoint, include_endpoint, for_export, for_freeze);
 
        return 0;
 }
@@ -490,7 +490,7 @@ AudioTrack::bounce_range (framepos_t start, framepos_t end, InterThreadInfo& itt
                          boost::shared_ptr<Processor> endpoint, bool include_endpoint)
 {
        vector<boost::shared_ptr<Source> > srcs;
-       return _session.write_one_track (*this, start, end, false, srcs, itt, endpoint, include_endpoint, false);
+       return _session.write_one_track (*this, start, end, false, srcs, itt, endpoint, include_endpoint, false, false);
 }
 
 void
@@ -533,8 +533,8 @@ AudioTrack::freeze_me (InterThreadInfo& itt)
 
        boost::shared_ptr<Region> res;
 
-       if ((res = _session.write_one_track (*this, _session.current_start_frame(), _session.current_end_frame(), true, srcs, itt, 
-                                            main_outs(), false, false)) == 0) {
+       if ((res = _session.write_one_track (*this, _session.current_start_frame(), _session.current_end_frame(),
+                                       true, srcs, itt, main_outs(), false, false, true)) == 0) {
                return;
        }
 
@@ -545,7 +545,10 @@ AudioTrack::freeze_me (InterThreadInfo& itt)
 
                for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) {
 
-                       if (!(*r)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*r)) {
+                       if ((*r)->does_routing() && (*r)->active()) {
+                               break;
+                       }
+                       if (!boost::dynamic_pointer_cast<PeakMeter>(*r)) {
 
                                FreezeRecordProcessorInfo* frii  = new FreezeRecordProcessorInfo ((*r)->get_state(), (*r));
 
@@ -553,9 +556,10 @@ AudioTrack::freeze_me (InterThreadInfo& itt)
 
                                _freeze_record.processor_info.push_back (frii);
 
-                               /* now deactivate the processor */
-
-                               (*r)->deactivate ();
+                               /* now deactivate the processor, */
+                               if (!boost::dynamic_pointer_cast<Amp>(*r)) {
+                                       (*r)->deactivate ();
+                               }
                        }
                        
                        _session.set_dirty ();
index 8ea01f3ec3c424b583a6ee0834a1f257d30c3559..93621717381ca19c2c4ea4a7d95761aa47dd75d7 100644 (file)
@@ -192,7 +192,7 @@ RegionExportChannelFactory::update_buffers (framecnt_t frames)
                }
                break;
        case Processed:
-               track.export_stuff (buffers, position, frames, track.main_outs(), true, true);
+               track.export_stuff (buffers, position, frames, track.main_outs(), true, true, false);
                break;
        default:
                throw ExportFailed ("Unhandled type in ExportChannelFactory::update_buffers");
index b820c001e1c1a846cd7d4aaaec35df0bb26c5c84..638ed057063a56b08b0e2f034fa4d6cc1d336260 100644 (file)
@@ -547,7 +547,7 @@ MidiTrack::write_out_of_band_data (BufferSet& bufs, framepos_t /*start*/, framep
 
 int
 MidiTrack::export_stuff (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framecnt_t /*nframes*/, 
-                        boost::shared_ptr<Processor> /*endpoint*/, bool /*include_endpoint*/, bool /*forexport*/)
+                        boost::shared_ptr<Processor> /*endpoint*/, bool /*include_endpoint*/, bool /*for_export*/, bool /*for_freeze*/)
 {
        return -1;
 }
index 4b899197d296ee126a4a216bac3f0bf1bc4c32fe..11f8ac25950748e6875d245097937c6f403fa640 100644 (file)
@@ -538,7 +538,8 @@ Route::process_output_buffers (BufferSet& bufs,
 
 void
 Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
-                         boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export)
+               boost::shared_ptr<Processor> endpoint,
+               bool include_endpoint, bool for_export, bool for_freeze)
 {
        /* If no processing is required, there's no need to go any further. */
        if (!endpoint && !include_endpoint) {
@@ -558,6 +559,9 @@ Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
                if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
                        break;
                }
+               if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
+                       break;
+               }
 
                /* don't run any processors that does routing.
                 * oh, and don't bother with the peak meter either.
@@ -574,7 +578,8 @@ Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
 }
 
 framecnt_t
-Route::bounce_get_latency (boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export) const
+Route::bounce_get_latency (boost::shared_ptr<Processor> endpoint,
+               bool include_endpoint, bool for_export, bool for_freeze) const
 {
        framecnt_t latency = 0;
        if (!endpoint && !include_endpoint) {
@@ -588,6 +593,9 @@ Route::bounce_get_latency (boost::shared_ptr<Processor> endpoint, bool include_e
                if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
                        break;
                }
+               if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
+                       break;
+               }
                if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
                        latency += (*i)->signal_latency ();
                }
@@ -599,7 +607,8 @@ Route::bounce_get_latency (boost::shared_ptr<Processor> endpoint, bool include_e
 }
 
 ChanCount
-Route::bounce_get_output_streams (ChanCount &cc, boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export) const
+Route::bounce_get_output_streams (ChanCount &cc, boost::shared_ptr<Processor> endpoint,
+               bool include_endpoint, bool for_export, bool for_freeze) const
 {
        if (!endpoint && !include_endpoint) {
                return cc;
@@ -612,6 +621,9 @@ Route::bounce_get_output_streams (ChanCount &cc, boost::shared_ptr<Processor> en
                if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
                        break;
                }
+               if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
+                       break;
+               }
                if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
                        cc = (*i)->output_streams();
                }
index 0f0eb5b8f16422c72a42bbbe4f39a257f025bf3c..fbde7edf607dbf71074ce09d750eaf132fe5ea3e 100644 (file)
@@ -4124,7 +4124,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
                          bool /*overwrite*/, vector<boost::shared_ptr<Source> >& srcs,
                          InterThreadInfo& itt, 
                          boost::shared_ptr<Processor> endpoint, bool include_endpoint,
-                         bool for_export)
+                         bool for_export, bool for_freeze)
 {
        boost::shared_ptr<Region> result;
        boost::shared_ptr<Playlist> playlist;
@@ -4150,7 +4150,8 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
                return result;
        }
 
-       diskstream_channels = track.bounce_get_output_streams (diskstream_channels, endpoint, include_endpoint, for_export);
+       diskstream_channels = track.bounce_get_output_streams (diskstream_channels, endpoint,
+                       include_endpoint, for_export, for_freeze);
 
        if (diskstream_channels.n_audio() < 1) {
                error << _("Cannot write a range with no audio.") << endmsg;
@@ -4217,7 +4218,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
 
        position = start;
        to_do = len;
-       latency_skip = track.bounce_get_latency (endpoint, include_endpoint, for_export);
+       latency_skip = track.bounce_get_latency (endpoint, include_endpoint, for_export, for_freeze);
 
        /* create a set of reasonably-sized buffers */
        for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
@@ -4235,7 +4236,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
 
                this_chunk = min (to_do, bounce_chunk_size);
 
-               if (track.export_stuff (buffers, start, this_chunk, endpoint, include_endpoint, for_export)) {
+               if (track.export_stuff (buffers, start, this_chunk, endpoint, include_endpoint, for_export, for_freeze)) {
                        goto out;
                }
 
@@ -4264,14 +4265,14 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
        }
 
        /* post-roll, pick up delayed processor output */
-       latency_skip = track.bounce_get_latency (endpoint, include_endpoint, for_export);
+       latency_skip = track.bounce_get_latency (endpoint, include_endpoint, for_export, for_freeze);
 
        while (latency_skip && !itt.cancel) {
                this_chunk = min (latency_skip, bounce_chunk_size);
                latency_skip -= this_chunk;
 
                buffers.silence (this_chunk, 0);
-               track.bounce_process (buffers, start, this_chunk, endpoint, include_endpoint, for_export);
+               track.bounce_process (buffers, start, this_chunk, endpoint, include_endpoint, for_export, for_freeze);
 
                uint32_t n = 0;
                for (vector<boost::shared_ptr<Source> >::iterator src=srcs.begin(); src != srcs.end(); ++src, ++n) {