annotate plugin/RealTimePluginFactory.cpp @ 101:ce1d385f4f89

* Use kill(pid, 0) instead of /proc or sysctl blather for looking up pids * Add OpenProcess call for Win32
author Chris Cannam
date Fri, 05 May 2006 12:34:51 +0000
parents 39ae3dee27b9
children c30728d5625c
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@0 28 #include <iostream>
Chris@0 29
Chris@0 30 int RealTimePluginFactory::m_sampleRate = 48000;
Chris@0 31
Chris@0 32 static LADSPAPluginFactory *_ladspaInstance = 0;
Chris@0 33 static LADSPAPluginFactory *_dssiInstance = 0;
Chris@0 34
Chris@0 35 RealTimePluginFactory *
Chris@0 36 RealTimePluginFactory::instance(QString pluginType)
Chris@0 37 {
Chris@0 38 if (pluginType == "ladspa") {
Chris@0 39 if (!_ladspaInstance) {
Chris@0 40 std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
Chris@0 41 << "): creating new LADSPAPluginFactory" << std::endl;
Chris@0 42 _ladspaInstance = new LADSPAPluginFactory();
Chris@0 43 _ladspaInstance->discoverPlugins();
Chris@0 44 }
Chris@0 45 return _ladspaInstance;
Chris@0 46 } else if (pluginType == "dssi") {
Chris@0 47 if (!_dssiInstance) {
Chris@0 48 std::cerr << "RealTimePluginFactory::instance(" << pluginType.toStdString()
Chris@0 49 << "): creating new DSSIPluginFactory" << std::endl;
Chris@0 50 _dssiInstance = new DSSIPluginFactory();
Chris@0 51 _dssiInstance->discoverPlugins();
Chris@0 52 }
Chris@0 53 return _dssiInstance;
Chris@0 54 }
Chris@0 55
Chris@0 56 else return 0;
Chris@0 57 }
Chris@0 58
Chris@0 59 RealTimePluginFactory *
Chris@0 60 RealTimePluginFactory::instanceFor(QString identifier)
Chris@0 61 {
Chris@0 62 QString type, soName, label;
Chris@0 63 PluginIdentifier::parseIdentifier(identifier, type, soName, label);
Chris@0 64 return instance(type);
Chris@0 65 }
Chris@0 66
Chris@0 67 std::vector<QString>
Chris@0 68 RealTimePluginFactory::getAllPluginIdentifiers()
Chris@0 69 {
Chris@0 70 RealTimePluginFactory *factory;
Chris@0 71 std::vector<QString> rv;
Chris@0 72
Chris@0 73 // Query DSSI plugins before LADSPA ones.
Chris@0 74 // This is to provide for the interesting possibility of plugins
Chris@0 75 // providing either DSSI or LADSPA versions of themselves,
Chris@0 76 // returning both versions if the LADSPA identifiers are queried
Chris@0 77 // first but only the DSSI version if the DSSI identifiers are
Chris@0 78 // queried first.
Chris@0 79
Chris@0 80 factory = instance("dssi");
Chris@0 81 if (factory) {
Chris@0 82 const std::vector<QString> &tmp = factory->getPluginIdentifiers();
Chris@0 83 for (size_t i = 0; i < tmp.size(); ++i) {
Chris@0 84 rv.push_back(tmp[i]);
Chris@0 85 }
Chris@0 86 }
Chris@0 87
Chris@0 88 factory = instance("ladspa");
Chris@0 89 if (factory) {
Chris@0 90 const std::vector<QString> &tmp = factory->getPluginIdentifiers();
Chris@0 91 for (size_t i = 0; i < tmp.size(); ++i) {
Chris@0 92 rv.push_back(tmp[i]);
Chris@0 93 }
Chris@0 94 }
Chris@0 95
Chris@0 96 // Plugins can change the locale, revert it to default.
Chris@0 97 setlocale(LC_ALL, "C");
Chris@0 98 return rv;
Chris@0 99 }
Chris@0 100
Chris@0 101 void
Chris@0 102 RealTimePluginFactory::enumerateAllPlugins(std::vector<QString> &list)
Chris@0 103 {
Chris@0 104 RealTimePluginFactory *factory;
Chris@0 105
Chris@0 106 // Query DSSI plugins before LADSPA ones.
Chris@0 107 // This is to provide for the interesting possibility of plugins
Chris@0 108 // providing either DSSI or LADSPA versions of themselves,
Chris@0 109 // returning both versions if the LADSPA identifiers are queried
Chris@0 110 // first but only the DSSI version if the DSSI identifiers are
Chris@0 111 // queried first.
Chris@0 112
Chris@0 113 factory = instance("dssi");
Chris@0 114 if (factory) factory->enumeratePlugins(list);
Chris@0 115
Chris@0 116 factory = instance("ladspa");
Chris@0 117 if (factory) factory->enumeratePlugins(list);
Chris@0 118
Chris@0 119 // Plugins can change the locale, revert it to default.
Chris@0 120 setlocale(LC_ALL, "C");
Chris@0 121 }
Chris@0 122