Mercurial > hg > svcore
comparison transform/FeatureExtractionModelTransformer.cpp @ 1080:f35c1f9bfaa2
Tighten up error handling
author | Chris Cannam |
---|---|
date | Wed, 10 Jun 2015 13:12:06 +0100 |
parents | f4ad0bfceeb7 |
children | 9f4505ac9072 |
comparison
equal
deleted
inserted
replaced
1079:6ea7761a418b | 1080:f35c1f9bfaa2 |
---|---|
42 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, | 42 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, |
43 const Transform &transform) : | 43 const Transform &transform) : |
44 ModelTransformer(in, transform), | 44 ModelTransformer(in, transform), |
45 m_plugin(0) | 45 m_plugin(0) |
46 { | 46 { |
47 // SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl; | 47 SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << m_transforms.begin()->getPluginIdentifier() << ", outputName " << m_transforms.begin()->getOutput() << endl; |
48 | 48 |
49 initialise(); | 49 initialise(); |
50 } | 50 } |
51 | 51 |
52 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, | 52 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, |
53 const Transforms &transforms) : | 53 const Transforms &transforms) : |
54 ModelTransformer(in, transforms), | 54 ModelTransformer(in, transforms), |
55 m_plugin(0) | 55 m_plugin(0) |
56 { | 56 { |
57 // SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl; | 57 if (m_transforms.empty()) { |
58 | 58 SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: " << transforms.size() << " transform(s)" << endl; |
59 } else { | |
60 SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: " << transforms.size() << " transform(s), first has plugin " << m_transforms.begin()->getPluginIdentifier() << ", outputName " << m_transforms.begin()->getOutput() << endl; | |
61 } | |
62 | |
59 initialise(); | 63 initialise(); |
60 } | 64 } |
61 | 65 |
62 static bool | 66 static bool |
63 areTransformsSimilar(const Transform &t1, const Transform &t2) | 67 areTransformsSimilar(const Transform &t1, const Transform &t2) |
603 blockSize, | 607 blockSize, |
604 stepSize, | 608 stepSize, |
605 blockSize, | 609 blockSize, |
606 false, | 610 false, |
607 StorageAdviser::PrecisionCritical); | 611 StorageAdviser::PrecisionCritical); |
608 if (!model->isOK()) { | 612 if (!model->isOK() || model->getError() != "") { |
613 QString err = model->getError(); | |
609 delete model; | 614 delete model; |
610 for (int j = 0; j < (int)m_outputNos.size(); ++j) { | 615 for (int j = 0; j < (int)m_outputNos.size(); ++j) { |
611 setCompletion(j, 100); | 616 setCompletion(j, 100); |
612 } | 617 } |
613 //!!! need a better way to handle this -- previously we were using a QMessageBox but that isn't an appropriate thing to do here either | 618 //!!! need a better way to handle this -- previously we were using a QMessageBox but that isn't an appropriate thing to do here either |
614 throw AllocationFailed("Failed to create the FFT model for this feature extraction model transformer"); | 619 throw AllocationFailed("Failed to create the FFT model for this feature extraction model transformer: error is: " + err); |
615 } | 620 } |
616 model->resume(); | 621 model->resume(); |
617 fftModels.push_back(model); | 622 fftModels.push_back(model); |
623 cerr << "created model for channel " << ch << endl; | |
618 } | 624 } |
619 } | 625 } |
620 | 626 |
621 sv_frame_t startFrame = m_input.getModel()->getStartFrame(); | 627 sv_frame_t startFrame = m_input.getModel()->getStartFrame(); |
622 sv_frame_t endFrame = m_input.getModel()->getEndFrame(); | 628 sv_frame_t endFrame = m_input.getModel()->getEndFrame(); |
695 error = fftModels[ch]->getError(); | 701 error = fftModels[ch]->getError(); |
696 if (error != "") { | 702 if (error != "") { |
697 cerr << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl; | 703 cerr << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl; |
698 m_abandoned = true; | 704 m_abandoned = true; |
699 m_message = error; | 705 m_message = error; |
706 break; | |
700 } | 707 } |
701 } | 708 } |
702 } else { | 709 } else { |
703 getFrames(channelCount, blockFrame, blockSize, buffers); | 710 getFrames(channelCount, blockFrame, blockSize, buffers); |
704 } | 711 } |