Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_clock_recovery_mm_ff.cc
index d27ab9d65e52f8bdc0cf4c9dda40456b27d98ca3..2e9eea8e665f6a2aa94db12b88f327d75b9e793a 100644 (file)
@@ -108,9 +108,10 @@ gr_clock_recovery_mm_ff::general_work (int noutput_items,
 
   int  ii = 0;                         // input index
   int          oo = 0;                         // output index
+  int   ni = ninput_items[0] - d_interp->ntaps(); // don't use more input than this
   float mm_val;
 
-  while (oo < noutput_items){
+  while (oo < noutput_items && ii < ni ){
 
     // produce output sample
     out[oo] = d_interp->interpolate (&in[ii], d_mu);
@@ -118,11 +119,7 @@ gr_clock_recovery_mm_ff::general_work (int noutput_items,
     d_last_sample = out[oo];
 
     d_omega = d_omega + d_gain_omega * mm_val;
-    if (d_omega > d_max_omega)
-      d_omega = d_max_omega;
-    else if (d_omega < d_min_omega)
-      d_omega = d_min_omega;
-
+    d_omega = d_omega_mid + gr_branchless_clip(d_omega-d_omega_mid, d_omega_relative_limit);   // make sure we don't walk away
     d_mu = d_mu + d_omega + d_gain_mu * mm_val;
 
     ii += (int) floor(d_mu);
@@ -136,5 +133,5 @@ gr_clock_recovery_mm_ff::general_work (int noutput_items,
 
   consume_each (ii);
 
-  return noutput_items;
+  return oo;
 }