MCPcopy Create free account
hub / github.com/audacity/audacity / DiscoverPluginsAtPath

Method DiscoverPluginsAtPath

libraries/lib-ladspa/LadspaEffectsModule.cpp:210–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210unsigned LadspaEffectsModule::DiscoverPluginsAtPath(
211 const PluginPath & path, TranslatableString &errMsg,
212 const RegistrationCallback &callback)
213{
214 errMsg = {};
215 // Since we now have builtin VST support, ignore the VST bridge as it
216 // causes duplicate menu entries to appear.
217 wxFileName ff(path);
218 if (ff.GetName().CmpNoCase(wxT("vst-bridge")) == 0) {
219 errMsg = XO("Audacity no longer uses vst-bridge");
220 return 0;
221 }
222
223 // As a courtesy to some plug-ins that might be bridges to
224 // open other plug-ins, we set the current working
225 // directory to be the plug-in's directory.
226 wxString envpath;
227 bool hadpath = wxGetEnv(wxT("PATH"), &envpath);
228 wxSetEnv(wxT("PATH"), ff.GetPath() + wxFILE_SEP_PATH + envpath);
229 wxString saveOldCWD = ff.GetCwd();
230 ff.SetCwd();
231
232 int index = 0;
233 int nLoaded = 0;
234 LADSPA_Descriptor_Function mainFn = NULL;
235
236#if defined(__WXMSW__)
237 wxDynamicLibrary lib;
238 if (lib.Load(path, wxDL_NOW))
239#else
240 void *lib = dlopen((const char *)path.ToUTF8(), RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
241 if (lib)
242#endif
243 {
244
245#if defined(__WXMSW__)
246 wxLogNull logNo;
247
248 mainFn = (LADSPA_Descriptor_Function) lib.GetSymbol(wxT("ladspa_descriptor"));
249#else
250 mainFn = (LADSPA_Descriptor_Function) dlsym(lib, "ladspa_descriptor");
251#endif
252
253 if (mainFn) {
254 const LADSPA_Descriptor *data;
255
256 for (data = mainFn(index); data; data = mainFn(++index)) {
257 LadspaEffectBase effect(path, index);
258 if (effect.InitializePlugin()) {
259 ++nLoaded;
260 if (callback)
261 callback( this, &effect );
262 }
263 else
264 errMsg = XO("Could not load the library");
265 }
266 }
267 }

Callers

nothing calls this directly

Calls 7

callbackFunction · 0.85
GetNameMethod · 0.45
GetPathMethod · 0.45
LoadMethod · 0.45
GetSymbolMethod · 0.45
InitializePluginMethod · 0.45
UnloadMethod · 0.45

Tested by

no test coverage detected