From 839400f4385b1eb4a4d44848b19eb4a9e7cd6153 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 12 Aug 2022 01:31:49 +0200 Subject: [PATCH] Fix peak-thread race on session-load Session dirs must exist when loading Sources of a project. SourceFactory::init() starts the PeakFileBuilder background thread early on when libardour is initialized. This thread [re-]creates missing peak files when Sources are created or loaded. However AudioSource::prepare_for_peakfile_writes assumes the peak/ folder exists. This may not be true, which lead to "AudioSource: cannot open _peakpath [..] (No such file or directory)" errors. Also drop creation from Source::get_transients_path() as this may be called concurrently from Analyser background threads. --- libs/ardour/session.cc | 4 ++-- libs/ardour/source.cc | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index a7741abb29..14ec08f75e 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -424,6 +424,8 @@ Session::Session (AudioEngine &eng, destroy (); throw SessionException (_("Failed to load state")); } + + ensure_subdirs (); // archived or zipped sessions may lack peaks/ analysis/ etc } /* apply the loaded state_tree */ @@ -509,8 +511,6 @@ Session::Session (AudioEngine &eng, _engine.set_session (this); _engine.reset_timebase (); - ensure_subdirs (); // archived or zipped sessions may lack peaks/ analysis/ etc - if (!mix_template.empty ()) { /* ::create() unsets _is_new after creating the session. * But for templated sessions, the sample-rate is initially unset diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc index 3f0e6991df..ab61d79628 100644 --- a/libs/ardour/source.cc +++ b/libs/ardour/source.cc @@ -368,10 +368,6 @@ Source::get_transients_path () const vector parts; string s; - /* old sessions may not have the analysis directory */ - - _session.ensure_subdirs (); - s = _session.analysis_dir (); parts.push_back (s);