fast region export -- don't call process()
authorRobin Gareus <robin@gareus.org>
Mon, 17 Oct 2016 19:34:40 +0000 (21:34 +0200)
committerRobin Gareus <robin@gareus.org>
Mon, 17 Oct 2016 19:35:00 +0000 (21:35 +0200)
libs/ardour/ardour/session.h
libs/ardour/export_handler.cc
libs/ardour/session.cc
libs/ardour/session_export.cc

index a156a4243c51b980744c680573dc5697f56fd57d..d76c65c675d556dad1c31e94ab69f102e900a853 100644 (file)
@@ -725,7 +725,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        boost::shared_ptr<ExportHandler> get_export_handler ();
        boost::shared_ptr<ExportStatus> get_export_status ();
 
-       int start_audio_export (framepos_t position, bool realtime = false);
+       int start_audio_export (framepos_t position, bool realtime = false, bool region_export = false);
 
        PBD::Signal1<int, framecnt_t> ProcessExport;
        static PBD::Signal2<void,std::string, std::string> Exported;
@@ -1283,6 +1283,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        bool _exporting;
        bool _export_rolling;
        bool _realtime_export;
+       bool _region_export;
        framepos_t _export_preroll;
        framepos_t _export_latency;
 
index ac2f7b0bd37ac1718219eb46666938fcdf6cfbcc..3bdfdc90901179c4b774eb76f9e409c7743523c2 100644 (file)
@@ -191,19 +191,32 @@ ExportHandler::start_timespan ()
        graph_builder->set_current_timespan (current_timespan);
        handle_duplicate_format_extensions();
        bool realtime = current_timespan->realtime ();
+       bool region_export = true;
        for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
                // Filenames can be shared across timespans
                FileSpec & spec = it->second;
                spec.filename->set_timespan (it->first);
+               switch (spec.channel_config->region_processing_type ()) {
+                       case RegionExportChannelFactory::None:
+                       case RegionExportChannelFactory::Processed:
+                               region_export = false;
+                               break;
+                       default:
+                               break;
+               }
                graph_builder->add_config (spec, realtime);
        }
 
+       // ExportDialog::update_realtime_selection does not allow this
+       assert (!region_export || !realtime);
+
        /* start export */
 
        post_processing = false;
        session.ProcessExport.connect_same_thread (process_connection, boost::bind (&ExportHandler::process, this, _1));
        process_position = current_timespan->get_start();
-       session.start_audio_export (process_position, realtime);
+       // TODO check if it's a RegionExport.. set flag to skip  process_without_events()
+       session.start_audio_export (process_position, realtime, region_export);
 }
 
 void
index ce86483d75fa208576f7f8e7128e0919d67c8561..f89440b86ac018cd0de7f18c9970ab00cacb3fca 100644 (file)
@@ -213,6 +213,7 @@ Session::Session (AudioEngine &eng,
        , _exporting (false)
        , _export_rolling (false)
        , _realtime_export (false)
+       , _region_export (false)
        , _export_preroll (0)
        , _export_latency (0)
        , _pre_export_mmc_enabled (false)
index 463f50441121fc1e5d090c9b6ac6092f69341cde..23172838d075c7726dcfd8d02f413c5c2927a1db 100644 (file)
@@ -104,15 +104,19 @@ Session::pre_export ()
 
 /** Called for each range that is being exported */
 int
-Session::start_audio_export (framepos_t position, bool realtime)
+Session::start_audio_export (framepos_t position, bool realtime, bool region_export)
 {
        if (!_exporting) {
                pre_export ();
        }
 
        _realtime_export = realtime;
+       _region_export = region_export;
 
-       if (realtime) {
+       if (region_export) {
+               _export_preroll = 0;
+       }
+       else if (realtime) {
                _export_preroll = nominal_frame_rate ();
        } else {
                _export_preroll = Config->get_export_preroll() * nominal_frame_rate ();
@@ -134,6 +138,10 @@ Session::start_audio_export (framepos_t position, bool realtime)
         */
        _export_latency = worst_track_latency ();
 
+       if (region_export) {
+               _export_latency = 0;
+       }
+
        /* We're about to call Track::seek, so the butler must have finished everything
           up otherwise it could be doing do_refill in its thread while we are doing
           it here.
@@ -197,19 +205,26 @@ Session::process_export (pframes_t nframes)
                stop_audio_export ();
        }
 
-       if (_export_rolling) {
-               if (!_realtime_export)  {
-                       /* make sure we've caught up with disk i/o, since
-                        * we're running faster than realtime c/o JACK.
-                        */
-                       _butler->wait_until_finished ();
-               }
+       /* for Region Raw or Fades, we can skip this
+        * RegionExportChannelFactory::update_buffers() does not care
+        * about anything done here
+        */
+       if (!_region_export) {
+               if (_export_rolling) {
+                       if (!_realtime_export)  {
+                               /* make sure we've caught up with disk i/o, since
+                                * we're running faster than realtime c/o JACK.
+                                */
+                               _butler->wait_until_finished ();
+                       }
 
-               /* do the usual stuff */
+                       /* do the usual stuff */
 
-               process_without_events (nframes);
-       } else if (_realtime_export) {
-               fail_roll (nframes); // somehow we need to silence _ALL_ output buffers
+                       process_without_events (nframes);
+
+               } else if (_realtime_export) {
+                       fail_roll (nframes); // somehow we need to silence _ALL_ output buffers
+               }
        }
 
        try {