RealTimePluginFactory.cpp

Go to the documentation of this file.
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 
00030 #include <iostream>
00031 
00032 int RealTimePluginFactory::m_sampleRate = 48000;
00033 
00034 static LADSPAPluginFactory *_ladspaInstance = 0;
00035 static LADSPAPluginFactory *_dssiInstance = 0;
00036 
00037 RealTimePluginFactory::~RealTimePluginFactory()
00038 {
00039 }
00040 
00041 RealTimePluginFactory *
00042 RealTimePluginFactory::instance(QString pluginType)
00043 {
00044     if (pluginType == "ladspa") {
00045         if (!_ladspaInstance) {
00046 //          std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
00047 //                    << "): creating new LADSPAPluginFactory" << std::endl;
00048             _ladspaInstance = new LADSPAPluginFactory();
00049             _ladspaInstance->discoverPlugins();
00050         }
00051         return _ladspaInstance;
00052     } else if (pluginType == "dssi") {
00053         if (!_dssiInstance) {
00054 //          std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
00055 //                    << "): creating new DSSIPluginFactory" << std::endl;
00056             _dssiInstance = new DSSIPluginFactory();
00057             _dssiInstance->discoverPlugins();
00058         }
00059         return _dssiInstance;
00060     }
00061         
00062     else return 0;
00063 }
00064 
00065 RealTimePluginFactory *
00066 RealTimePluginFactory::instanceFor(QString identifier)
00067 {
00068     QString type, soName, label;
00069     PluginIdentifier::parseIdentifier(identifier, type, soName, label);
00070     return instance(type);
00071 }
00072 
00073 std::vector<QString>
00074 RealTimePluginFactory::getAllPluginIdentifiers()
00075 {
00076     RealTimePluginFactory *factory;
00077     std::vector<QString> rv;
00078     
00079     // Query DSSI plugins before LADSPA ones.
00080     // This is to provide for the interesting possibility of plugins
00081     // providing either DSSI or LADSPA versions of themselves,
00082     // returning both versions if the LADSPA identifiers are queried
00083     // first but only the DSSI version if the DSSI identifiers are
00084     // queried first.
00085 
00086     factory = instance("dssi");
00087     if (factory) {
00088         const std::vector<QString> &tmp = factory->getPluginIdentifiers();
00089         for (size_t i = 0; i < tmp.size(); ++i) {
00090             rv.push_back(tmp[i]);
00091         }
00092     }
00093 
00094     factory = instance("ladspa");
00095     if (factory) {
00096         const std::vector<QString> &tmp = factory->getPluginIdentifiers();
00097         for (size_t i = 0; i < tmp.size(); ++i) {
00098             rv.push_back(tmp[i]);
00099         }
00100     }
00101 
00102     // Plugins can change the locale, revert it to default.
00103     RestoreStartupLocale();
00104 
00105     return rv;
00106 }
00107 
00108 void
00109 RealTimePluginFactory::enumerateAllPlugins(std::vector<QString> &list)
00110 {
00111     RealTimePluginFactory *factory;
00112 
00113     // Query DSSI plugins before LADSPA ones.
00114     // This is to provide for the interesting possibility of plugins
00115     // providing either DSSI or LADSPA versions of themselves,
00116     // returning both versions if the LADSPA identifiers are queried
00117     // first but only the DSSI version if the DSSI identifiers are
00118     // queried first.
00119 
00120     factory = instance("dssi");
00121     if (factory) factory->enumeratePlugins(list);
00122 
00123     factory = instance("ladspa");
00124     if (factory) factory->enumeratePlugins(list);
00125     
00126     // Plugins can change the locale, revert it to default.
00127     setlocale(LC_ALL, "C");
00128 }
00129 

Generated on Wed Feb 20 15:45:27 2008 for SonicVisualiser by  doxygen 1.5.1