comparison transform/FeatureExtractionModelTransformer.cpp @ 497:b6dc6c7f402c

Various fixes: * Fix handling of HTTP redirects (avoiding crashes... I hope) * Fix failure to delete FFT models when a feature extraction model transformer was abandoned (also a cause of crashes in the past) * Fix deadlock when said transform was abandoned before its source model was ready because the session was being cleared (and so the source model would never be ready)
author Chris Cannam
date Fri, 28 Nov 2008 13:36:13 +0000
parents a70dcfed59c1
children 55ad231c9db7
comparison
equal deleted inserted replaced
496:05383ee78f3e 497:b6dc6c7f402c
369 DenseTimeValueModel *input = getConformingInput(); 369 DenseTimeValueModel *input = getConformingInput();
370 if (!input) return; 370 if (!input) return;
371 371
372 if (!m_output) return; 372 if (!m_output) return;
373 373
374 while (!input->isReady()) { 374 while (!input->isReady() && !m_abandoned) {
375 std::cerr << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << std::endl; 375 std::cerr << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << std::endl;
376 sleep(1); 376 usleep(500000);
377 } 377 }
378 if (m_abandoned) return;
378 379
379 size_t sampleRate = input->getSampleRate(); 380 size_t sampleRate = input->getSampleRate();
380 381
381 size_t channelCount = input->getChannelCount(); 382 size_t channelCount = input->getChannelCount();
382 if (m_plugin->getMaxChannelCount() < channelCount) { 383 if (m_plugin->getMaxChannelCount() < channelCount) {
476 } 477 }
477 } else { 478 } else {
478 getFrames(channelCount, blockFrame, blockSize, buffers); 479 getFrames(channelCount, blockFrame, blockSize, buffers);
479 } 480 }
480 481
482 if (m_abandoned) break;
483
481 Vamp::Plugin::FeatureSet features = m_plugin->process 484 Vamp::Plugin::FeatureSet features = m_plugin->process
482 (buffers, Vamp::RealTime::frame2RealTime(blockFrame, sampleRate)); 485 (buffers, Vamp::RealTime::frame2RealTime(blockFrame, sampleRate));
486
487 if (m_abandoned) break;
483 488
484 for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) { 489 for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) {
485 Vamp::Plugin::Feature feature = 490 Vamp::Plugin::Feature feature =
486 features[m_outputFeatureNo][fi]; 491 features[m_outputFeatureNo][fi];
487 addFeature(blockFrame, feature); 492 addFeature(blockFrame, feature);
493 } 498 }
494 499
495 blockFrame += stepSize; 500 blockFrame += stepSize;
496 } 501 }
497 502
498 if (m_abandoned) return; 503 if (!m_abandoned) {
499 504 Vamp::Plugin::FeatureSet features = m_plugin->getRemainingFeatures();
500 Vamp::Plugin::FeatureSet features = m_plugin->getRemainingFeatures(); 505
501 506 for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) {
502 for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) { 507 Vamp::Plugin::Feature feature =
503 Vamp::Plugin::Feature feature = 508 features[m_outputFeatureNo][fi];
504 features[m_outputFeatureNo][fi]; 509 addFeature(blockFrame, feature);
505 addFeature(blockFrame, feature); 510 }
506 } 511 }
512
513 setCompletion(100);
507 514
508 if (frequencyDomain) { 515 if (frequencyDomain) {
509 for (size_t ch = 0; ch < channelCount; ++ch) { 516 for (size_t ch = 0; ch < channelCount; ++ch) {
510 delete fftModels[ch]; 517 delete fftModels[ch];
511 } 518 }
512 } 519 }
513
514 setCompletion(100);
515 } 520 }
516 521
517 void 522 void
518 FeatureExtractionModelTransformer::getFrames(int channelCount, 523 FeatureExtractionModelTransformer::getFrames(int channelCount,
519 long startFrame, long size, 524 long startFrame, long size,