return true;
}
+ // This can happen when we get dropped frames on the master card.
+ if (duration<double>(ts.time_since_epoch()).count() <= 0.0) {
+ rate_adjustment_policy = DO_NOT_ADJUST_RATE;
+ }
+
if (rate_adjustment_policy == ADJUST_RATE && (a0.good_sample || a1.good_sample)) {
// Estimate the current number of input samples produced at
// this instant in time, by extrapolating from the last known
err += delay_samples_to_add;
} else if (err > 0.0) {
int delay_samples_to_remove = min<int>(lrintf(err), buffer.size() / num_channels);
- for (ssize_t i = 0; i < delay_samples_to_remove * num_channels; ++i) {
- buffer.pop_front();
- }
+ buffer.erase(buffer.begin(), buffer.begin() + delay_samples_to_remove * num_channels);
total_consumed_samples += delay_samples_to_remove;
err -= delay_samples_to_remove;
}
if (rcorr < 0.95) rcorr = 0.95;
assert(!isnan(rcorr));
vresampler.set_rratio(rcorr);
- } else {
- assert(rate_adjustment_policy == DO_NOT_ADJUST_RATE);
}
// Finally actually resample, producing exactly <num_samples> output samples.
fprintf(stderr, "Card %u: PANIC: Out of input samples to resample, still need %d output samples! (correction factor is %f)\n",
card_num, int(vresampler.out_count), rcorr);
memset(vresampler.out_data, 0, vresampler.out_count * num_channels * sizeof(float));
+
+ // Reset the loop filter.
+ z1 = z2 = z3 = 0.0;
+
return false;
}