diff src/MatchFeeder.cpp @ 63:a540137d393b refactors_no_float

Fix handling of empty queues -- we should continue processing when a queue is empty only if we've reached end of file on both
author Chris Cannam
date Tue, 18 Nov 2014 10:03:36 +0000
parents faa523be20f9
children da9ead46abe9
line wrap: on
line diff
--- a/src/MatchFeeder.cpp	Fri Nov 14 13:53:58 2014 +0000
+++ b/src/MatchFeeder.cpp	Tue Nov 18 10:03:36 2014 +0000
@@ -53,8 +53,7 @@
 
     prepare(input);
 
-    while (!q1.empty() || !q2.empty()) {
-//        std::cerr << "MatchFeeder::feed: q1 " << q1.size() << " q2 " << q2.size() << std::endl;
+    while (!q1.empty() && !q2.empty()) {
         (void)feedBlock();
     }
 }
@@ -66,6 +65,28 @@
 
     Features all;
 
+    while (!q1.empty() && !q2.empty()) {
+        Features ff = feedBlock();
+        all.f1.insert(all.f1.end(), ff.f1.begin(), ff.f1.end());
+        all.f2.insert(all.f2.end(), ff.f2.begin(), ff.f2.end());
+    }
+
+    return all;
+}
+
+void
+MatchFeeder::finish()
+{
+    while (!q1.empty() || !q2.empty()) {
+        (void)feedBlock();
+    }
+}
+
+MatchFeeder::Features
+MatchFeeder::finishAndGetFeatures()
+{
+    Features all;
+
     while (!q1.empty() || !q2.empty()) {
         Features ff = feedBlock();
         all.f1.insert(all.f1.end(), ff.f1.begin(), ff.f1.end());
@@ -117,9 +138,9 @@
     vector<double> f1, f2;
 
     if (q1.empty()) {
-        feed2();
+        f2 = feed2();
     } else if (q2.empty()) {
-        feed1();
+        f1 = feed1();
     } else if (pm1->m_frameCount < pm1->m_blockSize) {		// fill initial block
 //        std::cerr << "feeding initial block" << std::endl;
         f1 = feed1();