annotate plugin/RealTimePluginFactory.cpp @ 1131:db946591a391 tony-2.0-integration

Fix lock contention in FFTapi
author Chris Cannam
date Mon, 12 Oct 2015 15:06:15 +0100
parents a1cd5abcb38b
children 48e9f538e6e9
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@1040 33 sv_samplerate_t 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@690 47 // SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new LADSPAPluginFactory" << endl;
Chris@0 48 _ladspaInstance = new LADSPAPluginFactory();
Chris@0 49 _ladspaInstance->discoverPlugins();
Chris@0 50 }
Chris@0 51 return _ladspaInstance;
Chris@0 52 } else if (pluginType == "dssi") {
Chris@0 53 if (!_dssiInstance) {
Chris@690 54 // SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new DSSIPluginFactory" << endl;
Chris@0 55 _dssiInstance = new DSSIPluginFactory();
Chris@0 56 _dssiInstance->discoverPlugins();
Chris@0 57 }
Chris@0 58 return _dssiInstance;
Chris@0 59 }
Chris@0 60
Chris@0 61 else return 0;
Chris@0 62 }
Chris@0 63
Chris@0 64 RealTimePluginFactory *
Chris@0 65 RealTimePluginFactory::instanceFor(QString identifier)
Chris@0 66 {
Chris@0 67 QString type, soName, label;
Chris@0 68 PluginIdentifier::parseIdentifier(identifier, type, soName, label);
Chris@0 69 return instance(type);
Chris@0 70 }
Chris@0 71
Chris@0 72 std::vector<QString>
Chris@0 73 RealTimePluginFactory::getAllPluginIdentifiers()
Chris@0 74 {
Chris@408 75 Profiler profiler("RealTimePluginFactory::getAllPluginIdentifiers");
Chris@408 76
Chris@0 77 RealTimePluginFactory *factory;
Chris@0 78 std::vector<QString> rv;
Chris@0 79
Chris@0 80 // Query DSSI plugins before LADSPA ones.
Chris@0 81 // This is to provide for the interesting possibility of plugins
Chris@0 82 // providing either DSSI or LADSPA versions of themselves,
Chris@0 83 // returning both versions if the LADSPA identifiers are queried
Chris@0 84 // first but only the DSSI version if the DSSI identifiers are
Chris@0 85 // queried first.
Chris@0 86
Chris@0 87 factory = instance("dssi");
Chris@0 88 if (factory) {
Chris@0 89 const std::vector<QString> &tmp = factory->getPluginIdentifiers();
Chris@0 90 for (size_t i = 0; i < tmp.size(); ++i) {
Chris@0 91 rv.push_back(tmp[i]);
Chris@0 92 }
Chris@0 93 }
Chris@0 94
Chris@0 95 factory = instance("ladspa");
Chris@0 96 if (factory) {
Chris@0 97 const std::vector<QString> &tmp = factory->getPluginIdentifiers();
Chris@0 98 for (size_t i = 0; i < tmp.size(); ++i) {
Chris@0 99 rv.push_back(tmp[i]);
Chris@0 100 }
Chris@0 101 }
Chris@0 102
Chris@0 103 // Plugins can change the locale, revert it to default.
Chris@303 104 RestoreStartupLocale();
Chris@303 105
Chris@0 106 return rv;
Chris@0 107 }
Chris@0 108
Chris@0 109 void
Chris@0 110 RealTimePluginFactory::enumerateAllPlugins(std::vector<QString> &list)
Chris@0 111 {
Chris@408 112 Profiler profiler("RealTimePluginFactory::enumerateAllPlugins");
Chris@408 113
Chris@0 114 RealTimePluginFactory *factory;
Chris@0 115
Chris@0 116 // Query DSSI plugins before LADSPA ones.
Chris@0 117 // This is to provide for the interesting possibility of plugins
Chris@0 118 // providing either DSSI or LADSPA versions of themselves,
Chris@0 119 // returning both versions if the LADSPA identifiers are queried
Chris@0 120 // first but only the DSSI version if the DSSI identifiers are
Chris@0 121 // queried first.
Chris@0 122
Chris@0 123 factory = instance("dssi");
Chris@0 124 if (factory) factory->enumeratePlugins(list);
Chris@0 125
Chris@0 126 factory = instance("ladspa");
Chris@0 127 if (factory) factory->enumeratePlugins(list);
Chris@0 128
Chris@0 129 // Plugins can change the locale, revert it to default.
Chris@608 130 RestoreStartupLocale();
Chris@0 131 }
Chris@0 132