RunTimeFaustLibraryLoader.hxx
Go to the documentation of this file.00001 #ifndef RunTimeFaustLibraryLoader_hxx
00002 #define RunTimeFaustLibraryLoader_hxx
00003
00004 #include <dirent.h>
00005 #include "RunTimeLibraryLoader.hxx"
00006
00007 #include "LadspaWrapperCreator.hxx"
00008 #include <ladspa.h>
00009
00010
00011 class RunTimeFaustLibraryLoader : public RunTimeLibraryLoader
00012 {
00013
00014 public:
00015 virtual void Load() const
00016 {
00017 std::string examplesDir = CompletePathFor("examples/ladspadir");
00018 LoadLibrariesFromPath(examplesDir);
00019 RunTimeLibraryLoader::Load();
00020 }
00021 void LoadPlugin(const std::string & pluginFullPath) const
00022 {
00023 LoadLibrariesFromPath(pluginFullPath);
00024 }
00025
00026
00027 virtual std::list<std::string> GetUsedLibraries()
00028 {
00029 std::list<std::string> loadedLibraries=LoadedLibraries();
00030 LoadedLibraries().clear();
00031 return loadedLibraries;
00032 }
00033 protected:
00034
00035 virtual const bool needReleaseHandlerOnReload() const {return false; }
00036 void SetupLibrary(void* handle, const std::string & pluginFullFilename) const
00037 {
00038 LADSPA_Descriptor_Function descriptorTable = 0;
00039 descriptorTable = (LADSPA_Descriptor_Function)GetSymbol(handle, "ladspa_descriptor");
00040 if (!descriptorTable)
00041 {
00042
00043 return;
00044 }
00045
00046 LoadedLibraries().push_back(pluginFullFilename);
00047 CLAM::ProcessingFactory& factory = CLAM::ProcessingFactory::GetInstance();
00048 for (unsigned long i=0; descriptorTable(i); i++)
00049 {
00050 LADSPA_Descriptor* descriptor = (LADSPA_Descriptor*)descriptorTable(i);
00051 std::ostringstream oss;
00052 oss << descriptor->Label << i;
00053 factory.AddCreatorWarningRepetitions(oss.str(),
00054 new CLAM::LadspaWrapperCreator(pluginFullFilename,
00055 i,
00056 oss.str()));
00057 factory.AddAttribute(oss.str(), "category", "FAUST");
00058 factory.AddAttribute(oss.str(), "description", descriptor->Name);
00059 factory.AddAttribute(oss.str(), "library", pluginFullFilename);
00060
00061 std::string pluginName=descriptor->Label;
00062 const std::string diagramMainSufix=".dsp-svg/process.svg";
00063 std::string svgFileDir = CompletePathFor( "examples/" + pluginName + diagramMainSufix);
00064 if (svgFileDir != "")
00065 {
00066 factory.AddAttribute(oss.str(), "faust_diagram", svgFileDir);
00067 }
00068 if (!factory.AttributeExists(oss.str(), "embedded_svg"))
00069 factory.AddAttribute(oss.str(), "embedded_svg", ":icons/images/faustlogo.svg");
00070 if (!factory.AttributeExists(oss.str(), "icon"))
00071 factory.AddAttribute(oss.str(), "icon", "faustlogo.svg");
00072 std::string sourcePath=CompletePathFor( "examples/"+pluginName+".dsp");
00073 if (sourcePath != "")
00074 factory.AddAttribute(oss.str(), "faust_source_file", sourcePath);
00075 }
00076 if (ReleaseLibraryHandler(handle, pluginFullFilename))
00077 {
00078 std::cout<<"[FAUST-LADSPA] error unloading library handle of: " << pluginFullFilename<<std::endl;
00079 std::cout<<LibraryLoadError()<<std::endl;
00080 }
00081 }
00082
00083 const char ** standardPaths() const
00084 {
00085 static const char * result[] =
00086 {
00087
00088
00089 0
00090 };
00091 return result;
00092 }
00093
00094 const char * homePath() const { return "/.faust"; }
00095 const char * pathEnvironmentVar() const { return "CLAM_FAUST_PATH"; }
00096 const char * libraryType() const { return "LADSPA"; }
00097 private:
00098 static std::list<std::string> & LoadedLibraries()
00099 {
00100 static std::list<std::string> sLoadedLibraries;
00101 return sLoadedLibraries;
00102 }
00103 };
00104
00105 #endif // RunTimeFaustLibraryLoader_hxx
00106
00107