comparison transform/RealTimeEffectModelTransformer.cpp @ 1496:fde8c497373f

Avoid crashing if an effects plugin can't be instantiated and so the output vector is empty in the transformer's run() method
author Chris Cannam
date Mon, 13 Aug 2018 15:25:32 +0100
parents 48e9f538e6e9
children 70e172e6cc59
comparison
equal deleted inserted replaced
1495:6965c83c8fa7 1496:fde8c497373f
45 m_outputNo = 45 m_outputNo =
46 (transform.getOutput() == "A") ? -1 : transform.getOutput().toInt(); 46 (transform.getOutput() == "A") ? -1 : transform.getOutput().toInt();
47 47
48 QString pluginId = transform.getPluginIdentifier(); 48 QString pluginId = transform.getPluginIdentifier();
49 49
50 // SVDEBUG << "RealTimeEffectModelTransformer::RealTimeEffectModelTransformer: plugin " << pluginId << ", output " << output << endl; 50 SVDEBUG << "RealTimeEffectModelTransformer::RealTimeEffectModelTransformer: plugin " << pluginId << ", output " << transform.getOutput() << endl;
51 51
52 RealTimePluginFactory *factory = 52 RealTimePluginFactory *factory =
53 RealTimePluginFactory::instanceFor(pluginId); 53 RealTimePluginFactory::instanceFor(pluginId);
54 54
55 if (!factory) { 55 if (!factory) {
56 cerr << "RealTimeEffectModelTransformer: No factory available for plugin id \"" 56 SVCERR << "RealTimeEffectModelTransformer: No factory available for plugin id \""
57 << pluginId << "\"" << endl; 57 << pluginId << "\"" << endl;
58 return; 58 return;
59 } 59 }
60 60
61 DenseTimeValueModel *input = getConformingInput(); 61 DenseTimeValueModel *input = getConformingInput();
62 if (!input) return; 62 if (!input) return;
65 input->getSampleRate(), 65 input->getSampleRate(),
66 transform.getBlockSize(), 66 transform.getBlockSize(),
67 input->getChannelCount()); 67 input->getChannelCount());
68 68
69 if (!m_plugin) { 69 if (!m_plugin) {
70 cerr << "RealTimeEffectModelTransformer: Failed to instantiate plugin \"" 70 SVCERR << "RealTimeEffectModelTransformer: Failed to instantiate plugin \""
71 << pluginId << "\"" << endl; 71 << pluginId << "\"" << endl;
72 return; 72 return;
73 } 73 }
74 74
75 TransformFactory::getInstance()->setPluginParameters(transform, m_plugin); 75 TransformFactory::getInstance()->setPluginParameters(transform, m_plugin);
76 76
127 127
128 while (!input->isReady() && !m_abandoned) { 128 while (!input->isReady() && !m_abandoned) {
129 SVDEBUG << "RealTimeEffectModelTransformer::run: Waiting for input model to be ready..." << endl; 129 SVDEBUG << "RealTimeEffectModelTransformer::run: Waiting for input model to be ready..." << endl;
130 usleep(500000); 130 usleep(500000);
131 } 131 }
132 if (m_abandoned) return; 132 if (m_abandoned) {
133 133 return;
134 SparseTimeValueModel *stvm = dynamic_cast<SparseTimeValueModel *>(m_outputs[0]); 134 }
135 WritableWaveFileModel *wwfm = dynamic_cast<WritableWaveFileModel *>(m_outputs[0]); 135 if (m_outputs.empty()) {
136 if (!stvm && !wwfm) return; 136 return;
137 137 }
138 if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) return; 138
139 SparseTimeValueModel *stvm =
140 dynamic_cast<SparseTimeValueModel *>(m_outputs[0]);
141 WritableWaveFileModel *wwfm =
142 dynamic_cast<WritableWaveFileModel *>(m_outputs[0]);
143
144 if (!stvm && !wwfm) {
145 return;
146 }
147
148 if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) {
149 return;
150 }
139 151
140 sv_samplerate_t sampleRate = input->getSampleRate(); 152 sv_samplerate_t sampleRate = input->getSampleRate();
141 int channelCount = input->getChannelCount(); 153 int channelCount = input->getChannelCount();
142 if (!wwfm && m_input.getChannel() != -1) channelCount = 1; 154 if (!wwfm && m_input.getChannel() != -1) channelCount = 1;
143 155