diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/SConscript | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/ardour.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/control_protocol_manager.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/control_protocol_search_path.h | 42 | ||||
-rw-r--r-- | libs/ardour/ardour/filesystem_paths.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 3 | ||||
-rw-r--r-- | libs/ardour/control_protocol_manager.cc | 35 | ||||
-rw-r--r-- | libs/ardour/control_protocol_search_path.cc | 52 | ||||
-rw-r--r-- | libs/ardour/filesystem_paths.cc | 8 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 18 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 41 |
11 files changed, 126 insertions, 83 deletions
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript index 1d66b1f6be..e2e84c386c 100644 --- a/libs/ardour/SConscript +++ b/libs/ardour/SConscript @@ -66,6 +66,7 @@ automation.cc automation_event.cc configuration.cc control_protocol_manager.cc +control_protocol_search_path.cc crossfade.cc curve.cc cycle_timer.cc diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index c7bf7edcf8..e76c984ba4 100644 --- a/libs/ardour/ardour/ardour.h +++ b/libs/ardour/ardour/ardour.h @@ -53,7 +53,6 @@ namespace ARDOUR { std::string get_user_ardour_path (); std::string get_system_data_path (); - std::string get_system_module_path (); std::string find_config_file (std::string name); std::string find_data_file (std::string name, std::string subdir = "" ); diff --git a/libs/ardour/ardour/control_protocol_manager.h b/libs/ardour/ardour/control_protocol_manager.h index e8dc0bf22c..c61513e117 100644 --- a/libs/ardour/ardour/control_protocol_manager.h +++ b/libs/ardour/ardour/control_protocol_manager.h @@ -58,7 +58,7 @@ struct ControlProtocolInfo { static ControlProtocolManager& instance() { return *_instance; } void set_session (Session&); - void discover_control_protocols (std::string search_path); + void discover_control_protocols (); void foreach_known_protocol (sigc::slot<void,const ControlProtocolInfo*>); void load_mandatory_protocols (); diff --git a/libs/ardour/ardour/control_protocol_search_path.h b/libs/ardour/ardour/control_protocol_search_path.h new file mode 100644 index 0000000000..f9a8103c0c --- /dev/null +++ b/libs/ardour/ardour/control_protocol_search_path.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2007 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef ARDOUR_CONTROL_PROTOCOL_SEARCH_PATH_INCLUDED +#define ARDOUR_CONTROL_PROTOCOL_SEARCH_PATH_INCLUDED + +#include <pbd/search_path.h> + +namespace ARDOUR { + + using PBD::SearchPath; + + /** + * return a SearchPath containing directories in which to look for + * control surface plugins. + * + * If ARDOUR_SURFACES_PATH is defined then the SearchPath returned + * will contain only those directories specified in it, otherwise it will + * contain the user and system directories which may contain control + * surface plugins. + */ + SearchPath control_protocol_search_path (); + +} // namespace ARDOUR + +#endif diff --git a/libs/ardour/ardour/filesystem_paths.h b/libs/ardour/ardour/filesystem_paths.h index dc0d2576ba..0e17327fa5 100644 --- a/libs/ardour/ardour/filesystem_paths.h +++ b/libs/ardour/ardour/filesystem_paths.h @@ -32,6 +32,12 @@ namespace ARDOUR { */ sys::path user_config_directory (); + /** + * @return the path to the directory that contains the system wide ardour + * modules. + */ + sys::path system_module_directory (); + } // namespace ARDOUR #endif diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f0a175c624..9001196b60 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -261,9 +261,6 @@ class Session : public PBD::StatefulDestructible std::string automation_dir () const; - static string suffixed_search_path (std::string suffix, bool data); - static string control_protocol_path (); - static string change_audio_path_by_name (string oldpath, string oldname, string newname, bool destructive); static string change_midi_path_by_name (string oldpath, string oldname, string newname, bool destructive); diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 00c05b2800..84791ab2c7 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -20,13 +20,14 @@ #include <dlfcn.h> #include <pbd/compose.h> +#include <pbd/file_utils.h> #include <pbd/error.h> -#include <pbd/pathscanner.h> #include <control_protocol/control_protocol.h> #include <ardour/session.h> #include <ardour/control_protocol_manager.h> +#include <ardour/control_protocol_search_path.h> using namespace ARDOUR; using namespace std; @@ -168,15 +169,6 @@ ControlProtocolManager::teardown (ControlProtocolInfo& cpi) return 0; } -static bool protocol_filter (const string& str, void *arg) -{ - /* Not a dotfile, has a prefix before a period, suffix is "so", or "dylib" */ - - return str[0] != '.' - && ((str.length() > 3 && str.find (".so") == (str.length() - 3)) - || (str.length() > 6 && str.find (".dylib") == (str.length() - 6))); -} - void ControlProtocolManager::load_mandatory_protocols () { @@ -193,21 +185,24 @@ ControlProtocolManager::load_mandatory_protocols () } void -ControlProtocolManager::discover_control_protocols (string path) +ControlProtocolManager::discover_control_protocols () { - vector<string *> *found; - PathScanner scanner; + vector<sys::path> cp_modules; - info << string_compose (_("looking for control protocols in %1"), path) << endmsg; + Glib::PatternSpec so_extension_pattern("*.so"); + Glib::PatternSpec dylib_extension_pattern("*.dylib"); - found = scanner (path, protocol_filter, 0, false, true); + find_matching_files_in_search_path (control_protocol_search_path (), + so_extension_pattern, cp_modules); - for (vector<string*>::iterator i = found->begin(); i != found->end(); ++i) { - control_protocol_discover (**i); - delete *i; - } + find_matching_files_in_search_path (control_protocol_search_path (), + dylib_extension_pattern, cp_modules); + + info << string_compose (_("looking for control protocols in %1"), control_protocol_search_path().get_string()) << endmsg; - delete found; + for (vector<sys::path>::iterator i = cp_modules.begin(); i != cp_modules.end(); ++i) { + control_protocol_discover ((*i).to_string()); + } } int diff --git a/libs/ardour/control_protocol_search_path.cc b/libs/ardour/control_protocol_search_path.cc new file mode 100644 index 0000000000..aac83c602a --- /dev/null +++ b/libs/ardour/control_protocol_search_path.cc @@ -0,0 +1,52 @@ +/* + Copyright (C) 2007 Tim Mayberry + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <glibmm/miscutils.h> + +#include <ardour/control_protocol_search_path.h> +#include <ardour/directory_names.h> +#include <ardour/filesystem_paths.h> + +namespace { + const char * const surfaces_env_variable_name = "ARDOUR_SURFACES_PATH"; +} // anonymous + +namespace ARDOUR { + +SearchPath +control_protocol_search_path () +{ + bool surfaces_path_defined = false; + SearchPath spath_env(Glib::getenv(surfaces_env_variable_name, surfaces_path_defined)); + + if (surfaces_path_defined) + { + return spath_env; + } + + SearchPath spath(user_config_directory ()); + + spath += system_module_directory (); + + spath.add_subdirectory_to_paths(surfaces_dir_name); + + return spath; +} + +} // namespace ARDOUR diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc index 55a8a9983f..465d07bddc 100644 --- a/libs/ardour/filesystem_paths.cc +++ b/libs/ardour/filesystem_paths.cc @@ -49,4 +49,12 @@ user_config_directory () return p; } +sys::path +system_module_directory () +{ + sys::path module_directory(MODULE_DIR); + module_directory /= "ardour2"; + return module_directory; +} + } // namespace ARDOUR diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 1a5e2bb5b5..c51d2339ea 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -307,7 +307,7 @@ ARDOUR::init (bool use_vst, bool try_optimization) /* singleton - first object is "it" */ new ControlProtocolManager (); - ControlProtocolManager::instance().discover_control_protocols (Session::control_protocol_path()); + ControlProtocolManager::instance().discover_control_protocols (); XMLNode* node; if ((node = Config->control_protocol_state()) != 0) { @@ -405,22 +405,6 @@ ARDOUR::get_system_data_path () return path; } -string -ARDOUR::get_system_module_path () -{ - string path; - char *envvar; - - if ((envvar = getenv ("ARDOUR_MODULE_PATH")) != 0) { - path = envvar; - } else { - path += MODULE_DIR; - path += "/ardour2/"; - } - - return path; -} - static string find_file (string name, string dir, string subdir = "") { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index b1a9b87536..446743796d 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -56,7 +56,6 @@ #include <pbd/pathscanner.h> #include <pbd/pthread_utils.h> #include <pbd/search_path.h> -#include <pbd/strsplit.h> #include <pbd/stacktrace.h> #include <pbd/copyfile.h> @@ -1839,46 +1838,6 @@ Session::automation_dir () const return res; } -string -Session::suffixed_search_path (string suffix, bool data) -{ - string path; - - path += get_user_ardour_path(); - if (path[path.length()-1] != ':') { - path += ':'; - } - - if (data) { - path += get_system_data_path(); - } else { - path += get_system_module_path(); - } - - vector<string> split_path; - - split (path, split_path, ':'); - path = ""; - - for (vector<string>::iterator i = split_path.begin(); i != split_path.end(); ++i) { - path += *i; - path += suffix; - path += '/'; - - if (distance (i, split_path.end()) != 1) { - path += ':'; - } - } - - return path; -} - -string -Session::control_protocol_path () -{ - return suffixed_search_path (surfaces_dir_name, false); -} - int Session::load_bundles (const XMLNode& node) { |