Merging ofdm2 branch -r7047:7321 into trunk. This updates the OFDM code to hier_block...
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_ofdm_sampler.cc
index 56b5d50a4e761ed87d61cef6ab7f9cf328709948..6216df791cfc7e7bd03c35cc1711682f525a4bab 100644 (file)
@@ -65,22 +65,26 @@ gr_ofdm_sampler::general_work (int noutput_items,
 
   gr_complex *optr = (gr_complex *) output_items[0];
 
-  int found=0;
+  int found=0, index=0;
 
   int i=d_fft_length-1;
 
-  while(!found && i<std::min(ninput_items[0],ninput_items[1]) ) {
-    if(trigger[i])
+  // FIXME: This is where we miss if the regeneration happens too soon.
+  //while(!found && i<std::min(ninput_items[0],ninput_items[1]) ) {
+  while(i<std::min(ninput_items[0],ninput_items[1]) ) {
+    if(trigger[i]) {
       found = 1;
+      index = i++;
+    }
     else
       i++;
   }
-
+  
   if(found) {
-    assert(i-d_fft_length+1 >= 0);
-    for(int j=i-d_fft_length+1;j<=i;j++)
+    assert(index-d_fft_length+1 >= 0);
+    for(int j=index - d_fft_length + 1; j <= index; j++)
       *optr++ = iptr[j];
-    consume_each(i-d_fft_length+2);
+    consume_each(index - d_fft_length + 2);
     //printf("OFDM Sampler found:  ninput_items: %d/%d   noutput_items: %d  consumed: %d   found: %d\n", 
     //   ninput_items[0], ninput_items[1], noutput_items, (i-d_fft_length+2), found);
   }