X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Frc_configuration.cc;h=100e73678d5e4ed64935534f24b1c769fe4309e5;hb=77687519b69f39aaa2354f4c9945958fc1c630fe;hp=a17fd9f5a509fcb5f9f3717d0bcb596b5b59823a;hpb=a473d630eb165272992e90f8d854b1d66ec0be63;p=ardour.git diff --git a/libs/ardour/rc_configuration.cc b/libs/ardour/rc_configuration.cc index a17fd9f5a5..100e73678d 100644 --- a/libs/ardour/rc_configuration.cc +++ b/libs/ardour/rc_configuration.cc @@ -21,23 +21,22 @@ #include /* for snprintf, grrr */ #include -#include /* for g_stat() */ +#include "pbd/gstdio_compat.h" #include -#include "pbd/failed_constructor.h" #include "pbd/xml++.h" -#include "pbd/filesystem.h" #include "pbd/file_utils.h" +#include "pbd/replace_all.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" +#include "pbd/i18n.h" using namespace ARDOUR; using namespace std; @@ -51,6 +50,9 @@ namespace ARDOUR { float speed_quietning = 0.251189; // -12dB reduction for ffwd or rewind } +static const char* user_config_file_name = "config"; +static const char* system_config_file_name = "system_config"; + RCConfiguration::RCConfiguration () : /* construct variables */ @@ -65,32 +67,20 @@ RCConfiguration::RCConfiguration () { } - RCConfiguration::~RCConfiguration () { - for (list::iterator i = _midi_port_states.begin(); i != _midi_port_states.end(); ++i) { - delete *i; - } - delete _control_protocol_state; } 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 (ardour_config_search_path(), system_config_file_name, rcfile)) { /* stupid XML Parser hates empty files */ @@ -112,20 +102,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 (ardour_config_search_path(), user_config_file_name, rcfile)) { /* stupid XML parser hates empty files */ @@ -151,29 +134,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(), user_config_file_name); // this test seems bogus? if (!rcfile.empty()) { @@ -205,22 +172,14 @@ XMLNode& RCConfiguration::get_state () { XMLNode* root; - LocaleGuard lg (X_("POSIX")); + LocaleGuard lg; root = new XMLNode("Ardour"); - MIDI::Manager* mm = MIDI::Manager::instance(); - - if (mm) { - const MIDI::Manager::PortList& ports = mm->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); } @@ -234,7 +193,7 @@ XMLNode& RCConfiguration::get_variables () { XMLNode* node; - LocaleGuard lg (X_("POSIX")); + LocaleGuard lg; node = new XMLNode ("Config"); @@ -252,7 +211,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; @@ -262,11 +221,7 @@ RCConfiguration::set_state (const XMLNode& root, int /*version*/) XMLNodeConstIterator niter; XMLNode *node; - for (list::iterator i = _midi_port_states.begin(); i != _midi_port_states.end(); ++i) { - delete *i; - } - - _midi_port_states.clear (); + Stateful::save_extra_xml (root); for (niter = nlist.begin(); niter != nlist.end(); ++niter) { @@ -274,16 +229,15 @@ RCConfiguration::set_state (const XMLNode& root, int /*version*/) 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); - } else if (node->name() == MIDI::Port::state_node_name) { - _midi_port_states.push_back (new XMLNode (*node)); } } - Diskstream::set_disk_io_chunk_frames (minimum_disk_io_bytes.get() / sizeof (Sample)); + Diskstream::set_disk_read_chunk_frames (minimum_disk_read_bytes.get() / sizeof (Sample)); + Diskstream::set_disk_write_chunk_frames (minimum_disk_write_bytes.get() / sizeof (Sample)); return 0; } @@ -318,3 +272,4 @@ RCConfiguration::map_parameters (boost::function& functor) #undef CONFIG_VARIABLE #undef CONFIG_VARIABLE_SPECIAL } +