From 043418c1b9459499efdca23e1f16aae9b9b2b945 Mon Sep 17 00:00:00 2001 From: waxfrenzy Date: Mon, 20 Jan 2003 23:11:28 +0000 Subject: [PATCH] Automatic scanning of plugins added --- SpiralSynthModularInfo.C | 104 +++++++++++++++++++++++++++++---------- 1 file changed, 77 insertions(+), 27 deletions(-) diff --git a/SpiralSynthModularInfo.C b/SpiralSynthModularInfo.C index c0a0eb6..6bd72de 100644 --- a/SpiralSynthModularInfo.C +++ b/SpiralSynthModularInfo.C @@ -16,14 +16,19 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include +#include +#include + #include "SpiralSynthModularInfo.h" #include "SpiralSynthPluginLocation.h" #include "FL/fl_draw.h" string SpiralInfo::LOCALE = "EN"; -int SpiralInfo::BUFSIZE = 512; -int SpiralInfo::FRAGSIZE = 256; -int SpiralInfo::FRAGCOUNT = 8; +int SpiralInfo::BUFSIZE = 512; +int SpiralInfo::FRAGSIZE = 256; +int SpiralInfo::FRAGCOUNT = 8; int SpiralInfo::SAMPLERATE = 44100; long SpiralInfo::MAXSAMPLE = 32767; float SpiralInfo::VALUECONV = 1.0f/MAXSAMPLE; @@ -55,43 +60,44 @@ SpiralSynthModularInfo* SpiralSynthModularInfo::Get() { m_SpiralSynthModularInfo = new SpiralSynthModularInfo; } - + return m_SpiralSynthModularInfo; } SpiralSynthModularInfo::SpiralSynthModularInfo() -{ +{ BGIMG="None"; - + // default plugins + path, check these before dist... // this is one of the two plugin lists, th other is in - // the SpiralSound/Plugins/PluginList.txt for the + // the SpiralSound/Plugins/PluginList.txt for the // configure/make/install scripts - + PLUGIN_PATH = PLUGIN_PATH_LOCATION; - PLUGINVEC.push_back("OutputPlugin.so"); - PLUGINVEC.push_back("DiskWriterPlugin.so"); - PLUGINVEC.push_back("ScopePlugin.so"); - PLUGINVEC.push_back("MidiPlugin.so"); - PLUGINVEC.push_back("KeyboardPlugin.so"); - PLUGINVEC.push_back("ControllerPlugin.so"); - PLUGINVEC.push_back("MatrixPlugin.so"); - PLUGINVEC.push_back("SeqSelectorPlugin.so"); - PLUGINVEC.push_back("SequencerPlugin.so"); +#ifdef SSM_EXPLICIT_PLUGIN_LIST + PLUGINVEC.push_back("OutputPlugin.so"); + PLUGINVEC.push_back("DiskWriterPlugin.so"); + PLUGINVEC.push_back("ScopePlugin.so"); + PLUGINVEC.push_back("MidiPlugin.so"); + PLUGINVEC.push_back("KeyboardPlugin.so"); + PLUGINVEC.push_back("ControllerPlugin.so"); + PLUGINVEC.push_back("MatrixPlugin.so"); + PLUGINVEC.push_back("SeqSelectorPlugin.so"); + PLUGINVEC.push_back("SequencerPlugin.so"); PLUGINVEC.push_back("PoshSamplerPlugin.so"); - PLUGINVEC.push_back("WaveTablePlugin.so"); - PLUGINVEC.push_back("OscillatorPlugin.so"); + PLUGINVEC.push_back("WaveTablePlugin.so"); + PLUGINVEC.push_back("OscillatorPlugin.so"); PLUGINVEC.push_back("LFOPlugin.so"); PLUGINVEC.push_back("NoisePlugin.so"); - PLUGINVEC.push_back("EnvelopePlugin.so"); + PLUGINVEC.push_back("EnvelopePlugin.so"); PLUGINVEC.push_back("SampleHoldPlugin.so"); - PLUGINVEC.push_back("NoteSnapPlugin.so"); - PLUGINVEC.push_back("MixerPlugin.so"); - PLUGINVEC.push_back("StereoMixerPlugin.so"); - PLUGINVEC.push_back("AmpPlugin.so"); - PLUGINVEC.push_back("RingModPlugin.so"); - PLUGINVEC.push_back("FilterPlugin.so"); + PLUGINVEC.push_back("NoteSnapPlugin.so"); + PLUGINVEC.push_back("MixerPlugin.so"); + PLUGINVEC.push_back("StereoMixerPlugin.so"); + PLUGINVEC.push_back("AmpPlugin.so"); + PLUGINVEC.push_back("RingModPlugin.so"); + PLUGINVEC.push_back("FilterPlugin.so"); PLUGINVEC.push_back("SVFilterPlugin.so"); PLUGINVEC.push_back("MoogFilterPlugin.so"); PLUGINVEC.push_back("FormantPlugin.so"); @@ -111,13 +117,57 @@ SpiralSynthModularInfo::SpiralSynthModularInfo() PLUGINVEC.push_back("SwitchPlugin.so"); PLUGINVEC.push_back("BeatMatchPlugin.so"); PLUGINVEC.push_back("LogicPlugin.so"); +#else + // Scan plugin path for plugins. + DIR *dp; + struct dirent *ep; + struct stat sb; + void *handle; + string fullpath; + const char *path = PLUGIN_PATH.c_str(); + + dp = opendir(path); + if (!dp) { + cerr << "WARNING: Could not open path " << path << endl; + } else { + while ((ep = readdir(dp))) { + + // Need full path + fullpath = path; + fullpath.append(ep->d_name); + + // Stat file to get type + if (!stat(fullpath.c_str(), &sb)) { + + // We only want regular files + if (S_ISREG(sb.st_mode)) { + + // We're not fussed about resolving symbols yet, since we are just + // checking if it's a DLL. + handle = dlopen(fullpath.c_str(), RTLD_LAZY); + + if (!handle) { + cerr << "WARNING: File " << path << ep->d_name + << " could not be examined" << endl; + cerr << "dlerror() output:" << endl; + cerr << dlerror() << endl; + } else { + + // It's a DLL. Add name to list + PLUGINVEC.push_back(ep->d_name); + } + } + } + } + } +#endif } void SpiralSynthModularInfo::StreamInPrefs(istream &s) { // call base class SpiralInfo::StreamInPrefs(s); - + char temp[256]; s>>temp>>temp; s>>temp>>temp>>GUICOL_Tool;