From: Steinar H. Gunderson Date: Sat, 7 May 2016 23:59:07 +0000 (+0200) Subject: Make the audio resampler panic message slightly more readable. X-Git-Tag: 1.3.0~16 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c0bf9deb26205bf35758d49f587961f19bdb15b8;hp=ccc0d8f9b40db622ee30e1bd1b07d031b2c8b0e0;p=nageru Make the audio resampler panic message slightly more readable. --- diff --git a/mixer.cpp b/mixer.cpp index fa3a6de..1d71ac8 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -853,9 +853,7 @@ void Mixer::process_audio_one_frame(int64_t frame_pts_int, int num_samples) samples_card.resize(num_samples * 2); { unique_lock lock(cards[card_index].audio_mutex); - if (!cards[card_index].resampling_queue->get_output_samples(double(frame_pts_int) / TIMEBASE, &samples_card[0], num_samples)) { - printf("Card %d reported previous underrun.\n", card_index); - } + cards[card_index].resampling_queue->get_output_samples(double(frame_pts_int) / TIMEBASE, &samples_card[0], num_samples); } if (card_index == selected_audio_card) { samples_out = move(samples_card); diff --git a/resampling_queue.cpp b/resampling_queue.cpp index ab20b41..9e8fb7d 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); @@ -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; } diff --git a/resampling_queue.h b/resampling_queue.h index c085ece..e43e0ea 100644 --- a/resampling_queue.h +++ b/resampling_queue.h @@ -47,7 +47,8 @@ class ResamplingQueue { public: - ResamplingQueue(unsigned freq_in, unsigned freq_out, unsigned num_channels = 2); + // card_num is for debugging outputs only. + ResamplingQueue(unsigned card_num, unsigned freq_in, unsigned freq_out, unsigned num_channels = 2); // Note: pts is always in seconds. void add_input_samples(double pts, const float *samples, ssize_t num_samples); @@ -58,6 +59,7 @@ private: VResampler vresampler; + unsigned card_num; unsigned freq_in, freq_out, num_channels; bool first_input = true, first_output = true;