#include <unistd.h>
#include <glibmm/pattern.h>
+#include <glibmm/fileutils.h>
#include "pbd/error.h"
#include "pbd/compose.h"
#include "pbd/file_utils.h"
-#include "pbd/symlink.h"
+#include "ardour/debug.h"
#include "ardour/panner_manager.h"
+
+#ifdef SearchPath
+#undef SearchPath
+#endif
+
#include "ardour/panner_search_path.h"
#include "i18n.h"
void
PannerManager::discover_panners ()
{
- vector<sys::path> panner_modules;
+ vector<std::string> panner_modules;
Glib::PatternSpec so_extension_pattern("*.so");
Glib::PatternSpec dylib_extension_pattern("*.dylib");
+ Glib::PatternSpec dll_extension_pattern("*.dll");
find_matching_files_in_search_path (panner_search_path (),
so_extension_pattern, panner_modules);
find_matching_files_in_search_path (panner_search_path (),
dylib_extension_pattern, panner_modules);
- info << string_compose (_("looking for panners in %1"), panner_search_path().to_string()) << endmsg;
+ find_matching_files_in_search_path (panner_search_path (),
+ dll_extension_pattern, panner_modules);
+
+ DEBUG_TRACE (DEBUG::Panning, string_compose (_("looking for panners in %1"), panner_search_path().to_string()));
- for (vector<sys::path>::iterator i = panner_modules.begin(); i != panner_modules.end(); ++i) {
- panner_discover ((*i).to_string());
+ for (vector<std::string>::iterator i = panner_modules.begin(); i != panner_modules.end(); ++i) {
+ panner_discover (*i);
}
}
int
{
PannerInfo* pinfo;
- /* don't look in symlinks, because otherwise we find too many versions
- * of the same library.
- */
+ if ((pinfo = get_descriptor (path)) != 0) {
- if (PBD::is_symlink (path)) {
- return 0;
- }
+ list<PannerInfo*>::iterator i;
- if ((pinfo = get_descriptor (path)) != 0) {
- panner_info.push_back (pinfo);
- info << string_compose(_("Panner discovered: \"%1\" in %2"), pinfo->descriptor.name, path) << endmsg;
+ for (i = panner_info.begin(); i != panner_info.end(); ++i) {
+ if (pinfo->descriptor.name == (*i)->descriptor.name) {
+ break;
+ }
+ }
+
+ 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));
+ }
}
return 0;
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;