1 #include <glibmm/pattern.h>
4 #include "pbd/compose.h"
5 #include "pbd/file_utils.h"
7 #include "ardour/panner_manager.h"
8 #include "ardour/panner_search_path.h"
11 using namespace ARDOUR;
14 PannerManager* PannerManager::_instance = 0;
16 PannerManager::PannerManager ()
20 PannerManager::~PannerManager ()
22 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
28 PannerManager::instance ()
31 _instance = new PannerManager ();
38 PannerManager::discover_panners ()
40 vector<sys::path> panner_modules;
42 Glib::PatternSpec so_extension_pattern("*.so");
43 Glib::PatternSpec dylib_extension_pattern("*.dylib");
45 find_matching_files_in_search_path (panner_search_path (),
46 so_extension_pattern, panner_modules);
48 find_matching_files_in_search_path (panner_search_path (),
49 dylib_extension_pattern, panner_modules);
51 info << string_compose (_("looking for panners in %1"), panner_search_path().to_string()) << endmsg;
53 for (vector<sys::path>::iterator i = panner_modules.begin(); i != panner_modules.end(); ++i) {
54 panner_discover ((*i).to_string());
58 PannerManager::panner_discover (string path)
62 if ((pinfo = get_descriptor (path)) != 0) {
63 panner_info.push_back (pinfo);
64 info << string_compose(_("Panner discovered: \"%1\""), pinfo->descriptor.name) << endmsg;
71 PannerManager::get_descriptor (string path)
75 PanPluginDescriptor *descriptor = 0;
76 PanPluginDescriptor* (*dfunc)(void);
79 if ((module = dlopen (path.c_str(), RTLD_NOW)) == 0) {
80 error << string_compose(_("PannerManager: cannot load module \"%1\" (%2)"), path, dlerror()) << endmsg;
84 dfunc = (PanPluginDescriptor* (*)(void)) dlsym (module, "panner_descriptor");
86 if ((errstr = dlerror()) != 0) {
87 error << string_compose(_("PannerManager: module \"%1\" has no descriptor function."), path) << endmsg;
88 error << errstr << endmsg;
95 info = new PannerInfo (*descriptor, module);
104 PannerManager::select_panner (ChanCount in, ChanCount out)
106 PanPluginDescriptor* d;
107 int32_t nin = in.n_audio();
108 int32_t nout = out.n_audio();
110 /* look for exact match first */
112 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
113 d = &(*p)->descriptor;
115 if (d->in == nin && d->out == nout) {
120 /* no exact match, look for good fit on inputs and variable on outputs */
122 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
123 d = &(*p)->descriptor;
125 if (d->in == nin && d->out == -1) {
130 /* no exact match, look for good fit on outputs and variable on inputs */
132 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
133 d = &(*p)->descriptor;
135 if (d->in == -1 && d->out == nout) {
140 /* no exact match, look for variable fit on inputs and outputs */
142 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
143 d = &(*p)->descriptor;
145 if (d->in == -1 && d->out == -1) {
150 warning << string_compose (_("no panner discovered for in/out = %1/%2"), nin, nout) << endmsg;