annotate plugin/RealTimePluginFactory.cpp @ 555:8accc7969c1c

* Some steps to avoid backward seeks in MatrixFile in common use cases
author Chris Cannam
date Mon, 09 Feb 2009 11:38:08 +0000
parents 115f60df1e4d
children d7f3dfe6f9a4
rev   line source
Chris@49 1 // -*- c-basic-offset: 4 indent-tabs-mode: nil -*-
Chris@0 2
Chris@0 3 /*
Chris@0 4 Rosegarden-4
Chris@0 5 A sequencer and musical notation editor.
Chris@0 6
Chris@17 7 This program is Copyright 2000-2006
Chris@0 8 Guillaume Laurent <glaurent@telegraph-road.org>,
Chris@0 9 Chris Cannam <cannam@all-day-breakfast.com>,
Chris@0 10 Richard Bown <bownie@bownie.com>
Chris@0 11
Chris@0 12 The moral right of the authors to claim authorship of this work
Chris@0 13 has been asserted.
Chris@0 14
Chris@0 15 This program is free software; you can redistribute it and/or
Chris@0 16 modify it under the terms of the GNU General Public License as
Chris@0 17 published by the Free Software Foundation; either version 2 of the
Chris@0 18 License, or (at your option) any later version. See the file
Chris@0 19 COPYING included with this distribution for more information.
Chris@0 20 */
Chris@0 21
Chris@0 22 #include "RealTimePluginFactory.h"
Chris@0 23 #include "PluginIdentifier.h"
Chris@0 24
Chris@0 25 #include "LADSPAPluginFactory.h"
Chris@0 26 #include "DSSIPluginFactory.h"
Chris@0 27
Chris@303 28 #include "system/System.h"
Chris@408 29 #include "base/Profiler.h"
Chris@303 30
Chris@0 31 #include <iostream>
Chris@0 32
Chris@0 33 int RealTimePluginFactory::m_sampleRate = 48000;
Chris@0 34
Chris@0 35 static LADSPAPluginFactory *_ladspaInstance = 0;
Chris@0 36 static LADSPAPluginFactory *_dssiInstance = 0;
Chris@0 37
Chris@259 38 RealTimePluginFactory::~RealTimePluginFactory()
Chris@259 39 {
Chris@259 40 }
Chris@259 41
Chris@0 42 RealTimePluginFactory *
Chris@0 43 RealTimePluginFactory::instance(QString pluginType)
Chris@0 44 {
Chris@0 45 if (pluginType == "ladspa") {
Chris@0 46 if (!_ladspaInstance) {
Chris@117 47 // std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
Chris@117 48 // << "): creating new LADSPAPluginFactory" << std::endl;
Chris@0 49 _ladspaInstance = new LADSPAPluginFactory();
Chris@0 50 _ladspaInstance->discoverPlugins();
Chris@0 51 }
Chris@0 52 return _ladspaInstance;
Chris@0 53 } else if (pluginType == "dssi") {
Chris@0 54 if (!_dssiInstance) {
Chris@117 55 // std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
Chris@117 56 // << "): creating new DSSIPluginFactory" << std::endl;
Chris@0 57 _dssiInstance = new DSSIPluginFactory();
Chris@0 58 _dssiInstance->discoverPlugins();
Chris@0 59 }
Chris@0 60 return _dssiInstance;
Chris@0 61 }
Chris@0 62
Chris@0 63 else return 0;
Chris@0 64 }
Chris@0 65
Chris@0 66 RealTimePluginFactory *
Chris@0 67 RealTimePluginFactory::instanceFor(QString identifier)
Chris@0 68 {
Chris@0 69 QString type, soName, label;
Chris@0 70 PluginIdentifier::parseIdentifier(identifier, type, soName, label);
Chris@0 71 return instance(type);
Chris@0 72 }
Chris@0 73
Chris@0 74 std::vector<QString>
Chris@0 75 RealTimePluginFactory::getAllPluginIdentifiers()
Chris@0 76 {
Chris@408 77 Profiler profiler("RealTimePluginFactory::getAllPluginIdentifiers");
Chris@408 78
Chris@0 79 RealTimePluginFactory *factory;
Chris@0 80 std::vector<QString> rv;
Chris@0 81
Chris@0 82 // Query DSSI plugins before LADSPA ones.
Chris@0 83 // This is to provide for the interesting possibility of plugins
Chris@0 84 // providing either DSSI or LADSPA versions of themselves,
Chris@0 85 // returning both versions if the LADSPA identifiers are queried
Chris@0 86 // first but only the DSSI version if the DSSI identifiers are
Chris@0 87 // queried first.
Chris@0 88
Chris@0 89 factory = instance("dssi");
Chris@0 90 if (factory) {
Chris@0 91 const std::vector<QString> &tmp = factory->getPluginIdentifiers();
Chris@0 92 for (size_t i = 0; i < tmp.size(); ++i) {
Chris@0 93 rv.push_back(tmp[i]);
Chris@0 94 }
Chris@0 95 }
Chris@0 96
Chris@0 97 factory = instance("ladspa");
Chris@0 98 if (factory) {
Chris@0 99 const std::vector<QString> &tmp = factory->getPluginIdentifiers();
Chris@0 100 for (size_t i = 0; i < tmp.size(); ++i) {
Chris@0 101 rv.push_back(tmp[i]);
Chris@0 102 }
Chris@0 103 }
Chris@0 104
Chris@0 105 // Plugins can change the locale, revert it to default.
Chris@303 106 RestoreStartupLocale();
Chris@303 107
Chris@0 108 return rv;
Chris@0 109 }
Chris@0 110
Chris@0 111 void
Chris@0 112 RealTimePluginFactory::enumerateAllPlugins(std::vector<QString> &list)
Chris@0 113 {
Chris@408 114 Profiler profiler("RealTimePluginFactory::enumerateAllPlugins");
Chris@408 115
Chris@0 116 RealTimePluginFactory *factory;
Chris@0 117
Chris@0 118 // Query DSSI plugins before LADSPA ones.
Chris@0 119 // This is to provide for the interesting possibility of plugins
Chris@0 120 // providing either DSSI or LADSPA versions of themselves,
Chris@0 121 // returning both versions if the LADSPA identifiers are queried
Chris@0 122 // first but only the DSSI version if the DSSI identifiers are
Chris@0 123 // queried first.
Chris@0 124
Chris@0 125 factory = instance("dssi");
Chris@0 126 if (factory) factory->enumeratePlugins(list);
Chris@0 127
Chris@0 128 factory = instance("ladspa");
Chris@0 129 if (factory) factory->enumeratePlugins(list);
Chris@0 130
Chris@0 131 // Plugins can change the locale, revert it to default.
Chris@0 132 setlocale(LC_ALL, "C");
Chris@0 133 }
Chris@0 134