X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fpanner_manager.cc;h=b14c7c79cf532efcf4a969e9495c327f4ef0ac47;hb=7953df93bfec2df8bb0a8568a9dacbd00235aac4;hp=b62f36b3554cb2c5d5697c4dedf173b6fa97fd0b;hpb=21ca6a10a96c135e7435f1cc786f4395020ca232;p=ardour.git diff --git a/libs/ardour/panner_manager.cc b/libs/ardour/panner_manager.cc index b62f36b355..b14c7c79cf 100644 --- a/libs/ardour/panner_manager.cc +++ b/libs/ardour/panner_manager.cc @@ -29,7 +29,8 @@ #include "ardour/debug.h" #include "ardour/panner_manager.h" -#include "ardour/panner_search_path.h" + +#include "ardour/search_paths.h" #include "i18n.h" @@ -62,10 +63,27 @@ PannerManager::instance () static bool panner_filter (const string& str, void */*arg*/) { -#ifdef __APPLE__ +#ifdef COMPILER_MSVC + /** + * Different build targets (Debug / Release etc) use different versions + * of the 'C' runtime (which can't be 'mixed & matched'). Therefore, in + * case the supplied search path contains multiple version(s) of a given + * panner module, only select the one(s) which match the current build + * target (otherwise, all hell will break loose !!) + */ + #if defined (_DEBUG) + return str.length() > 12 && (str.find ("panner_") == 0) && (str.find ("D.dll") == (str.length() - 5)); + #elif defined (RDC_BUILD) + return str.length() > 14 && (str.find ("panner_") == 0) && (str.find ("RDC.dll") == (str.length() - 7)); + #elif defined (_WIN64) + return str.length() > 13 && (str.find ("panner_") == 0) && (str.find ("64.dll") == (str.length() - 6)); + #else + return str.length() > 13 && (str.find ("panner_") == 0) && (str.find ("32.dll") == (str.length() - 6)); + #endif +#elif defined (__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)); + return str[0] != '.' && (str.length() > 3 && (str.find (".so") == (str.length() - 3) || str.find (".dll") == (str.length() - 4))); #endif } @@ -83,6 +101,7 @@ PannerManager::discover_panners () for (vector::iterator i = panner_modules->begin(); i != panner_modules->end(); ++i) { panner_discover (**i); } + vector_delete (panner_modules); } @@ -113,31 +132,33 @@ PannerManager::panner_discover (string path) PannerInfo* PannerManager::get_descriptor (string path) { - void *module; + Glib::Module* module = new Glib::Module(path); PannerInfo* info = 0; PanPluginDescriptor *descriptor = 0; PanPluginDescriptor* (*dfunc)(void); - const char *errstr; + void* func = 0; - if ((module = dlopen (path.c_str(), RTLD_NOW)) == 0) { - error << string_compose(_("PannerManager: cannot load module \"%1\" (%2)"), path, dlerror()) << endmsg; + if (!module) { + error << string_compose(_("PannerManager: cannot load module \"%1\" (%2)"), path, + Glib::Module::get_last_error()) << endmsg; + delete module; return 0; } - dfunc = (PanPluginDescriptor* (*)(void)) dlsym (module, "panner_descriptor"); - - if ((errstr = dlerror()) != 0) { + if (!module->get_symbol("panner_descriptor", func)) { error << string_compose(_("PannerManager: module \"%1\" has no descriptor function."), path) << endmsg; - error << errstr << endmsg; - dlclose (module); + error << Glib::Module::get_last_error() << endmsg; + delete module; return 0; } + dfunc = (PanPluginDescriptor* (*)(void))func; descriptor = dfunc(); + if (descriptor) { info = new PannerInfo (*descriptor, module); } else { - dlclose (module); + delete module; } return info; @@ -146,9 +167,11 @@ PannerManager::get_descriptor (string path) PannerInfo* 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::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { @@ -164,40 +187,51 @@ PannerManager::select_panner (ChanCount in, ChanCount out, std::string const uri for (list::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::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::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::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; @@ -205,13 +239,35 @@ PannerManager::select_panner (ChanCount in, ChanCount out, std::string const uri } PannerInfo* -PannerManager::get_by_uri (std::string uri) +PannerManager::get_by_uri (std::string uri) const { PannerInfo* pi = NULL; - for (list::iterator p = panner_info.begin(); p != panner_info.end(); ++p) { + for (list::const_iterator p = panner_info.begin(); p != panner_info.end(); ++p) { if ((*p)->descriptor.panner_uri != uri) continue; pi = (*p); break; } return pi; } + +PannerUriMap +PannerManager::get_available_panners(uint32_t const a_in, uint32_t const a_out) const +{ + int const in = a_in; + int const out = a_out; + PannerUriMap panner_list; + + if (out < 2 || in == 0) { + return panner_list; + } + + /* get available panners for current configuration. */ + for (list::const_iterator p = panner_info.begin(); p != panner_info.end(); ++p) { + PanPluginDescriptor* d = &(*p)->descriptor; + if (d->in != -1 && d->in != in) continue; + if (d->out != -1 && d->out != out) continue; + if (d->in == -1 && d->out == -1 && out <= 2) continue; + panner_list.insert(std::pair(d->panner_uri,d->name)); + } + return panner_list; +}