diff options
author | Robin Gareus <robin@gareus.org> | 2020-03-05 20:18:54 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-03-06 01:49:44 +0100 |
commit | 18514408637c9b49a1858443a4f1a37023244599 (patch) | |
tree | b640ccf40bc2ed28fd011eb4fb4a2808850f2c78 /libs/ardour/export_handler.cc | |
parent | 128a45954cfbfeaa0fd70c626a5d0c3c86e2ff7a (diff) |
Fix realtime export of multiple time-spans
After exporting a time-span, the next time-span was started
directly from the rt-callback. This had various issues.
In particular with realtime export.
Post-processing of a realtime-export enables freewheeling
and is driven by freewheel callbacks. Freewheeling needs to be
safely disabled for an upcoming realtime export.
A similar issues existed when mixing realtime and non-realtime exports.
Diffstat (limited to 'libs/ardour/export_handler.cc')
-rw-r--r-- | libs/ardour/export_handler.cc | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index 4aed0ee97e..76869c7a79 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -172,6 +172,14 @@ ExportHandler::start_timespan () { export_status->timespan++; + /* stop freewheeling and wait for latency callbacks */ + if (AudioEngine::instance()->freewheeling ()) { + AudioEngine::instance()->freewheel (false); + do { + Glib::usleep (AudioEngine::instance()->usecs_per_cycle ()); + } while (AudioEngine::instance()->freewheeling ()); + } + if (config_map.empty()) { // freewheeling has to be stopped from outside the process cycle export_status->set_running (false); @@ -266,10 +274,11 @@ ExportHandler::process (samplecnt_t samples) // wait until we're freewheeling return 0; } - } else { + } else if (samples > 0) { Glib::Threads::Mutex::Lock l (export_status->lock()); return process_timespan (samples); } + return 0; } int @@ -338,6 +347,16 @@ ExportHandler::command_output(std::string output, size_t size) info << output << endmsg; } +void* +ExportHandler::start_timespan_bg (void* eh) +{ + ExportHandler* self = static_cast<ExportHandler*> (eh); + self->process_connection.disconnect (); + Glib::Threads::Mutex::Lock l (self->export_status->lock()); + self->start_timespan (); + return 0; +} + void ExportHandler::finish_timespan () { @@ -474,7 +493,12 @@ ExportHandler::finish_timespan () config_map.erase (config_map.begin()); } - start_timespan (); + /* finish timespan is called in freewheeling rt-context, + * we cannot start a new export from here */ + assert (AudioEngine::instance()->freewheeling ()); + pthread_t tid; + pthread_create (&tid, NULL, ExportHandler::start_timespan_bg, this); + pthread_detach (tid); } void |