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"
13 using namespace ARDOUR;
16 PannerManager* PannerManager::_instance = 0;
18 PannerManager::PannerManager ()
22 PannerManager::~PannerManager ()
24 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
30 PannerManager::instance ()
33 _instance = new PannerManager ();
40 PannerManager::discover_panners ()
42 vector<sys::path> panner_modules;
44 Glib::PatternSpec so_extension_pattern("*.so");
45 Glib::PatternSpec dylib_extension_pattern("*.dylib");
47 find_matching_files_in_search_path (panner_search_path (),
48 so_extension_pattern, panner_modules);
50 find_matching_files_in_search_path (panner_search_path (),
51 dylib_extension_pattern, panner_modules);
53 info << string_compose (_("looking for panners in %1"), panner_search_path().to_string()) << endmsg;
55 for (vector<sys::path>::iterator i = panner_modules.begin(); i != panner_modules.end(); ++i) {
56 panner_discover ((*i).to_string());
60 PannerManager::panner_discover (string path)
64 if ((pinfo = get_descriptor (path)) != 0) {
65 panner_info.push_back (pinfo);
66 info << string_compose(_("Panner discovered: \"%1\""), pinfo->descriptor.name) << endmsg;
73 PannerManager::get_descriptor (string path)
77 PanPluginDescriptor *descriptor = 0;
78 PanPluginDescriptor* (*dfunc)(void);
81 if ((module = dlopen (path.c_str(), RTLD_NOW)) == 0) {
82 error << string_compose(_("PannerManager: cannot load module \"%1\" (%2)"), path, dlerror()) << endmsg;
86 dfunc = (PanPluginDescriptor* (*)(void)) dlsym (module, "panner_descriptor");
88 if ((errstr = dlerror()) != 0) {
89 error << string_compose(_("PannerManager: module \"%1\" has no descriptor function."), path) << endmsg;
90 error << errstr << endmsg;
97 info = new PannerInfo (*descriptor, module);
106 PannerManager::select_panner (ChanCount in, ChanCount out)
108 PanPluginDescriptor* d;
109 int32_t nin = in.n_audio();
110 int32_t nout = out.n_audio();
112 /* look for exact match first */
114 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
115 d = &(*p)->descriptor;
117 if (d->in == nin && d->out == nout) {
122 /* no exact match, look for good fit on inputs and variable on outputs */
124 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
125 d = &(*p)->descriptor;
127 if (d->in == nin && d->out == -1) {
132 /* no exact match, look for good fit on outputs and variable on inputs */
134 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
135 d = &(*p)->descriptor;
137 if (d->in == -1 && d->out == nout) {
142 /* no exact match, look for variable fit on inputs and outputs */
144 for (list<PannerInfo*>::iterator p = panner_info.begin(); p != panner_info.end(); ++p) {
145 d = &(*p)->descriptor;
147 if (d->in == -1 && d->out == -1) {
152 warning << string_compose (_("no panner discovered for in/out = %1/%2"), nin, nout) << endmsg;