Fix potential deadlock when exporting w/normalizing

start_post_processing() may be called from the freewheeling
callback, when starting to normalize.
This commit is contained in:
Robin Gareus 2020-03-06 21:34:55 +01:00
parent 77d12b490e
commit dd46dfe8d2
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 12 additions and 4 deletions

View File

@ -278,7 +278,8 @@ class LIBARDOUR_API ExportGraphBuilder
bool _realtime;
samplecnt_t _master_align;
Glib::ThreadPool thread_pool;
Glib::ThreadPool thread_pool;
Glib::Threads::Mutex engine_request_lock;
};
} // namespace ARDOUR

View File

@ -678,12 +678,19 @@ ExportGraphBuilder::Intermediate::prepare_post_processing()
void
ExportGraphBuilder::Intermediate::start_post_processing()
{
/* called in disk-thread (when exporting in realtime) */
tmp_file->seek (0, SEEK_SET);
/* RT Stem export has multiple TmpFileRt threads,
/* called in disk-thread when exporting in realtime,
* to enable freewheeling for post-proc.
*
* It may also be called to normalize from the
* freewheeling rt-callback, in which case this
* will be a no-op.
*
* RT Stem export has multiple TmpFileRt threads,
* prevent concurrent calls to enable freewheel ()
*/
Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
Glib::Threads::Mutex::Lock lm (parent.engine_request_lock);
if (!AudioEngine::instance()->freewheeling ()) {
AudioEngine::instance()->freewheel (true);
while (!AudioEngine::instance()->freewheeling ()) {