RunTimeLadspaLibraryLoader.hxx

Go to the documentation of this file.
00001 #ifndef RunTimeLadspaLibraryLoader_hxx
00002 #define RunTimeLadspaLibraryLoader_hxx
00003 
00004 #ifdef WIN32
00005 #include <windows.h>
00006 #undef GetClassName
00007 #else
00008 #include <dlfcn.h>
00009 #endif
00010 #include <dirent.h>
00011 //#include "RunTimeLibraryLoader.hxx"
00012 
00013 #include "ProcessingFactory.hxx" 
00014 #include "LadspaWrapperCreator.hxx"
00015 #include <ladspa.h>
00016 
00017 
00018 class RunTimeLadspaLibraryLoader : public RunTimeLibraryLoader
00019 {
00020 
00021 protected:
00022 
00023         virtual const bool needReleaseHandlerOnReload() const { return false;} 
00024         void SetupLibrary(void* handle, const std::string & pluginFullFilename) const
00025         {
00026                 LADSPA_Descriptor_Function descriptorTable = 0;
00027                 descriptorTable = (LADSPA_Descriptor_Function)dlsym(handle, "ladspa_descriptor");
00028                 if (!descriptorTable)
00029                 {
00030                         std::cout << "[LADSPA Plugin] Warning: trying to open non ladspa plugin: " << pluginFullFilename << std::endl;
00031                         return;
00032                 }
00033                 //std::cout << "[LADSPA] \topened plugin: " << pluginFullFilename << std::endl;
00034                 CLAM::ProcessingFactory& factory = CLAM::ProcessingFactory::GetInstance();
00035                 for (unsigned long i=0; descriptorTable(i); i++)
00036                 {
00037                         LADSPA_Descriptor* descriptor = (LADSPA_Descriptor*)descriptorTable(i);
00038                         std::ostringstream oss;
00039                         oss << descriptor->Label << i;
00040                         factory.AddCreatorWarningRepetitions(oss.str(), 
00041                                         new CLAM::LadspaWrapperCreator(pluginFullFilename, 
00042                                                 i, 
00043                                                 oss.str()));
00044                         factory.AddAttribute(oss.str(), "category", "LADSPA");
00045                         factory.AddAttribute(oss.str(), "description", descriptor->Name);
00046                         factory.AddAttribute(oss.str(), "library", pluginFullFilename);
00047                         //std::cout << "[LADSPA] added \"" << plugin.factoryID << "\" to the Factory" << std::endl;
00048                 }
00049                 if (ReleaseLibraryHandler(handle, pluginFullFilename))
00050                 {
00051                         std::cout<<"[LADSPA Plugin] error unloading library handle of: " << pluginFullFilename<<std::endl;
00052                         std::cout<<LibraryLoadError()<<std::endl;
00053                 }
00054         }
00055 
00056         const char ** standardPaths() const
00057         { 
00058                 static const char * result[] = 
00059                 {
00060                         "/usr/local/lib/ladspa",
00061                         "/usr/lib/ladspa",
00062                         0
00063                 };
00064                 return result;
00065         }
00066 
00067         const char * homePath() const { return  "/.ladspa"; }
00068         const char * pathEnvironmentVar() const { return  "LADSPA_PATH"; }
00069         const char * libraryType() const { return  "LADSPA"; }
00070 };
00071 
00072 #endif // RunTimeLadspaLibraryLoader_hxx
00073 
00074 

Generated on Tue Aug 12 22:33:44 2008 for CLAM by  doxygen 1.5.5