svcore
1.9
|
00001 // -*- c-basic-offset: 4 indent-tabs-mode: nil -*- 00002 00003 /* 00004 Rosegarden-4 00005 A sequencer and musical notation editor. 00006 00007 This program is Copyright 2000-2006 00008 Guillaume Laurent <glaurent@telegraph-road.org>, 00009 Chris Cannam <cannam@all-day-breakfast.com>, 00010 Richard Bown <bownie@bownie.com> 00011 00012 The moral right of the authors to claim authorship of this work 00013 has been asserted. 00014 00015 This program is free software; you can redistribute it and/or 00016 modify it under the terms of the GNU General Public License as 00017 published by the Free Software Foundation; either version 2 of the 00018 License, or (at your option) any later version. See the file 00019 COPYING included with this distribution for more information. 00020 */ 00021 00022 #include "RealTimePluginFactory.h" 00023 #include "PluginIdentifier.h" 00024 00025 #include "LADSPAPluginFactory.h" 00026 #include "DSSIPluginFactory.h" 00027 00028 #include "system/System.h" 00029 #include "base/Profiler.h" 00030 00031 #include <iostream> 00032 00033 int RealTimePluginFactory::m_sampleRate = 48000; 00034 00035 static LADSPAPluginFactory *_ladspaInstance = 0; 00036 static LADSPAPluginFactory *_dssiInstance = 0; 00037 00038 RealTimePluginFactory::~RealTimePluginFactory() 00039 { 00040 } 00041 00042 RealTimePluginFactory * 00043 RealTimePluginFactory::instance(QString pluginType) 00044 { 00045 if (pluginType == "ladspa") { 00046 if (!_ladspaInstance) { 00047 // SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new LADSPAPluginFactory" << endl; 00048 _ladspaInstance = new LADSPAPluginFactory(); 00049 _ladspaInstance->discoverPlugins(); 00050 } 00051 return _ladspaInstance; 00052 } else if (pluginType == "dssi") { 00053 if (!_dssiInstance) { 00054 // SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new DSSIPluginFactory" << endl; 00055 _dssiInstance = new DSSIPluginFactory(); 00056 _dssiInstance->discoverPlugins(); 00057 } 00058 return _dssiInstance; 00059 } 00060 00061 else return 0; 00062 } 00063 00064 RealTimePluginFactory * 00065 RealTimePluginFactory::instanceFor(QString identifier) 00066 { 00067 QString type, soName, label; 00068 PluginIdentifier::parseIdentifier(identifier, type, soName, label); 00069 return instance(type); 00070 } 00071 00072 std::vector<QString> 00073 RealTimePluginFactory::getAllPluginIdentifiers() 00074 { 00075 Profiler profiler("RealTimePluginFactory::getAllPluginIdentifiers"); 00076 00077 RealTimePluginFactory *factory; 00078 std::vector<QString> rv; 00079 00080 // Query DSSI plugins before LADSPA ones. 00081 // This is to provide for the interesting possibility of plugins 00082 // providing either DSSI or LADSPA versions of themselves, 00083 // returning both versions if the LADSPA identifiers are queried 00084 // first but only the DSSI version if the DSSI identifiers are 00085 // queried first. 00086 00087 factory = instance("dssi"); 00088 if (factory) { 00089 const std::vector<QString> &tmp = factory->getPluginIdentifiers(); 00090 for (size_t i = 0; i < tmp.size(); ++i) { 00091 rv.push_back(tmp[i]); 00092 } 00093 } 00094 00095 factory = instance("ladspa"); 00096 if (factory) { 00097 const std::vector<QString> &tmp = factory->getPluginIdentifiers(); 00098 for (size_t i = 0; i < tmp.size(); ++i) { 00099 rv.push_back(tmp[i]); 00100 } 00101 } 00102 00103 // Plugins can change the locale, revert it to default. 00104 RestoreStartupLocale(); 00105 00106 return rv; 00107 } 00108 00109 void 00110 RealTimePluginFactory::enumerateAllPlugins(std::vector<QString> &list) 00111 { 00112 Profiler profiler("RealTimePluginFactory::enumerateAllPlugins"); 00113 00114 RealTimePluginFactory *factory; 00115 00116 // Query DSSI plugins before LADSPA ones. 00117 // This is to provide for the interesting possibility of plugins 00118 // providing either DSSI or LADSPA versions of themselves, 00119 // returning both versions if the LADSPA identifiers are queried 00120 // first but only the DSSI version if the DSSI identifiers are 00121 // queried first. 00122 00123 factory = instance("dssi"); 00124 if (factory) factory->enumeratePlugins(list); 00125 00126 factory = instance("ladspa"); 00127 if (factory) factory->enumeratePlugins(list); 00128 00129 // Plugins can change the locale, revert it to default. 00130 RestoreStartupLocale(); 00131 } 00132