From feed9648e19f5750b102a161a1028bb143ea16c5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 11 Oct 2016 22:05:27 +0200 Subject: [PATCH] Allow loading sessions with missing external files #7067 The issue was introduced in dbf86a495b, forcing must_exist = true for *all* files that have a absolute _origin, including stub SilentFileSources. If an external file is no longer available and a user chooses to "ignore, skip" an SilentFile is created instead of the actual source, The SilentFileSource has the same XML state which includes _origin. ARDOUR::SilentFileSource::SilentFileSource () c'tor calls AudioFileSource::AudioFileSource (,.., must_exit = false) but since the file has an absolute _origin, the AudioFileSource c'tor sets must_exist = true; throws and the session cannot be loaded. --- libs/ardour/ardour/audiofilesource.h | 2 +- libs/ardour/ardour/silentfilesource.h | 2 +- libs/ardour/audiofilesource.cc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index d91280284d..b833ee1807 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -88,7 +88,7 @@ protected: SampleFormat samp_format, HeaderFormat hdr_format); /** Constructor to be called for existing in-session files */ - AudioFileSource (Session&, const XMLNode&, bool must_exist = true); + AudioFileSource (Session&, const XMLNode&, bool must_exist = true, bool optional_origin = false); /** Constructor to be called for crash recovery. Final argument is not * used but exists to differentiate from the external-to-session diff --git a/libs/ardour/ardour/silentfilesource.h b/libs/ardour/ardour/silentfilesource.h index 80f4b361b2..ebc295d08d 100644 --- a/libs/ardour/ardour/silentfilesource.h +++ b/libs/ardour/ardour/silentfilesource.h @@ -45,7 +45,7 @@ protected: SilentFileSource (Session& s, const XMLNode& x, framecnt_t len, float srate) : Source (s, x) - , AudioFileSource (s, x, false) + , AudioFileSource (s, x, false, true) , _sample_rate(srate) { _length = len; diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index a25e19ea5a..8e1f50a55d 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -135,7 +135,7 @@ AudioFileSource::AudioFileSource (Session& s, const string& path, Source::Flag f * is an absolute path after ::set_state(), then the file is external to the * session. */ -AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist) +AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exist, bool optional_origin) : Source (s, node) , AudioSource (s, node) , FileSource (s, node, must_exist) @@ -146,7 +146,7 @@ AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exi if (Glib::path_is_absolute (_origin)) { _path = _origin; - must_exist = true; + must_exist = !optional_origin; } if (init (_path, must_exist)) {