summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-11-20 03:11:39 +0100
committerRobin Gareus <robin@gareus.org>2015-11-20 03:22:41 +0100
commit4c04e8028aa73177f4ab02e3c82ea051e20b4edb (patch)
tree9687dcb70eac2630a962792b44c5c6bd00e816cd
parentc4084932fab7ceb32a7a62ec5206fff18173dc1f (diff)
add API to read snapshot name from instant.xml
-rw-r--r--libs/ardour/ardour/session.h1
-rw-r--r--libs/ardour/session_state.cc23
2 files changed, 24 insertions, 0 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 8a8e8e72e3..60fa9e5761 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -173,6 +173,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
virtual ~Session ();
static int get_info_from_path (const std::string& xmlpath, float& sample_rate, SampleFormat& data_format);
+ static std::string get_snapshot_from_instant (const std::string& session_dir);
std::string path() const { return _path; }
std::string name() const { return _name; }
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 9e8f8dcf2d..48bacdfe07 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -4216,6 +4216,29 @@ Session::get_info_from_path (const string& xmlpath, float& sample_rate, SampleFo
return !(found_sr && found_data_format); // zero if they are both found
}
+std::string
+Session::get_snapshot_from_instant (const std::string& session_dir)
+{
+ std::string instant_xml_path = Glib::build_filename (session_dir, "instant.xml");
+
+ if (!Glib::file_test (instant_xml_path, Glib::FILE_TEST_EXISTS)) {
+ return "";
+ }
+
+ XMLTree tree;
+ if (!tree.read (instant_xml_path)) {
+ return "";
+ }
+
+ const XMLProperty* prop;
+ XMLNode *last_used_snapshot = tree.root()->child("LastUsedSnapshot");
+ if (last_used_snapshot && (prop = last_used_snapshot->property ("name")) != 0) {
+ return prop->value();
+ }
+
+ return "";
+}
+
typedef std::vector<boost::shared_ptr<FileSource> > SeveralFileSources;
typedef std::map<std::string,SeveralFileSources> SourcePathMap;