Mercurial > hg > svcore
comparison transform/TransformFactory.h @ 1830:5f8fbbde08ff audio-source-refactor
Use shared_ptr for plugin instances throughout
author | Chris Cannam |
---|---|
date | Fri, 20 Mar 2020 16:30:33 +0000 |
parents | c01cbe41aeb5 |
children | 627a7d7ada45 |
comparison
equal
deleted
inserted
replaced
1829:51fd27fbce9a | 1830:5f8fbbde08ff |
---|---|
86 /** | 86 /** |
87 * A single transform ID can lead to many possible Transforms, | 87 * A single transform ID can lead to many possible Transforms, |
88 * with different parameters and execution context settings. | 88 * with different parameters and execution context settings. |
89 * Return the default one for the given transform. | 89 * Return the default one for the given transform. |
90 */ | 90 */ |
91 Transform getDefaultTransformFor(TransformId identifier, sv_samplerate_t rate = 0); | 91 Transform getDefaultTransformFor(TransformId identifier, |
92 sv_samplerate_t rate = 0); | |
92 | 93 |
93 /** | 94 /** |
94 * Full name of a transform, suitable for putting on a menu. | 95 * Full name of a transform, suitable for putting on a menu. |
95 */ | 96 */ |
96 QString getTransformName(TransformId identifier); | 97 QString getTransformName(TransformId identifier); |
136 * | 137 * |
137 * Returns the plugin thus loaded. This will be a | 138 * Returns the plugin thus loaded. This will be a |
138 * Vamp::PluginBase, but not necessarily a Vamp::Plugin (only if | 139 * Vamp::PluginBase, but not necessarily a Vamp::Plugin (only if |
139 * the transform was a feature-extraction type -- call | 140 * the transform was a feature-extraction type -- call |
140 * downcastVampPlugin if you only want Vamp::Plugins). Returns | 141 * downcastVampPlugin if you only want Vamp::Plugins). Returns |
141 * NULL if no suitable plugin was available. | 142 * nullptr if no suitable plugin was available. |
142 * | 143 */ |
143 * The returned plugin is owned by the caller, and should be | 144 std::shared_ptr<Vamp::PluginBase> instantiatePluginFor(const Transform &transform); |
144 * deleted (using "delete") when no longer needed. | |
145 */ | |
146 Vamp::PluginBase *instantiatePluginFor(const Transform &transform); | |
147 | |
148 /** | |
149 * Convert a Vamp::PluginBase to a Vamp::Plugin, if it is one. | |
150 * Return NULL otherwise. This ill-fitting convenience function | |
151 * is really just a dynamic_cast wrapper. | |
152 */ | |
153 Vamp::Plugin *downcastVampPlugin(Vamp::PluginBase *); | |
154 | 145 |
155 /** | 146 /** |
156 * Set the plugin parameters, program and configuration strings on | 147 * Set the plugin parameters, program and configuration strings on |
157 * the given Transform object from the given plugin instance. | 148 * the given Transform object from the given plugin instance. |
158 * Note that no check is made whether the plugin is actually the | 149 * Note that no check is made whether the plugin is actually the |
159 * "correct" one for the transform. | 150 * "correct" one for the transform. |
160 */ | 151 */ |
161 void setParametersFromPlugin(Transform &transform, Vamp::PluginBase *plugin); | 152 void setParametersFromPlugin(Transform &transform, std::shared_ptr<Vamp::PluginBase> plugin); |
162 | 153 |
163 /** | 154 /** |
164 * Set the parameters, program and configuration strings on the | 155 * Set the parameters, program and configuration strings on the |
165 * given plugin from the given Transform object. | 156 * given plugin from the given Transform object. |
166 */ | 157 */ |
167 void setPluginParameters(const Transform &transform, Vamp::PluginBase *plugin); | 158 void setPluginParameters(const Transform &transform, std::shared_ptr<Vamp::PluginBase> plugin); |
168 | 159 |
169 /** | 160 /** |
170 * If the given Transform object has no processing step and block | 161 * If the given Transform object has no processing step and block |
171 * sizes set, set them to appropriate defaults for the given | 162 * sizes set, set them to appropriate defaults for the given |
172 * plugin. | 163 * plugin. |
173 */ | 164 */ |
174 void makeContextConsistentWithPlugin(Transform &transform, Vamp::PluginBase *plugin); | 165 void makeContextConsistentWithPlugin(Transform &transform, std::shared_ptr<Vamp::PluginBase> plugin); |
175 | 166 |
176 /** | 167 /** |
177 * Retrieve a <plugin ... /> XML fragment that describes the | 168 * Retrieve a <plugin ... /> XML fragment that describes the |
178 * plugin parameters, program and configuration data for the given | 169 * plugin parameters, program and configuration data for the given |
179 * transform. | 170 * transform. |
214 void populateTransforms(); | 205 void populateTransforms(); |
215 void populateUninstalledTransforms(); | 206 void populateUninstalledTransforms(); |
216 void populateFeatureExtractionPlugins(TransformDescriptionMap &); | 207 void populateFeatureExtractionPlugins(TransformDescriptionMap &); |
217 void populateRealTimePlugins(TransformDescriptionMap &); | 208 void populateRealTimePlugins(TransformDescriptionMap &); |
218 | 209 |
219 Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, sv_samplerate_t rate); | 210 std::shared_ptr<Vamp::PluginBase> instantiateDefaultPluginFor(TransformId id, sv_samplerate_t rate); |
220 QMutex m_transformsMutex; | 211 QMutex m_transformsMutex; |
221 QMutex m_uninstalledTransformsMutex; | 212 QMutex m_uninstalledTransformsMutex; |
222 | 213 |
223 class UninstalledTransformsPopulateThread : public QThread | 214 class UninstalledTransformsPopulateThread : public QThread |
224 { | 215 { |