CLAM-Development  1.4.0
RunTimeLadspaLibraryLoader.hxx
Go to the documentation of this file.
1 #ifndef RunTimeLadspaLibraryLoader_hxx
2 #define RunTimeLadspaLibraryLoader_hxx
3 
4 #include <dirent.h>
5 //#include "RunTimeLibraryLoader.hxx"
6 
7 #include "ProcessingFactory.hxx"
9 #include <ladspa.h>
10 
11 
13 {
14 
15 protected:
16 
17  virtual const bool needReleaseHandlerOnReload() const { return false;}
18  void SetupLibrary(void* handle, const std::string & pluginFullFilename) const
19  {
20  LADSPA_Descriptor_Function descriptorTable = 0;
21  descriptorTable = (LADSPA_Descriptor_Function)GetSymbol(handle, "ladspa_descriptor");
22  if (!descriptorTable)
23  {
24  std::cout << "[LADSPA Plugin] Warning: trying to open non ladspa plugin: " << pluginFullFilename << std::endl;
25  return;
26  }
27  //std::cout << "[LADSPA] \topened plugin: " << pluginFullFilename << std::endl;
29  for (unsigned long i=0; descriptorTable(i); i++)
30  {
31  LADSPA_Descriptor* descriptor = (LADSPA_Descriptor*)descriptorTable(i);
32  const char* id = descriptor->Label;
34  new CLAM::LadspaWrapperCreator(pluginFullFilename,
35  i,
36  id));
37  factory.AddAttribute(id, "category", "LADSPA");
38  factory.AddAttribute(id, "description", descriptor->Name);
39  factory.AddAttribute(id, "library", pluginFullFilename);
40 
41  std::ostringstream oss;
42  oss << descriptor->Label << "_buffer" << i;
43  std::string id2=oss.str();
44  factory.AddCreatorWarningRepetitions(id2,
45  new CLAM::LadspaWrapperBufferCreator(pluginFullFilename,
46  i,
47  id2));
48  factory.AddAttribute(id2, "category", "LADSPA_BUFFER");
49  factory.AddAttribute(id2, "description", descriptor->Name);
50  factory.AddAttribute(id2, "library", pluginFullFilename);
51  //std::cout << "[LADSPA] added \"" << plugin.factoryID << "\" to the Factory" << std::endl;
52  }
53  if (ReleaseLibraryHandler(handle, pluginFullFilename))
54  {
55  std::cout<<"[LADSPA Plugin] error unloading library handle of: " << pluginFullFilename<<std::endl;
56  std::cout<<LibraryLoadError()<<std::endl;
57  }
58  }
59 
60  const char ** standardPaths() const
61  {
62  static const char * result[] =
63  {
64  "/usr/local/lib/ladspa",
65  "/usr/lib/ladspa",
66  0
67  };
68  return result;
69  }
70 
71  const char * homePath() const { return "/.ladspa"; }
72  const char * pathEnvironmentVar() const { return "LADSPA_PATH"; }
73  const char * libraryType() const { return "LADSPA"; }
74 };
75 
76 #endif // RunTimeLadspaLibraryLoader_hxx
77 
78