From e59f1669da7a0a09c51cfe028c47ed18e4d4ac21 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 17 Nov 2015 19:22:14 +0100 Subject: [PATCH] Better diagnostics when the time code is changing. --- mixer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mixer.cpp b/mixer.cpp index 1d1a60c..3fd2646 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -245,7 +245,6 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode, if (card->last_timecode != -1) { dropped_frames = unwrap_timecode(timecode, card->last_timecode) - card->last_timecode - 1; } - card->last_timecode = timecode; // Convert the audio to stereo fp32 and add it. vector audio; @@ -257,8 +256,8 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode, unique_lock lock(card->audio_mutex); if (dropped_frames > MAX_FPS * 2) { - fprintf(stderr, "Card %d lost more than two seconds (or time code jumping around), resetting resampler\n", - card_index); + fprintf(stderr, "Card %d lost more than two seconds (or time code jumping around; from 0x%04x to 0x%04x), resetting resampler\n", + card_index, card->last_timecode, timecode); card->resampling_queue.reset(new ResamplingQueue(OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2)); } else if (dropped_frames > 0) { // Insert silence as needed. (The number of samples could be nonintegral, @@ -279,6 +278,8 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode, card->next_local_pts = local_pts + frame_length; } + card->last_timecode = timecode; + // Done with the audio, so release it. if (audio_frame.owner) { audio_frame.owner->release_frame(audio_frame); -- 2.39.2