X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=resampling_queue.cpp;h=62c4413792b2cdba4be07119d692173dc0fb7b7f;hb=f98f6776f3a410c61dbf9fc523f28de7aa7fc154;hp=ab20b410623b348d3fab0b6ff65753f128e1747e;hpb=53aa0a5f3088f2cefae8e75f6986be3b8700c9d5;p=nageru diff --git a/resampling_queue.cpp b/resampling_queue.cpp index ab20b41..62c4413 100644 --- a/resampling_queue.cpp +++ b/resampling_queue.cpp @@ -26,8 +26,8 @@ #include #include -ResamplingQueue::ResamplingQueue(unsigned freq_in, unsigned freq_out, unsigned num_channels) - : freq_in(freq_in), freq_out(freq_out), num_channels(num_channels), +ResamplingQueue::ResamplingQueue(unsigned card_num, unsigned freq_in, unsigned freq_out, unsigned num_channels) + : card_num(card_num), freq_in(freq_in), freq_out(freq_out), num_channels(num_channels), ratio(double(freq_out) / double(freq_in)) { vresampler.setup(ratio, num_channels, /*hlen=*/32); @@ -95,8 +95,8 @@ bool ResamplingQueue::get_output_samples(double pts, float *samples, ssize_t num } total_consumed_samples -= delay_samples_to_add; // Equivalent to increasing k_a0 and k_a1. err += delay_samples_to_add; - first_output = false; } + first_output = false; // Compute loop filter coefficients for the two filters. We need to compute them // every time, since they depend on the number of samples the user asked for. @@ -129,8 +129,8 @@ bool ResamplingQueue::get_output_samples(double pts, float *samples, ssize_t num if (buffer.empty()) { // This should never happen unless delay is set way too low, // or we're dropping a lot of data. - fprintf(stderr, "PANIC: Out of input samples to resample, still need %d output samples!\n", - int(vresampler.out_count)); + 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 * 2 * sizeof(float)); return false; } @@ -147,7 +147,8 @@ bool ResamplingQueue::get_output_samples(double pts, float *samples, ssize_t num vresampler.inp_count = num_input_samples; vresampler.inp_data = inbuf; - vresampler.process(); + int err = vresampler.process(); + assert(err == 0); size_t consumed_samples = num_input_samples - vresampler.inp_count; total_consumed_samples += consumed_samples;