diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc index 600a03df48..4026aab11c 100644 --- a/gtk2_ardour/ui_config.cc +++ b/gtk2_ardour/ui_config.cc @@ -20,6 +20,8 @@ #include #include /* for snprintf, grrr */ +#include + #include #include #include @@ -125,8 +127,7 @@ UIConfiguration::save_state() XMLTree tree; string rcfile; - rcfile = get_user_ardour_path (); - rcfile += "ardour2_ui.conf"; + rcfile = Glib::build_filename (get_user_ardour_path (), "ardour2_ui.conf"); if (rcfile.length()) { tree.set_root (&get_state()); diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index 2c7b8a3f7e..0e81c75790 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -395,6 +395,7 @@ class IO : public PBD::StatefulDestructible int create_ports (const XMLNode&); int make_connections (const XMLNode&); + Connection *find_possible_connection(const string &desired_name, const string &default_name, const string &connection_type_name); void setup_peak_meters (); void meter (); diff --git a/libs/ardour/audio_library.cc b/libs/ardour/audio_library.cc index 1a05ceb4fd..26046c3c7a 100644 --- a/libs/ardour/audio_library.cc +++ b/libs/ardour/audio_library.cc @@ -22,6 +22,7 @@ #include #include +#include #include @@ -37,11 +38,14 @@ static const char* TAG = "http://ardour.org/ontology/Tag"; AudioLibrary::AudioLibrary () { - src = "file:" + get_user_ardour_path() + "sfdb"; + /* XXX URL - '/' is always the separator */ + + src = "file:" + get_user_ardour_path() + "/sfdb"; // workaround for possible bug in raptor that crashes when saving to a // non-existant file. - touch_file(get_user_ardour_path() + "sfdb"); + + touch_file(Glib::build_filename (get_user_ardour_path(), "sfdb")); lrdf_read_file(src.c_str()); } diff --git a/libs/ardour/configuration.cc b/libs/ardour/configuration.cc index 6493b61fea..819b78fb88 100644 --- a/libs/ardour/configuration.cc +++ b/libs/ardour/configuration.cc @@ -22,6 +22,7 @@ #include #include /* for g_stat() */ +#include #include #include @@ -155,8 +156,7 @@ Configuration::save_state() XMLTree tree; string rcfile; - rcfile = get_user_ardour_path (); - rcfile += "ardour.rc"; + rcfile = Glib::build_filename (get_user_ardour_path (), "ardour.rc"); if (rcfile.length()) { tree.set_root (&get_state()); diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index a5bcedb6c2..6938f86c87 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -493,11 +493,12 @@ find_file (string name, string dir, string subdir = "") path = get_user_ardour_path(); if (subdir.length()) { - path += subdir + "/"; + path = Glib::build_filename (path, subdir); } - path += name; - if (access (path.c_str(), R_OK) == 0) { + path = Glib::build_filename (path, name); + + if (Glib::file_test (path.c_str(), Glib::FILE_TEST_EXISTS)) { return path; } @@ -543,6 +544,8 @@ ARDOUR::find_bindings_files (map& files) vector *found; string full_path; + /* XXX building path, so separators are fixed */ + full_path = get_user_ardour_path (); full_path += ':'; full_path = get_system_data_path (); diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 68a4128116..6c48848712 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -1782,6 +1782,83 @@ IO::ports_became_legal () return ret; } +Connection * +IO::find_possible_connection(const string &desired_name, const string &default_name, const string &connection_type_name) { + + Connection* c = _session.connection_by_name (desired_name); + + if (!c) { + int connection_number, i, n, p, mask; + string possible_name; + bool stereo = false; + + error << string_compose(_("Unknown connection \"%1\" listed for %2 of %3"), desired_name, connection_type_name, _name) + << endmsg; + + // find numeric suffix of desired name + connection_number = 0; + p = 1; + i = desired_name.length(); + while (n = desired_name[--i], isdigit(n) && i) { + connection_number += (n-'0') * p; + p *= 10; + } + if (i && n == '+') { + // see if it's a stereo connection e.g. "in 3+4" + int left_connection_number = 0; + p = 1; + info << "assuming port " << desired_name << " is stereo" << endmsg; + while (n = desired_name[--i], isdigit(n) && i) { + left_connection_number += (n-'0') * p; + p *= 10; + } + if (left_connection_number > 0 && left_connection_number + 1 == connection_number) { + connection_number--; + stereo = true; + } + } + + // make 0-based + connection_number--; + // cerr << "desired_name = " << desired_name << ", connection_number = " << connection_number << endl; + + // find highest set bit + mask = 1; + while ((mask <= connection_number) && (mask <<= 1)) { + } + + // "wrap" connection number into largest possible power of 2 + // that works... + while (mask && !c) { + if (connection_number & mask) { + connection_number &= ~mask; + + stringstream s; + s << default_name << " " << connection_number + 1; + if (stereo) { + s << "+" << connection_number + 2; + } + + possible_name = s.str(); + c = _session.connection_by_name (possible_name); + } + mask >>= 1; + } + if (c) { + info << string_compose (_("Connection %1 was not available - \"%2\" used instead"), desired_name, possible_name) + << endmsg; + } else { + error << string_compose(_("No %1 connections available as a replacement"), connection_type_name) + << endmsg; + } + + } + + return c; + + +} + int IO::create_ports (const XMLNode& node) { @@ -1791,19 +1868,10 @@ IO::create_ports (const XMLNode& node) if ((prop = node.property ("input-connection")) != 0) { - Connection* c = _session.connection_by_name (prop->value()); + Connection* c = find_possible_connection(prop->value(), _("in"), _("input")); if (c == 0) { - error << string_compose(_("Unknown connection \"%1\" listed for input of %2"), prop->value(), _name) << endmsg; - - if ((c = _session.connection_by_name (_("in 1"))) == 0) { - error << _("No input connections available as a replacement") - << endmsg; - return -1; - } else { - info << string_compose (_("Connection %1 was not available - \"in 1\" used instead"), prop->value()) - << endmsg; - } + return -1; } num_inputs = c->nports(); @@ -1814,19 +1882,10 @@ IO::create_ports (const XMLNode& node) } if ((prop = node.property ("output-connection")) != 0) { - Connection* c = _session.connection_by_name (prop->value()); + Connection* c = find_possible_connection(prop->value(), _("out"), _("output")); if (c == 0) { - error << string_compose(_("Unknown connection \"%1\" listed for output of %2"), prop->value(), _name) << endmsg; - - if ((c = _session.connection_by_name (_("out 1"))) == 0) { - error << _("No output connections available as a replacement") - << endmsg; - return -1; - } else { - info << string_compose (_("Connection %1 was not available - \"out 1\" used instead"), prop->value()) - << endmsg; - } + return -1; } num_outputs = c->nports (); @@ -1857,19 +1916,10 @@ IO::make_connections (const XMLNode& node) const XMLProperty* prop; if ((prop = node.property ("input-connection")) != 0) { - Connection* c = _session.connection_by_name (prop->value()); + Connection* c = find_possible_connection (prop->value(), _("in"), _("input")); if (c == 0) { - error << string_compose(_("Unknown connection \"%1\" listed for input of %2"), prop->value(), _name) << endmsg; - - if ((c = _session.connection_by_name (_("in 1"))) == 0) { - error << _("No input connections available as a replacement") - << endmsg; - return -1; - } else { - info << string_compose (_("Connection %1 was not available - \"in 1\" used instead"), prop->value()) - << endmsg; - } + return -1; } use_input_connection (*c, this); @@ -1882,19 +1932,10 @@ IO::make_connections (const XMLNode& node) } if ((prop = node.property ("output-connection")) != 0) { - Connection* c = _session.connection_by_name (prop->value()); + Connection* c = find_possible_connection (prop->value(), _("out"), _("output")); if (c == 0) { - error << string_compose(_("Unknown connection \"%1\" listed for output of %2"), prop->value(), _name) << endmsg; - - if ((c = _session.connection_by_name (_("out 1"))) == 0) { - error << _("No output connections available as a replacement") - << endmsg; - return -1; - } else { - info << string_compose (_("Connection %1 was not available - \"out 1\" used instead"), prop->value()) - << endmsg; - } + return -1; } use_output_connection (*c, this); diff --git a/libs/ardour/osc.cc b/libs/ardour/osc.cc index ea3c2f4d4c..101e4cbd93 100644 --- a/libs/ardour/osc.cc +++ b/libs/ardour/osc.cc @@ -28,6 +28,8 @@ #include #include +#include + #include #include @@ -103,18 +105,17 @@ OSC::start () cerr << "OSC @ " << get_server_url () << endl; - _osc_url_file = get_user_ardour_path () + "/osc_url"; - ofstream urlfile; - urlfile.open(_osc_url_file.c_str(),ios::trunc); - if ( urlfile ) - { - urlfile << get_server_url () << endl; - urlfile.close(); - } - else - { - cerr << "Couldn't write '" << _osc_url_file << "'" < #endif // VST_SUPPORT +#include + #include #include @@ -500,10 +502,7 @@ PluginManager::is_a_favorite_plugin (const PluginInfoPtr& pi) void PluginManager::save_favorites () { - Glib::ustring path = get_user_ardour_path (); - path += '/'; - path += "favorite_plugins"; - + Glib::ustring path = Glib::build_filename (get_user_ardour_path (), "favorite_plugins"); ofstream ofs; ofs.open (path.c_str(), ios_base::openmode (ios::out|ios::trunc)); @@ -537,9 +536,7 @@ PluginManager::save_favorites () void PluginManager::load_favorites () { - Glib::ustring path = get_user_ardour_path (); - path += '/'; - path += "favorite_plugins"; + Glib::ustring path = Glib::build_filename (get_user_ardour_path (),"favorite_plugins"); ifstream ifs (path.c_str()); diff --git a/libs/ardour/recent_sessions.cc b/libs/ardour/recent_sessions.cc index 93cd47cbff..9102a49065 100644 --- a/libs/ardour/recent_sessions.cc +++ b/libs/ardour/recent_sessions.cc @@ -22,7 +22,11 @@ #include #include #include + +#include + #include + #include #include #include @@ -35,8 +39,7 @@ using namespace PBD; int ARDOUR::read_recent_sessions (RecentSessions& rs) { - string path = get_user_ardour_path(); - path += "/recent"; + Glib::ustring path = Glib::build_filename (get_user_ardour_path(), "recent"); ifstream recent (path.c_str()); @@ -78,8 +81,7 @@ ARDOUR::read_recent_sessions (RecentSessions& rs) int ARDOUR::write_recent_sessions (RecentSessions& rs) { - string path = get_user_ardour_path(); - path += "/recent"; + Glib::ustring path = Glib::build_filename (get_user_ardour_path(), "recent"); ofstream recent (path.c_str()); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index a97a613ea4..b11ed56a6e 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1253,6 +1253,12 @@ Session::handle_locations_changed (Locations::LocationList& locations) set_loop = true; } + if (location->is_start()) { + start_location = location; + } + if (location->is_end()) { + end_location = location; + } } if (!set_loop) { diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc index 687e10f789..e7bafc986f 100644 --- a/libs/ardour/session_command.cc +++ b/libs/ardour/session_command.cc @@ -68,7 +68,7 @@ Session::memento_command_factory(XMLNode *n) before = new XMLNode(*n->children().front()); after = new XMLNode(*n->children().back()); child = before; - } + } if (!child) { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 770af1ba11..e419753159 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -2064,44 +2064,31 @@ Session::sound_dir (bool with_path) const string Session::peak_dir () const { - string res = _path; - res += peak_dir_name; - res += '/'; - return res; + return Glib::build_filename (_path, peak_dir_name); } string Session::automation_dir () const { - string res = _path; - res += "automation/"; - return res; + return Glib::build_filename (_path, "automation"); } string Session::analysis_dir () const { - string res = _path; - res += "analysis/"; - return res; + return Glib::build_filename (_path, "analysis"); } string Session::template_dir () { - string path = get_user_ardour_path(); - path += "templates/"; - - return path; + return Glib::build_filename (get_user_ardour_path(), "templates"); } string Session::export_dir () const { - string res = _path; - res += export_dir_name; - res += '/'; - return res; + return Glib::build_filename (_path, export_dir_name); } string @@ -2515,8 +2502,7 @@ Session::get_template_list (list &template_names) int Session::read_favorite_dirs (FavoriteDirs & favs) { - string path = get_user_ardour_path(); - path += "/favorite_dirs"; + Glib::ustring path = Glib::build_filename (get_user_ardour_path(), "favorite_dirs"); ifstream fav (path.c_str()); @@ -2550,8 +2536,7 @@ Session::read_favorite_dirs (FavoriteDirs & favs) int Session::write_favorite_dirs (FavoriteDirs & favs) { - string path = get_user_ardour_path(); - path += "/favorite_dirs"; + Glib::ustring path = Glib::build_filename (get_user_ardour_path(), "favorite_dirs"); ofstream fav (path.c_str()); diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index 2211b028a7..1c774f7c0c 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -155,12 +155,9 @@ VSTPlugin::get_state() /* save it to a file */ - string path; + Glib::ustring path = Glib::build_ustring (get_user_ardour_path (), "vst"); struct stat sbuf; - path = get_user_ardour_path (); - path += "vst"; - if (stat (path.c_str(), &sbuf)) { if (errno == ENOENT) { if (g_mkdir_with_parents (path.c_str(), 0600)) { @@ -183,7 +180,7 @@ VSTPlugin::get_state() return *root; } - path += "something"; + path = Glib::build_filename (path, "something"); /* store information */ diff --git a/libs/pbd/pbd/functor_command.h b/libs/pbd/pbd/functor_command.h index e335f4418e..e6c07cfdbe 100644 --- a/libs/pbd/pbd/functor_command.h +++ b/libs/pbd/pbd/functor_command.h @@ -44,15 +44,11 @@ class FunctorCommand : public Command typedef typename FunctorMap::iterator FunctorMapIterator; public: - FunctorCommand( - std::string functor, - obj_type object, - arg_type b, - arg_type a - ) : functor_name(functor), - object(object), - before(b), - after(a) + FunctorCommand(std::string functor, obj_type& object, arg_type b, arg_type a) + : functor_name(functor) + , object(object) + , before(b) + , after(a) { method = find_functor(functor); @@ -76,6 +72,7 @@ class FunctorCommand : public Command std::stringstream ss; XMLNode *node = new XMLNode("FunctorCommand"); + node->add_property("type_name", typeid(obj_type).name()); node->add_property("functor", functor_name); ss << before; node->add_property("before", ss.str()); diff --git a/libs/vamp-sdk/SConscript b/libs/vamp-sdk/SConscript index abf9d86534..e2d602e157 100644 --- a/libs/vamp-sdk/SConscript +++ b/libs/vamp-sdk/SConscript @@ -20,7 +20,7 @@ vamp-sdk/RealTime.cpp """) Import('env install_prefix libraries') -vampsdk = env.Copy() +vampsdk = env.Clone() vampsdk.Merge ([libraries['fftw3'], libraries['fftw3f']])