From 32c7b18f6dd9140c3ad7d9e83dd3ac2e4ca86c4e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 25 Mar 2021 21:15:13 +0100 Subject: [PATCH] Relax export preparation timeout This increases timeout granularity and ensure that rt (TSFM) and butler thread can run to prepare exports. This may fix an issue some windows users reported "Cannot prepare transport for export", and increasing the buffersize to 1024 or 2048 works around the isssue. This also fixes an edge-case usecs_per_cycle() may return -1 (sleep forever) when the engine dies. --- libs/ardour/session_export.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index f167b17f66..318702a3ff 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -140,9 +140,11 @@ Session::start_audio_export (samplepos_t position, bool realtime, bool region_ex * to wait for it to wake up and call * non_realtime_stop (). */ - int timeout = std::max (10, (int)(8 * nominal_sample_rate () / get_block_size ())); + int sleeptm = std::max (40000, engine().usecs_per_cycle ()); + int timeout = std::max (100, 8000000 / sleeptm); do { - Glib::usleep (engine().usecs_per_cycle ()); + Glib::usleep (sleeptm); + sched_yield (); } while (_transport_fsm->waiting_for_butler() && --timeout > 0); if (timeout == 0) {