diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index 79e0b5a51b..0c8811a969 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -110,9 +110,11 @@ Session::pre_export () int Session::start_audio_export (samplepos_t position, bool realtime, bool region_export) { + assert (!engine().in_process_thread ()); + if (!_exporting) { pre_export (); - } else { + } else if (_transport_speed != 0) { realtime_stop (true, true); } @@ -132,13 +134,21 @@ Session::start_audio_export (samplepos_t position, bool realtime, bool region_ex _export_preroll = 1; } + /* realtime_stop will have queued butler work (and TSFM), + * but the butler may not run immediately, so well have + * to wait for it to wake up and call + * non_realtime_stop (). + */ + do { + Glib::usleep (engine().usecs_per_cycle ()); + _butler->schedule_transport_work (); + } while (0 != post_transport_work ()); + /* 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. */ - Glib::usleep (engine().usecs_per_cycle ()); - _butler->schedule_transport_work (); _butler->wait_until_finished (); /* get everyone to the right position */ @@ -241,7 +251,8 @@ Session::process_export (pframes_t nframes) if (ProcessExport (nframes).value_or (0) > 0) { /* last cycle completed */ - flush_all_inserts (); + assert (_export_rolling); + stop_audio_export (); } } catch (std::exception & e) { @@ -361,6 +372,7 @@ Session::stop_audio_export () */ realtime_stop (true, true); + flush_all_inserts (); _export_rolling = false; _butler->schedule_transport_work (); diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index f136eebc5d..64dc5b3a7e 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -1568,6 +1568,13 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) DEBUG_TRACE (DEBUG::Transport, string_compose ("send TSC with speed = %1\n", _transport_speed)); TransportStateChange (); /* EMIT SIGNAL */ AutomationWatch::instance().transport_stop_automation_watches (_transport_sample); + +#if 0 + if (_exporting && !_realtime_export) { + ptw = PostTransportWork (ptw & ~(PostTransportStop)); + set_post_transport_work (ptw); + } +#endif } void