Mercurial > hg > svcore
changeset 1178:bf05d9259dbc pluginscan
First cut running (but not yet using output of, or recovering from errors in) the plugin checker at startup
author | Chris Cannam |
---|---|
date | Thu, 14 Apr 2016 12:12:04 +0100 |
parents | 4018fc0189bc |
children | 6b1af0f05f06 |
files | config.pri.in data/fileio/test/test.pro plugin/FeatureExtractionPluginFactory.cpp plugin/PluginScan.cpp plugin/PluginScan.h svcore.pro system/System.cpp |
diffstat | 7 files changed, 154 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/config.pri.in Fri Mar 18 14:25:05 2016 +0000 +++ b/config.pri.in Thu Apr 14 12:12:04 2016 +0100 @@ -10,7 +10,7 @@ QMAKE_CXXFLAGS += @CXXFLAGS@ QMAKE_LFLAGS += @LDFLAGS@ -linux*:LIBS += -lasound +linux*:LIBS += -lasound -ldl macx*:DEFINES += HAVE_COREAUDIO MACOSX_DEPLOYMENT_TARGET=1060
--- a/data/fileio/test/test.pro Fri Mar 18 14:25:05 2016 +0000 +++ b/data/fileio/test/test.pro Thu Apr 14 12:12:04 2016 +0100 @@ -36,6 +36,9 @@ DEFINES += HAVE_COREAUDIO LIBS += -framework CoreAudio -framework CoreMidi -framework AudioUnit -framework AudioToolbox -framework CoreFoundation -framework CoreServices -framework Accelerate } + linux* { + LIBS += -ldl + } } CONFIG += qt thread warn_on stl rtti exceptions console c++11
--- a/plugin/FeatureExtractionPluginFactory.cpp Fri Mar 18 14:25:05 2016 +0000 +++ b/plugin/FeatureExtractionPluginFactory.cpp Thu Apr 14 12:12:04 2016 +0100 @@ -119,7 +119,7 @@ for (QString dirname : path) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << dirname << endl; + cerr << "FeatureExtractionPluginFactory::getPluginCandidateFiles: scanning directory " << dirname << endl; #endif QDir pluginDir(dirname, PLUGIN_GLOB,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugin/PluginScan.cpp Thu Apr 14 12:12:04 2016 +0100 @@ -0,0 +1,89 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#include "PluginScan.h" + +#include "base/Debug.h" + +#include <QMutex> + +using std::string; + +PluginScan *PluginScan::getInstance() { + static QMutex mutex; + static PluginScan *m_instance = 0; + mutex.lock(); + if (!m_instance) m_instance = new PluginScan(); + mutex.unlock(); + return m_instance; +} + +PluginScan::PluginScan() : m_kp(0) { +} + +PluginScan::~PluginScan() { + delete m_kp; +} + +void +PluginScan::log(string message) +{ + SVDEBUG << "PluginScan: " << message; +} + +void +PluginScan::scan() +{ + delete m_kp; + m_kp = new KnownPlugins("./helper", this); //!!! +} + +QStringList +PluginScan::getCandidateVampLibraries() const +{ + QStringList candidates; + if (!m_kp) return candidates; + auto c = m_kp->getCandidateLibrariesFor(KnownPlugins::VampPlugin); + for (auto s: c) candidates.push_back(s.c_str()); + return candidates; +} + +QStringList +PluginScan::getCandidateLADSPALibraries() const +{ + QStringList candidates; + if (!m_kp) return candidates; + auto c = m_kp->getCandidateLibrariesFor(KnownPlugins::LADSPAPlugin); + for (auto s: c) candidates.push_back(s.c_str()); + return candidates; +} + +QStringList +PluginScan::getCandidateDSSILibraries() const +{ + QStringList candidates; + if (!m_kp) return candidates; + auto c = m_kp->getCandidateLibrariesFor(KnownPlugins::DSSIPlugin); + for (auto s: c) candidates.push_back(s.c_str()); + return candidates; +} + +QString +PluginScan::getStartupFailureReport() const +{ + if (!m_kp) return ""; //!!!??? + string report = m_kp->getFailureReport(); + return report.c_str(); //!!! wrap? +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugin/PluginScan.h Thu Apr 14 12:12:04 2016 +0100 @@ -0,0 +1,44 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef PLUGIN_SCAN_H +#define PLUGIN_SCAN_H + +#include <QStringList> + +#include "../vamp-plugin-load-checker/knownplugins.h" //!!! + +class PluginScan : public PluginCandidates::LogCallback +{ +public: + static PluginScan *getInstance(); + + void scan(); + + QStringList getCandidateVampLibraries() const; + QStringList getCandidateLADSPALibraries() const; + QStringList getCandidateDSSILibraries() const; + + QString getStartupFailureReport() const; + +protected: + void log(std::string); + +private: + PluginScan(); + ~PluginScan(); + KnownPlugins *m_kp; +}; + +#endif
--- a/svcore.pro Fri Mar 18 14:25:05 2016 +0000 +++ b/svcore.pro Thu Apr 14 12:12:04 2016 +0100 @@ -223,7 +223,8 @@ data/osc/OSCMessage.cpp \ data/osc/OSCQueue.cpp -HEADERS += plugin/DSSIPluginFactory.h \ +HEADERS += plugin/PluginScan.h \ + plugin/DSSIPluginFactory.h \ plugin/DSSIPluginInstance.h \ plugin/FeatureExtractionPluginFactory.h \ plugin/LADSPAPluginFactory.h \ @@ -243,7 +244,8 @@ plugin/api/alsa/sound/asequencer.h -SOURCES += plugin/DSSIPluginFactory.cpp \ +SOURCES += plugin/PluginScan.cpp \ + plugin/DSSIPluginFactory.cpp \ plugin/DSSIPluginInstance.cpp \ plugin/FeatureExtractionPluginFactory.cpp \ plugin/LADSPAPluginFactory.cpp \
--- a/system/System.cpp Fri Mar 18 14:25:05 2016 +0000 +++ b/system/System.cpp Thu Apr 14 12:12:04 2016 +0100 @@ -335,6 +335,11 @@ { //!!! This is POSIX only, no equivalent on Windows, where we'll //!!! have to do something completely different + + //!!! update -- this is a bad idea on POSIX systems as well, I + //!!! fear, because fork() generally doesn't mix with + //!!! multithreaded processes (it forks only one thread but any + //!!! locked mutexes from the other threads remain locked). pid_t pid = fork(); @@ -344,6 +349,8 @@ if (pid == 0) { // the child process + cerr << "isPluginLibraryLoadable: About to try library \"" << soname << "\"" << endl; + void *handle = DLOPEN(soname, RTLD_NOW | RTLD_LOCAL); if (!handle) { cerr << "isPluginLibraryLoadable: Failed to open plugin library \"" @@ -358,7 +365,7 @@ exit(2); } -// cerr << "isPluginLibraryLoadable: Successfully loaded library \"" << soname << "\" and retrieved descriptor function" << endl; + cerr << "isPluginLibraryLoadable: Successfully loaded library \"" << soname << "\" and retrieved descriptor function" << endl; exit(0); @@ -367,9 +374,13 @@ int status = 0; do { + cerr << "waiting for subprocess with pid " << pid << "..." << endl; waitpid(pid, &status, 0); + cerr << "waited" << endl; } while (WIFSTOPPED(status)); + cerr << "and finished" << endl; + if (WIFEXITED(status)) { switch (WEXITSTATUS(status)) { case 0: return PluginLoadOK; // success