Mercurial > hg > svcore
changeset 1703:b17fb3a4560c single-point
Add haveRunningTransformers() and mutex
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 16:01:04 +0100 |
parents | 81f50b70bdef |
children | 452b48b29c2d |
files | transform/ModelTransformerFactory.cpp transform/ModelTransformerFactory.h |
diffstat | 2 files changed, 32 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/transform/ModelTransformerFactory.cpp Tue May 07 15:52:12 2019 +0100 +++ b/transform/ModelTransformerFactory.cpp Thu May 09 16:01:04 2019 +0100 @@ -34,6 +34,7 @@ #include <set> #include <QRegExp> +#include <QMutexLocker> using std::vector; @@ -59,6 +60,8 @@ sv_frame_t duration, UserConfigurator *configurator) { + QMutexLocker locker(&m_mutex); + ModelTransformer::Input input(nullptr); if (candidateInputModels.empty()) return input; @@ -213,6 +216,8 @@ { SVDEBUG << "ModelTransformerFactory::transformMultiple: Constructing transformer with input model " << input.getModel() << endl; + QMutexLocker locker(&m_mutex); + ModelTransformer *t = createTransformer(transforms, input); if (!t) return vector<Model *>(); @@ -255,6 +260,8 @@ void ModelTransformerFactory::transformerFinished() { + QMutexLocker locker(&m_mutex); + QObject *s = sender(); ModelTransformer *transformer = dynamic_cast<ModelTransformer *>(s); @@ -299,17 +306,21 @@ { TransformerSet affected; - for (TransformerSet::iterator i = m_runningTransformers.begin(); - i != m_runningTransformers.end(); ++i) { + { + QMutexLocker locker(&m_mutex); + + for (TransformerSet::iterator i = m_runningTransformers.begin(); + i != m_runningTransformers.end(); ++i) { - ModelTransformer *t = *i; + ModelTransformer *t = *i; - if (t->getInputModel() == m) { - affected.insert(t); - } else { - vector<Model *> mm = t->getOutputModels(); - for (int i = 0; i < (int)mm.size(); ++i) { - if (mm[i] == m) affected.insert(t); + if (t->getInputModel() == m) { + affected.insert(t); + } else { + vector<Model *> mm = t->getOutputModels(); + for (int i = 0; i < (int)mm.size(); ++i) { + if (mm[i] == m) affected.insert(t); + } } } } @@ -327,3 +338,10 @@ } } +bool +ModelTransformerFactory::haveRunningTransformers() const +{ + QMutexLocker locker(&m_mutex); + + return (!m_runningTransformers.empty()); +}
--- a/transform/ModelTransformerFactory.h Tue May 07 15:52:12 2019 +0100 +++ b/transform/ModelTransformerFactory.h Thu May 09 16:01:04 2019 +0100 @@ -25,6 +25,7 @@ #include <vamp-hostsdk/PluginBase.h> #include <QMap> +#include <QMutex> #include <map> #include <set> #include <vector> @@ -145,6 +146,8 @@ QString &message, AdditionalModelHandler *handler = 0); + bool haveRunningTransformers() const; + signals: void transformFailed(QString transformName, QString message); @@ -157,6 +160,8 @@ ModelTransformer *createTransformer(const Transforms &transforms, const ModelTransformer::Input &input); + mutable QMutex m_mutex; + typedef std::map<TransformId, QString> TransformerConfigurationMap; TransformerConfigurationMap m_lastConfigurations;