summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-09-24 19:03:59 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-09-26 15:19:07 -0400
commit1e6b6df77321958ce50b4db79e446bd2c1ce9f23 (patch)
treedb061c9f6bd4dd5f9ddfe61aab4f46490ff48925
parent0f529ee8b4747d3d5d72db269e5c49b4ffb156c0 (diff)
next (final?) part of handling missing MIDI files.
If an external-to-session file is missing, consider it a fatal error in session loading. If an internal-to-session file is missing, just create a new MIDI source with the same path and ID, and use that instead.
-rw-r--r--libs/ardour/session_state.cc39
1 files changed, 32 insertions, 7 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 6c5734db10..79d8ca1c02 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -1835,7 +1835,10 @@ Session::load_sources (const XMLNode& node)
{
XMLNodeList nlist;
XMLNodeConstIterator niter;
- boost::shared_ptr<Source> source;
+ boost::shared_ptr<Source> source; /* don't need this but it stops some
+ * versions of gcc complaining about
+ * discarded return values.
+ */
nlist = node.children();
@@ -1852,9 +1855,15 @@ Session::load_sources (const XMLNode& node)
int user_choice;
+ if (err.type == DataType::MIDI && Glib::path_is_absolute (err.path)) {
+ error << string_compose (_("A external MIDI file is missing. %1 cannot currently recover from missing external MIDI files"),
+ PROGRAM_NAME) << endmsg;
+ return -1;
+ }
+
if (!no_questions_about_missing_files) {
- user_choice = MissingFile (this, err.path, err.type).get_value_or (-1);
- } else {
+ user_choice = MissingFile (this, err.path, err.type).get_value_or (-1);
+ } else {
user_choice = -2;
}
@@ -1882,14 +1891,30 @@ Session::load_sources (const XMLNode& node)
switch (err.type) {
case DataType::AUDIO:
- warning << _("A sound file is missing. It will be replaced by silence.") << endmsg;
source = SourceFactory::createSilent (*this, **niter, max_framecnt, _current_frame_rate);
break;
case DataType::MIDI:
- warning << string_compose (_("A MIDI file is missing. %1 cannot currently recover from missing MIDI files"),
- PROGRAM_NAME) << endmsg;
- return -1;
+ /* The MIDI file is actually missing so
+ * just create a new one in the same
+ * location. Do not announce its
+ */
+ string fullpath;
+
+ if (!Glib::path_is_absolute (err.path)) {
+ fullpath = Glib::build_filename (source_search_path (DataType::MIDI).front(), err.path);
+ } else {
+ /* this should be an unrecoverable error: we would be creating a MIDI file outside
+ the session tree.
+ */
+ return -1;
+ }
+ /* Note that we do not announce the source just yet - we need to reset its ID before we do that */
+ source = SourceFactory::createWritable (DataType::MIDI, *this, fullpath, false, _current_frame_rate, false, false);
+ /* reset ID to match the missing one */
+ source->set_id (**niter);
+ /* Now we can announce it */
+ SourceFactory::SourceCreated (source);
break;
}
break;