rework design of midi clock ticker to avoid expensive generalization that has turned...
[ardour.git] / libs / ardour / session_export.cc
index 75c8fd0dd75404d53d3beaa37bd405122334210a..4f46535a978e88429c8e350a8da13afb1eb1d162 100644 (file)
@@ -62,8 +62,6 @@ Session::pre_export ()
 {
        get_export_status (); // Init export_status
 
-       _butler->wait_until_finished ();
-
        /* take everyone out of awrite to avoid disasters */
 
        {
@@ -95,13 +93,21 @@ Session::pre_export ()
        return 0;
 }
 
+/** Called for each range that is being exported */
 int
-Session::start_audio_export (nframes_t position, bool /* realtime */)
+Session::start_audio_export (framepos_t position, bool /* realtime */)
 {
        if (!_exporting) {
                pre_export ();
        }
 
+       /* 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.
+       */
+       
+       _butler->wait_until_finished ();
+
        /* get everyone to the right position */
 
        {
@@ -149,7 +155,7 @@ Session::start_audio_export (nframes_t position, bool /* realtime */)
 }
 
 void
-Session::process_export (nframes_t nframes)
+Session::process_export (pframes_t nframes)
 {
        if (_export_rolling && export_status->stop) {
                stop_audio_export ();
@@ -165,20 +171,20 @@ Session::process_export (nframes_t nframes)
 
                process_without_events (nframes);
        }
-       
+
        try {
                /* handle export - XXX what about error handling? */
 
                ProcessExport (nframes);
 
        } catch (std::exception & e) {
-               std::cout << e.what() << std::endl;
+               error << string_compose (_("Export ended unexpectedly: %1"), e.what()) << endmsg;
                export_status->abort (true);
        }
 }
 
 int
-Session::process_export_fw (nframes_t nframes)
+Session::process_export_fw (pframes_t nframes)
 {
         _engine.main_thread()->get_buffers ();
        process_export (nframes);
@@ -216,6 +222,9 @@ Session::finalize_audio_export ()
 
        _engine.freewheel (false);
        export_freewheel_connection.disconnect();
+       
+       /* maybe write CUE/TOC */
+
        export_handler.reset();
        export_status.reset();