X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=nageru%2Fresampling_queue.cpp;h=9cbfe200f418dcae55522b15dfeea2929b9692b2;hb=a0e57ec99e9dfdd7e79bcf21e8c996dc43b6cb49;hp=711c1c5239f44aad7df9000711556bc2ff39c2d6;hpb=3630741c0d8c1d73fb7d888e1eb772e53f117105;p=nageru diff --git a/nageru/resampling_queue.cpp b/nageru/resampling_queue.cpp index 711c1c5..9cbfe20 100644 --- a/nageru/resampling_queue.cpp +++ b/nageru/resampling_queue.cpp @@ -20,18 +20,20 @@ #include "resampling_queue.h" #include +#include #include #include #include #include #include -#include + +#include "shared/shared_defs.h" using namespace std; using namespace std::chrono; -ResamplingQueue::ResamplingQueue(DeviceSpec device_spec, unsigned freq_in, unsigned freq_out, unsigned num_channels, double expected_delay_seconds) - : device_spec(device_spec), freq_in(freq_in), freq_out(freq_out), num_channels(num_channels), +ResamplingQueue::ResamplingQueue(const std::string &debug_description, unsigned freq_in, unsigned freq_out, unsigned num_channels, double expected_delay_seconds) + : debug_description(debug_description), freq_in(freq_in), freq_out(freq_out), num_channels(num_channels), current_estimated_freq_in(freq_in), ratio(double(freq_out) / double(freq_in)), expected_delay(expected_delay_seconds * OUTPUT_FREQUENCY) { @@ -62,7 +64,7 @@ void ResamplingQueue::add_input_samples(steady_clock::time_point ts, const float current_estimated_freq_in = (a1.input_samples_received - a0.input_samples_received) / duration(a1.ts - a0.ts).count(); if (!(current_estimated_freq_in >= 0.0)) { fprintf(stderr, "%s: PANIC: Input audio clock going backwards, ignoring.\n", - spec_to_string(device_spec).c_str()); + debug_description.c_str()); current_estimated_freq_in = freq_in; } @@ -170,7 +172,7 @@ bool ResamplingQueue::get_output_samples(steady_clock::time_point ts, float *sam // This should never happen unless delay is set way too low, // or we're dropping a lot of data. fprintf(stderr, "%s: PANIC: Out of input samples to resample, still need %d output samples! (correction factor is %f)\n", - spec_to_string(device_spec).c_str(), int(vresampler.out_count), rcorr); + debug_description.c_str(), int(vresampler.out_count), rcorr); memset(vresampler.out_data, 0, vresampler.out_count * num_channels * sizeof(float)); // Reset the loop filter.