comparison plugin/RealTimePluginFactory.cpp @ 0:da6937383da8

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