Mercurial > hg > svcore
comparison plugin/NativeVampPluginFactory.cpp @ 1249:d45a16c232bd piper
Align Sonic Annotator with the new Piper-ified subrepos (bearing in mind we want neither Piper nor the plugin load checker in Sonic Annotator itself)
author | Chris Cannam |
---|---|
date | Fri, 04 Nov 2016 14:16:01 +0000 |
parents | 8f076d02569a |
children | 48e9f538e6e9 |
comparison
equal
deleted
inserted
replaced
1248:58dd6a6fe414 | 1249:d45a16c232bd |
---|---|
68 vector<string> p = Vamp::PluginHostAdapter::getPluginPath(); | 68 vector<string> p = Vamp::PluginHostAdapter::getPluginPath(); |
69 for (size_t i = 0; i < p.size(); ++i) m_pluginPath.push_back(p[i].c_str()); | 69 for (size_t i = 0; i < p.size(); ++i) m_pluginPath.push_back(p[i].c_str()); |
70 return m_pluginPath; | 70 return m_pluginPath; |
71 } | 71 } |
72 | 72 |
73 static | |
74 QList<PluginScan::Candidate> | |
75 getCandidateLibraries() | |
76 { | |
77 #ifdef HAVE_PLUGIN_CHECKER_HELPER | |
78 return PluginScan::getInstance()->getCandidateLibrariesFor | |
79 (PluginScan::VampPlugin); | |
80 #else | |
81 auto path = Vamp::PluginHostAdapter::getPluginPath(); | |
82 QList<PluginScan::Candidate> candidates; | |
83 for (string dirname: path) { | |
84 SVDEBUG << "NativeVampPluginFactory: scanning directory myself: " | |
85 << dirname << endl; | |
86 #if defined(_WIN32) | |
87 #define PLUGIN_GLOB "*.dll" | |
88 #elif defined(__APPLE__) | |
89 #define PLUGIN_GLOB "*.dylib *.so" | |
90 #else | |
91 #define PLUGIN_GLOB "*.so" | |
92 #endif | |
93 QDir dir(dirname.c_str(), PLUGIN_GLOB, | |
94 QDir::Name | QDir::IgnoreCase, | |
95 QDir::Files | QDir::Readable); | |
96 | |
97 for (unsigned int i = 0; i < dir.count(); ++i) { | |
98 QString soname = dir.filePath(dir[i]); | |
99 candidates.push_back({ soname, "" }); | |
100 } | |
101 } | |
102 | |
103 return candidates; | |
104 #endif | |
105 } | |
106 | |
73 vector<QString> | 107 vector<QString> |
74 NativeVampPluginFactory::getPluginIdentifiers(QString &) | 108 NativeVampPluginFactory::getPluginIdentifiers(QString &) |
75 { | 109 { |
76 Profiler profiler("NativeVampPluginFactory::getPluginIdentifiers"); | 110 Profiler profiler("NativeVampPluginFactory::getPluginIdentifiers"); |
77 | 111 |
78 QMutexLocker locker(&m_mutex); | 112 QMutexLocker locker(&m_mutex); |
79 | 113 |
80 if (!m_identifiers.empty()) { | 114 if (!m_identifiers.empty()) { |
81 return m_identifiers; | 115 return m_identifiers; |
82 } | 116 } |
83 | 117 |
84 auto candidates = PluginScan::getInstance()->getCandidateLibrariesFor | 118 auto candidates = getCandidateLibraries(); |
85 (PluginScan::VampPlugin); | 119 |
86 | 120 SVDEBUG << "INFO: Have " << candidates.size() << " candidate Vamp plugin libraries" << endl; |
121 | |
87 for (auto candidate : candidates) { | 122 for (auto candidate : candidates) { |
88 | 123 |
89 QString soname = candidate.libraryPath; | 124 QString soname = candidate.libraryPath; |
90 | 125 |
126 SVDEBUG << "INFO: Considering candidate Vamp plugin library " << soname << endl; | |
127 | |
91 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); | 128 void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); |
92 | 129 |
93 if (!libraryHandle) { | 130 if (!libraryHandle) { |
94 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << endl; | 131 SVDEBUG << "WARNING: NativeVampPluginFactory::getPluginIdentifiers: Failed to load library " << soname << ": " << DLERROR() << endl; |
95 continue; | 132 continue; |