comparison transform/TransformFactory.cpp @ 1264:a99641535e02 3.0-integration

Debug output improvements, and make the checker actually attempt to call the descriptor function for known plugin types
author Chris Cannam
date Wed, 16 Nov 2016 16:12:42 +0000
parents 5d886b7b4029
children 48e9f538e6e9
comparison
equal deleted inserted replaced
1263:abfc498c52bc 1264:a99641535e02
751 { 751 {
752 Transform t; 752 Transform t;
753 t.setIdentifier(id); 753 t.setIdentifier(id);
754 if (rate != 0) t.setSampleRate(rate); 754 if (rate != 0) t.setSampleRate(rate);
755 755
756 SVDEBUG << "TransformFactory::getDefaultTransformFor: identifier \""
757 << id << "\"" << endl;
758
756 Vamp::PluginBase *plugin = instantiateDefaultPluginFor(id, rate); 759 Vamp::PluginBase *plugin = instantiateDefaultPluginFor(id, rate);
757 760
758 if (plugin) { 761 if (plugin) {
759 t.setPluginVersion(QString("%1").arg(plugin->getPluginVersion())); 762 t.setPluginVersion(QString("%1").arg(plugin->getPluginVersion()));
760 setParametersFromPlugin(t, plugin); 763 setParametersFromPlugin(t, plugin);
766 } 769 }
767 770
768 Vamp::PluginBase * 771 Vamp::PluginBase *
769 TransformFactory::instantiatePluginFor(const Transform &transform) 772 TransformFactory::instantiatePluginFor(const Transform &transform)
770 { 773 {
774 SVDEBUG << "TransformFactory::instantiatePluginFor: identifier \""
775 << transform.getIdentifier() << "\"" << endl;
776
771 Vamp::PluginBase *plugin = instantiateDefaultPluginFor 777 Vamp::PluginBase *plugin = instantiateDefaultPluginFor
772 (transform.getIdentifier(), transform.getSampleRate()); 778 (transform.getIdentifier(), transform.getSampleRate());
773 779
774 if (plugin) { 780 if (plugin) {
775 setPluginParameters(transform, plugin); 781 setPluginParameters(transform, plugin);
789 795
790 Vamp::PluginBase *plugin = 0; 796 Vamp::PluginBase *plugin = 0;
791 797
792 if (t.getType() == Transform::FeatureExtraction) { 798 if (t.getType() == Transform::FeatureExtraction) {
793 799
794 // cerr << "TransformFactory::instantiateDefaultPluginFor: identifier \"" 800 SVDEBUG << "TransformFactory::instantiateDefaultPluginFor: identifier \""
795 // << identifier << "\" is a feature extraction transform" << endl; 801 << identifier << "\" is a feature extraction transform" << endl;
796 802
797 FeatureExtractionPluginFactory *factory = 803 FeatureExtractionPluginFactory *factory =
798 FeatureExtractionPluginFactory::instance(); 804 FeatureExtractionPluginFactory::instance();
799 805
800 if (factory) { 806 if (factory) {
801 plugin = factory->instantiatePlugin(pluginId, rate); 807 plugin = factory->instantiatePlugin(pluginId, rate);
802 } 808 }
803 809
804 } else if (t.getType() == Transform::RealTimeEffect) { 810 } else if (t.getType() == Transform::RealTimeEffect) {
805 811
806 // cerr << "TransformFactory::instantiateDefaultPluginFor: identifier \"" 812 SVDEBUG << "TransformFactory::instantiateDefaultPluginFor: identifier \""
807 // << identifier << "\" is a real-time transform" << endl; 813 << identifier << "\" is a real-time transform" << endl;
808 814
809 RealTimePluginFactory *factory = 815 RealTimePluginFactory *factory =
810 RealTimePluginFactory::instanceFor(pluginId); 816 RealTimePluginFactory::instanceFor(pluginId);
811 817
812 if (factory) { 818 if (factory) {
813 plugin = factory->instantiatePlugin(pluginId, 0, 0, rate, 1024, 1); 819 plugin = factory->instantiatePlugin(pluginId, 0, 0, rate, 1024, 1);
814 } 820 }
815 821
816 } else { 822 } else {
817 cerr << "TransformFactory: ERROR: transform id \"" 823 SVDEBUG << "TransformFactory: ERROR: transform id \""
818 << identifier << "\" is of unknown type" << endl; 824 << identifier << "\" is of unknown type" << endl;
819 } 825 }
820 826
821 return plugin; 827 return plugin;
822 } 828 }
823 829
882 TransformFactory::getTransformInputDomain(TransformId identifier) 888 TransformFactory::getTransformInputDomain(TransformId identifier)
883 { 889 {
884 Transform transform; 890 Transform transform;
885 transform.setIdentifier(identifier); 891 transform.setIdentifier(identifier);
886 892
893 SVDEBUG << "TransformFactory::getTransformInputDomain: identifier \""
894 << identifier << "\"" << endl;
895
887 if (transform.getType() != Transform::FeatureExtraction) { 896 if (transform.getType() != Transform::FeatureExtraction) {
888 return Vamp::Plugin::TimeDomain; 897 return Vamp::Plugin::TimeDomain;
889 } 898 }
890 899
891 Vamp::Plugin *plugin = 900 Vamp::Plugin *plugin =
1067 QString 1076 QString
1068 TransformFactory::getPluginConfigurationXml(const Transform &t) 1077 TransformFactory::getPluginConfigurationXml(const Transform &t)
1069 { 1078 {
1070 QString xml; 1079 QString xml;
1071 1080
1081 SVDEBUG << "TransformFactory::getPluginConfigurationXml: identifier \""
1082 << t.getIdentifier() << "\"" << endl;
1083
1072 Vamp::PluginBase *plugin = instantiateDefaultPluginFor 1084 Vamp::PluginBase *plugin = instantiateDefaultPluginFor
1073 (t.getIdentifier(), 0); 1085 (t.getIdentifier(), 0);
1074 if (!plugin) { 1086 if (!plugin) {
1075 cerr << "TransformFactory::getPluginConfigurationXml: " 1087 SVDEBUG << "TransformFactory::getPluginConfigurationXml: "
1076 << "Unable to instantiate plugin for transform \"" 1088 << "Unable to instantiate plugin for transform \""
1077 << t.getIdentifier() << "\"" << endl; 1089 << t.getIdentifier() << "\"" << endl;
1078 return xml; 1090 return xml;
1079 } 1091 }
1080 1092
1081 setPluginParameters(t, plugin); 1093 setPluginParameters(t, plugin);
1082 1094
1089 1101
1090 void 1102 void
1091 TransformFactory::setParametersFromPluginConfigurationXml(Transform &t, 1103 TransformFactory::setParametersFromPluginConfigurationXml(Transform &t,
1092 QString xml) 1104 QString xml)
1093 { 1105 {
1106 SVDEBUG << "TransformFactory::setParametersFromPluginConfigurationXml: identifier \""
1107 << t.getIdentifier() << "\"" << endl;
1108
1094 Vamp::PluginBase *plugin = instantiateDefaultPluginFor 1109 Vamp::PluginBase *plugin = instantiateDefaultPluginFor
1095 (t.getIdentifier(), 0); 1110 (t.getIdentifier(), 0);
1096 if (!plugin) { 1111 if (!plugin) {
1097 cerr << "TransformFactory::setParametersFromPluginConfigurationXml: " 1112 SVDEBUG << "TransformFactory::setParametersFromPluginConfigurationXml: "
1098 << "Unable to instantiate plugin for transform \"" 1113 << "Unable to instantiate plugin for transform \""
1099 << t.getIdentifier() << "\"" << endl; 1114 << t.getIdentifier() << "\"" << endl;
1100 return; 1115 return;
1101 } 1116 }
1102 1117
1103 PluginXml(plugin).setParametersFromXml(xml); 1118 PluginXml(plugin).setParametersFromXml(xml);
1104 setParametersFromPlugin(t, plugin); 1119 setParametersFromPlugin(t, plugin);
1148 } 1163 }
1149 1164
1150 if (!m_uninstalledTransformsMutex.tryLock()) { 1165 if (!m_uninstalledTransformsMutex.tryLock()) {
1151 // uninstalled transforms are being populated; this may take some time, 1166 // uninstalled transforms are being populated; this may take some time,
1152 // and they aren't critical, but we will speed them up if necessary 1167 // and they aren't critical, but we will speed them up if necessary
1153 cerr << "TransformFactory::search: Uninstalled transforms mutex is held, skipping" << endl; 1168 SVDEBUG << "TransformFactory::search: Uninstalled transforms mutex is held, skipping" << endl;
1154 m_populatingSlowly = false; 1169 m_populatingSlowly = false;
1155 return results; 1170 return results;
1156 } 1171 }
1157 1172
1158 if (!m_uninstalledTransformsPopulated) { 1173 if (!m_uninstalledTransformsPopulated) {
1159 cerr << "WARNING: TransformFactory::search: Uninstalled transforms are not populated yet" << endl 1174 SVDEBUG << "WARNING: TransformFactory::search: Uninstalled transforms are not populated yet" << endl
1160 << "and are not being populated either -- was the thread not started correctly?" << endl; 1175 << "and are not being populated either -- was the thread not started correctly?" << endl;
1161 m_uninstalledTransformsMutex.unlock(); 1176 m_uninstalledTransformsMutex.unlock();
1162 return results; 1177 return results;
1163 } 1178 }
1164 1179
1165 m_uninstalledTransformsMutex.unlock(); 1180 m_uninstalledTransformsMutex.unlock();