apply gain automation on bounce - fixes 5887
[ardour.git] / libs / ardour / rc_configuration.cc
index a50a994f8774b059523e1f5af103d975cab13b6b..7fe030fb7e0102e3d39acc2a44586f45f253900f 100644 (file)
 #include <glib/gstdio.h> /* for g_stat() */
 #include <glibmm/miscutils.h>
 
-#include "pbd/failed_constructor.h"
 #include "pbd/xml++.h"
-#include "pbd/filesystem.h"
 #include "pbd/file_utils.h"
 
-#include "midi++/manager.h"
-
-#include "ardour/ardour.h"
-#include "ardour/rc_configuration.h"
-#include "ardour/audio_diskstream.h"
+#include "ardour/audioengine.h"
 #include "ardour/control_protocol_manager.h"
+#include "ardour/diskstream.h"
 #include "ardour/filesystem_paths.h"
+#include "ardour/port.h"
+#include "ardour/rc_configuration.h"
+#include "ardour/session_metadata.h"
 
 #include "i18n.h"
 
@@ -65,7 +63,6 @@ RCConfiguration::RCConfiguration ()
 {
 }
 
-
 RCConfiguration::~RCConfiguration ()
 {
        delete _control_protocol_state;
@@ -74,19 +71,12 @@ RCConfiguration::~RCConfiguration ()
 int
 RCConfiguration::load_state ()
 {
-       bool found = false;
-
-       sys::path system_rc_file;
-       struct stat statbuf;
+       std::string rcfile;
+       GStatBuf statbuf;
 
        /* load system configuration first */
 
-       if (find_file_in_search_path (ardour_search_path() + system_config_search_path(),
-                       "ardour_system.rc", system_rc_file) )
-       {
-               found = true;
-
-               string rcfile = system_rc_file.to_string();
+       if (find_file_in_search_path (ardour_config_search_path(), "ardour_system.rc", rcfile)) {
 
                /* stupid XML Parser hates empty files */
 
@@ -108,20 +98,13 @@ RCConfiguration::load_state ()
                                return -1;
                        }
                } else {
-                       error << string_compose (_("your system %1 configuration file is empty. This probably means that there as an error installing %1"), PROGRAM_NAME) << endmsg;
+                       error << string_compose (_("Your system %1 configuration file is empty. This probably means that there was an error installing %1"), PROGRAM_NAME) << endmsg;
                }
        }
 
        /* now load configuration file for user */
 
-       sys::path user_rc_file;
-
-       if (find_file_in_search_path (ardour_search_path() + user_config_directory(),
-                       "ardour.rc", user_rc_file))
-       {
-               found = true;
-
-               string rcfile = user_rc_file.to_string();
+       if (find_file_in_search_path (ardour_config_search_path(), "ardour.rc", rcfile)) {
 
                /* stupid XML parser hates empty files */
 
@@ -147,29 +130,13 @@ RCConfiguration::load_state ()
                }
        }
 
-       if (!found)
-               error << string_compose (_("%1: could not find configuration file (ardour.rc), canvas will look broken."), PROGRAM_NAME) << endmsg;
-
        return 0;
 }
 
 int
 RCConfiguration::save_state()
 {
-       try
-       {
-               sys::create_directories (user_config_directory ());
-       }
-       catch (const sys::filesystem_error& ex)
-       {
-               error << "Could not create user configuration directory" << endmsg;
-               return -1;
-       }
-
-       sys::path rcfile_path(user_config_directory());
-
-       rcfile_path /= "ardour.rc";
-       const string rcfile = rcfile_path.to_string();
+       const std::string rcfile = Glib::build_filename (user_config_directory(), "ardour.rc");
 
        // this test seems bogus?
        if (!rcfile.empty()) {
@@ -205,14 +172,10 @@ RCConfiguration::get_state ()
 
        root = new XMLNode("Ardour");
 
-       const MIDI::Manager::PortList& ports = MIDI::Manager::instance()->get_midi_ports();
-
-       for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) {
-               root->add_child_nocopy((*i)->get_state());
-       }
-
        root->add_child_nocopy (get_variables ());
 
+       root->add_child_nocopy (SessionMetadata::Metadata()->get_user_state());
+
        if (_extra_xml) {
                root->add_child_copy (*_extra_xml);
        }
@@ -244,7 +207,7 @@ RCConfiguration::get_variables ()
 }
 
 int
-RCConfiguration::set_state (const XMLNode& root, int /*version*/)
+RCConfiguration::set_state (const XMLNode& root, int version)
 {
        if (root.name() != "Ardour") {
                return -1;
@@ -254,17 +217,16 @@ RCConfiguration::set_state (const XMLNode& root, int /*version*/)
        XMLNodeConstIterator niter;
        XMLNode *node;
 
+       Stateful::save_extra_xml (root);
+
        for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
 
                node = *niter;
 
                if (node->name() == "Config") {
-
                        set_variables (*node);
-
-               } else if (node->name() == "Extra") {
-                       _extra_xml = new XMLNode (*node);
-
+               } else if (node->name() == "Metadata") {
+                       SessionMetadata::Metadata()->set_state (*node, version);
                } else if (node->name() == ControlProtocolManager::state_node_name) {
                        _control_protocol_state = new XMLNode (*node);
                }