From b411eeb74e8545ff844414cf2d6fb63c680d75ff Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 1 Apr 2022 21:41:30 +0200 Subject: [PATCH] Fix crash when exporting multiple timespans with MIDI tracks ::start_audio_export() may be called from a background thread which does not yet have a thread-local TempoMap. Track::seek() calls ARDOUR::AudioPlaylist::read() which calls Playlist::regions_touched_locked() which may require a TempoMap to calculate overage with Temporal::Beats --- libs/ardour/session_export.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index 8489a65ba6..ebb20e4055 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -165,7 +165,13 @@ Session::start_audio_export (samplepos_t position, bool realtime, bool region_ex Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ()); _butler->wait_until_finished (); - /* get everyone to the right position */ + /* This method may be called from a thread start_timespan_bg(), + * or from the GUI thread. We need to set/update the tempo-map + * thread-local variable before calling Track::seek + */ + Temporal::TempoMap::update_thread_tempo_map (); + + /* get everyone to the right position */ boost::shared_ptr rl = routes.reader();