- double last_output_len;
- if (first_output) {
- // Synthesize a fake length.
- last_output_len = double(num_samples) / freq_out;
- } else {
- last_output_len = pts - last_output_pts;
- }
- last_output_pts = pts;
-
- // Using the time point since just before the last call to add_input_samples() as a base,
- // estimate actual delay based on activity since then, measured in number of input samples:
- double actual_delay = 0.0;
- assert(last_input_len != 0);
- actual_delay += (k_a1 - k_a0) * last_output_len / last_input_len; // Inserted samples since k_a0, rescaled for the different time periods.
- actual_delay += k_a0 - total_consumed_samples; // Samples inserted before k_a0 but not consumed yet.
- actual_delay += vresampler.inpdist(); // Delay in the resampler itself.
- double err = actual_delay - expected_delay;
- if (first_output && err < 0.0) {
- // Before the very first block, insert artificial delay based on our initial estimate,
- // so that we don't need a long period to stabilize at the beginning.
- int delay_samples_to_add = lrintf(-err);
- for (ssize_t i = 0; i < delay_samples_to_add * num_channels; ++i) {
- buffer.push_front(0.0f);
+ double rcorr = -1.0;
+ if (rate_adjustment_policy == ADJUST_RATE) {
+ double last_output_len;
+ if (first_output) {
+ // Synthesize a fake length.
+ last_output_len = double(num_samples) / freq_out;
+ } else {
+ last_output_len = pts - last_output_pts;
+ }
+ last_output_pts = pts;
+
+ // Using the time point since just before the last call to add_input_samples() as a base,
+ // estimate actual delay based on activity since then, measured in number of input samples:
+ double actual_delay = 0.0;
+ assert(last_input_len != 0);
+ actual_delay += (k_a1 - k_a0) * last_output_len / last_input_len; // Inserted samples since k_a0, rescaled for the different time periods.
+ actual_delay += k_a0 - total_consumed_samples; // Samples inserted before k_a0 but not consumed yet.
+ actual_delay += vresampler.inpdist(); // Delay in the resampler itself.
+ double err = actual_delay - expected_delay;
+ if (first_output && err < 0.0) {
+ // Before the very first block, insert artificial delay based on our initial estimate,
+ // so that we don't need a long period to stabilize at the beginning.
+ int delay_samples_to_add = lrintf(-err);
+ for (ssize_t i = 0; i < delay_samples_to_add * num_channels; ++i) {
+ buffer.push_front(0.0f);
+ }
+ total_consumed_samples -= delay_samples_to_add; // Equivalent to increasing k_a0 and k_a1.
+ err += delay_samples_to_add;