diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/panner.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/panner_manager.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/panner_shell.h | 13 | ||||
-rw-r--r-- | libs/ardour/ardour/route.h | 1 | ||||
-rw-r--r-- | libs/ardour/panner_manager.cc | 86 | ||||
-rw-r--r-- | libs/ardour/panner_search_path.cc | 1 | ||||
-rw-r--r-- | libs/ardour/panner_shell.cc | 50 | ||||
-rw-r--r-- | libs/ardour/route.cc | 53 |
8 files changed, 183 insertions, 27 deletions
diff --git a/libs/ardour/ardour/panner.h b/libs/ardour/ardour/panner.h index cee59923ef..47b102989b 100644 --- a/libs/ardour/ardour/panner.h +++ b/libs/ardour/ardour/panner.h @@ -175,8 +175,11 @@ protected: extern "C" { struct LIBARDOUR_API PanPluginDescriptor { std::string name; + std::string panner_uri; + std::string gui_uri; int32_t in; int32_t out; + uint32_t priority; ARDOUR::Panner* (*factory)(boost::shared_ptr<ARDOUR::Pannable>, boost::shared_ptr<ARDOUR::Speakers>); }; } diff --git a/libs/ardour/ardour/panner_manager.h b/libs/ardour/ardour/panner_manager.h index e47ed36ec3..619beb454f 100644 --- a/libs/ardour/ardour/panner_manager.h +++ b/libs/ardour/ardour/panner_manager.h @@ -49,7 +49,8 @@ public: void discover_panners (); std::list<PannerInfo*> panner_info; - PannerInfo* select_panner (ChanCount in, ChanCount out); + PannerInfo* select_panner (ChanCount in, ChanCount out, std::string const uri = ""); + PannerInfo* get_by_uri (std::string uri); private: PannerManager(); diff --git a/libs/ardour/ardour/panner_shell.h b/libs/ardour/ardour/panner_shell.h index b78573212a..76df20489f 100644 --- a/libs/ardour/ardour/panner_shell.h +++ b/libs/ardour/ardour/panner_shell.h @@ -37,6 +37,7 @@ namespace ARDOUR { class Session; +class Route; class Panner; class BufferSet; class AudioBuffer; @@ -71,11 +72,23 @@ public: bool bypassed () const; void set_bypassed (bool); + std::string current_panner_uri() const { return _current_panner_uri; } + std::string user_selected_panner_uri() const { return _user_selected_panner_uri; } + std::string panner_gui_uri() const { return _panner_gui_uri; } + private: + friend class Route; void distribute_no_automation (BufferSet& src, BufferSet& dest, pframes_t nframes, gain_t gain_coeff); + bool set_user_selected_panner_uri (std::string const uri); + boost::shared_ptr<Panner> _panner; boost::shared_ptr<Pannable> _pannable; bool _bypassed; + + std::string _current_panner_uri; + std::string _user_selected_panner_uri; + std::string _panner_gui_uri; + bool _force_reselect; }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index fb2b18f177..5cd17ee24e 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -256,6 +256,7 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou int remove_processor (boost::shared_ptr<Processor>, ProcessorStreams* err = 0, bool need_process_lock = true); int remove_processors (const ProcessorList&, ProcessorStreams* err = 0); int reorder_processors (const ProcessorList& new_order, ProcessorStreams* err = 0); + void set_custom_panner_uri (std::string const panner_uri); void disable_processors (Placement); void disable_processors (); void disable_plugins (Placement); diff --git a/libs/ardour/panner_manager.cc b/libs/ardour/panner_manager.cc index 94e8d4ff2f..24fa10e225 100644 --- a/libs/ardour/panner_manager.cc +++ b/libs/ardour/panner_manager.cc @@ -24,7 +24,8 @@ #include "pbd/error.h" #include "pbd/compose.h" -#include "pbd/file_utils.h" +#include "pbd/pathscanner.h" +#include "pbd/stl_delete.h" #include "ardour/debug.h" #include "ardour/panner_manager.h" @@ -59,25 +60,30 @@ PannerManager::instance () return *_instance; } +static bool panner_filter (const string& str, void */*arg*/) +{ +#ifdef __APPLE__ + return str[0] != '.' && (str.length() > 6 && str.find (".dylib") == (str.length() - 6)); +#else + return str[0] != '.' && (str.length() > 3 && str.find (".so") == (str.length() - 3)); +#endif +} + void PannerManager::discover_panners () { - vector<std::string> panner_modules; - - Glib::PatternSpec so_extension_pattern("*.so"); - Glib::PatternSpec dylib_extension_pattern("*.dylib"); + PathScanner scanner; + std::vector<std::string *> *panner_modules; + std::string search_path = panner_search_path().to_string(); - find_matching_files_in_search_path (panner_search_path (), - so_extension_pattern, panner_modules); + DEBUG_TRACE (DEBUG::Panning, string_compose (_("looking for panners in %1\n"), search_path)); - find_matching_files_in_search_path (panner_search_path (), - dylib_extension_pattern, panner_modules); + panner_modules = scanner (search_path, panner_filter, 0, false, true, 1, true); - DEBUG_TRACE (DEBUG::Panning, string_compose (_("looking for panners in %1"), panner_search_path().to_string())); - - for (vector<std::string>::iterator i = panner_modules.begin(); i != panner_modules.end(); ++i) { - panner_discover (*i); + for (vector<std::string *>::iterator i = panner_modules->begin(); i != panner_modules->end(); ++i) { + panner_discover (**i); } + vector_delete (panner_modules); } int @@ -97,7 +103,7 @@ PannerManager::panner_discover (string path) if (i == panner_info.end()) { panner_info.push_back (pinfo); - DEBUG_TRACE (DEBUG::Panning, string_compose(_("Panner discovered: \"%1\" in %2"), pinfo->descriptor.name, path)); + DEBUG_TRACE (DEBUG::Panning, string_compose(_("Panner discovered: \"%1\" in %2\n"), pinfo->descriptor.name, path)); } } @@ -138,53 +144,87 @@ PannerManager::get_descriptor (string path) } PannerInfo* -PannerManager::select_panner (ChanCount in, ChanCount out) +PannerManager::select_panner (ChanCount in, ChanCount out, std::string const uri) { + PannerInfo* rv = NULL; PanPluginDescriptor* d; int32_t nin = in.n_audio(); int32_t nout = out.n_audio(); + uint32_t priority = 0; + + /* look for user-preference -- check if channels match */ + for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { + d = &(*p)->descriptor; + if (d->panner_uri != uri) continue; + if (d->in != nin && d->in != -1) continue; + if (d->out != nout && d->out != -1) continue; + return *p; + } /* look for exact match first */ for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { d = &(*p)->descriptor; - if (d->in == nin && d->out == nout) { - return *p; + if (d->in == nin && d->out == nout && d->priority > priority) { + priority = d->priority; + rv = *p; } } + if (rv) { return rv; } /* no exact match, look for good fit on inputs and variable on outputs */ + priority = 0; for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { d = &(*p)->descriptor; - if (d->in == nin && d->out == -1) { - return *p; + if (d->in == nin && d->out == -1 && d->priority > priority) { + priority = d->priority; + rv = *p; } } + if (rv) { return rv; } /* no exact match, look for good fit on outputs and variable on inputs */ + priority = 0; for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { d = &(*p)->descriptor; - if (d->in == -1 && d->out == nout) { - return *p; + if (d->in == -1 && d->out == nout && d->priority > priority) { + priority = d->priority; + rv = *p; } } + if (rv) { return rv; } /* no exact match, look for variable fit on inputs and outputs */ + priority = 0; for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { d = &(*p)->descriptor; - if (d->in == -1 && d->out == -1) { - return *p; + if (d->in == -1 && d->out == -1 && d->priority > priority) { + priority = d->priority; + rv = *p; } } + if (rv) { return rv; } warning << string_compose (_("no panner discovered for in/out = %1/%2"), nin, nout) << endmsg; return 0; } + +PannerInfo* +PannerManager::get_by_uri (std::string uri) +{ + PannerInfo* pi = NULL; + for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { + if ((*p)->descriptor.panner_uri != uri) continue; + pi = (*p); + break; + } + return pi; +} diff --git a/libs/ardour/panner_search_path.cc b/libs/ardour/panner_search_path.cc index 63802ffc4e..49349238e4 100644 --- a/libs/ardour/panner_search_path.cc +++ b/libs/ardour/panner_search_path.cc @@ -37,7 +37,6 @@ panner_search_path () SearchPath spath(user_config_directory ()); spath += ardour_dll_directory (); spath.add_subdirectory_to_paths(panner_dir_name); - spath += SearchPath(Glib::getenv(panner_env_variable_name)); return spath; } diff --git a/libs/ardour/panner_shell.cc b/libs/ardour/panner_shell.cc index 1aeb94eb7e..a25cb49ab5 100644 --- a/libs/ardour/panner_shell.cc +++ b/libs/ardour/panner_shell.cc @@ -63,6 +63,10 @@ PannerShell::PannerShell (string name, Session& s, boost::shared_ptr<Pannable> p : SessionObject (s, name) , _pannable (p) , _bypassed (false) + , _current_panner_uri("") + , _user_selected_panner_uri("") + , _panner_gui_uri("") + , _force_reselect (false) { set_name (name); } @@ -82,7 +86,7 @@ PannerShell::configure_io (ChanCount in, ChanCount out) the config hasn't changed, we're done. */ - if (_panner && (_panner->in().n_audio() == nins) && (_panner->out().n_audio() == nouts)) { + if (!_force_reselect && _panner && (_panner->in().n_audio() == nins) && (_panner->out().n_audio() == nouts)) { return; } @@ -90,17 +94,21 @@ PannerShell::configure_io (ChanCount in, ChanCount out) /* no need for panning with less than 2 outputs or no inputs */ if (_panner) { _panner.reset (); + _current_panner_uri = ""; + _panner_gui_uri = ""; Changed (); /* EMIT SIGNAL */ } return; } - PannerInfo* pi = PannerManager::instance().select_panner (in, out); + PannerInfo* pi = PannerManager::instance().select_panner (in, out, _user_selected_panner_uri); if (!pi) { cerr << "No panner found: check that panners are being discovered correctly during startup.\n"; assert (pi); } + DEBUG_TRACE (DEBUG::Panning, string_compose (_("select panner: %1\n"), pi->descriptor.name.c_str())); + boost::shared_ptr<Speakers> speakers = _session.get_speakers (); if (nouts != speakers->size()) { @@ -116,6 +124,8 @@ PannerShell::configure_io (ChanCount in, ChanCount out) // boost_debug_shared_ptr_mark_interesting (p, "Panner"); _panner.reset (p); _panner->configure_io (in, out); + _current_panner_uri = pi->descriptor.panner_uri; + _panner_gui_uri = pi->descriptor.gui_uri; Changed (); /* EMIT SIGNAL */ } @@ -126,6 +136,7 @@ PannerShell::get_state () XMLNode* node = new XMLNode ("PannerShell"); node->add_property (X_("bypassed"), _bypassed ? X_("yes") : X_("no")); + node->add_property (X_("user-panner"), _user_selected_panner_uri); if (_panner) { node->add_child_nocopy (_panner->get_state ()); @@ -146,12 +157,29 @@ PannerShell::set_state (const XMLNode& node, int version) set_bypassed (string_is_affirmative (prop->value ())); } + if ((prop = node.property (X_("user-panner"))) != 0) { + _user_selected_panner_uri = prop->value (); + } + _panner.reset (); for (niter = nlist.begin(); niter != nlist.end(); ++niter) { if ((*niter)->name() == X_("Panner")) { + if ((prop = (*niter)->property (X_("uri")))) { + PannerInfo* p = PannerManager::instance().get_by_uri(prop->value()); + if (p) { + _panner.reset (p->descriptor.factory (_pannable, _session.get_speakers ())); + _current_panner_uri = p->descriptor.panner_uri; + _panner_gui_uri = p->descriptor.gui_uri; + if (_panner->set_state (**niter, version) == 0) { + return -1; + } + } + } + + else /* backwards compatibility */ if ((prop = (*niter)->property (X_("type")))) { list<PannerInfo*>::iterator p; @@ -166,6 +194,8 @@ PannerShell::set_state (const XMLNode& node, int version) */ _panner.reset ((*p)->descriptor.factory (_pannable, _session.get_speakers ())); + _current_panner_uri = (*p)->descriptor.panner_uri; + _panner_gui_uri = (*p)->descriptor.gui_uri; if (_panner->set_state (**niter, version) == 0) { return -1; @@ -347,3 +377,19 @@ PannerShell::bypassed () const { return _bypassed; } + +/* set custom-panner config + * + * This function is intended to be only called from + * Route::set_custom_panner() + * which will trigger IO-reconfigutaion if this fn return true + */ +bool +PannerShell::set_user_selected_panner_uri (std::string const uri) +{ + if (uri == _user_selected_panner_uri) return false; + _user_selected_panner_uri = uri; + if (uri == _current_panner_uri) return false; + _force_reselect = true; + return true; +} diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index c032b77eff..6f23e920d4 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -51,6 +51,7 @@ #include "ardour/midi_port.h" #include "ardour/monitor_processor.h" #include "ardour/pannable.h" +#include "ardour/panner.h" #include "ardour/panner_shell.h" #include "ardour/plugin_insert.h" #include "ardour/port.h" @@ -1574,6 +1575,58 @@ Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* } void +Route::set_custom_panner_uri (std::string const panner_uri) +{ + if (_in_configure_processors) { + DEBUG_TRACE (DEBUG::Panning, string_compose (_("Route::set_custom_panner_uri '%1' -- called while in_configure_processors\n"), name())); + return; + } + + if (!_main_outs->panner_shell()->set_user_selected_panner_uri(panner_uri)) { + DEBUG_TRACE (DEBUG::Panning, string_compose (_("Route::set_custom_panner_uri '%1 '%2' -- no change needed\n"), name(), panner_uri)); + /* no change needed */ + return; + } + + DEBUG_TRACE (DEBUG::Panning, string_compose (_("Route::set_custom_panner_uri '%1 '%2' -- reconfigure I/O\n"), name(), panner_uri)); + + /* reconfigure I/O -- re-initialize panner modules */ + { + Glib::Threads::RWLock::WriterLock lm (_processor_lock); + Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); + + for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) { + boost::shared_ptr<Delivery> dl; + boost::shared_ptr<Panner> panner; + if ((dl = boost::dynamic_pointer_cast<Delivery> (*p)) == 0) { + continue; + } + if (!dl->panner_shell()) { + continue; + } + if (!(panner = dl->panner_shell()->panner())) { + continue; + } + /* _main_outs has already been set before the loop. + * Ignore the return status here. It need reconfiguration */ + if (dl->panner_shell() != _main_outs->panner_shell()) { + if (!dl->panner_shell()->set_user_selected_panner_uri(panner_uri)) { + continue; + } + } + + ChanCount in = panner->in(); + ChanCount out = panner->out(); + dl->panner_shell()->configure_io(in, out); + dl->panner_shell()->pannable()->set_panner(dl->panner_shell()->panner()); + } + } + + processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */ + _session.set_dirty (); +} + +void Route::reset_instrument_info () { boost::shared_ptr<Processor> instr = the_instrument(); |