]> git.sesse.net Git - nageru/commitdiff
Better diagnostics when the time code is changing.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 17 Nov 2015 18:22:14 +0000 (19:22 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 17 Nov 2015 18:22:14 +0000 (19:22 +0100)
mixer.cpp

index 1d1a60cdea8f96576d202730bfdf763f7deb0712..3fd264615dbc0aab32bbf8c82c4e970c2fb07751 100644 (file)
--- 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<float> audio;
@@ -257,8 +256,8 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
                unique_lock<mutex> 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);