]> git.sesse.net Git - nageru/commitdiff
Drop frames if there are clearly too many samples (typically happening at the start).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 11 Oct 2015 22:19:15 +0000 (00:19 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 11 Oct 2015 22:19:15 +0000 (00:19 +0200)
mixer.cpp

index 1f83215bf05152c52fd1bd2dee263b879651bf5d..0c68bb1b58d30d0215400b7d9e354afe58668817 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -168,14 +168,17 @@ void Mixer::bm_frame(int card_index, uint16_t timecode,
 
        if (video_frame.len - video_offset != 1280 * 750 * 2) {
                printf("dropping frame with wrong length (%ld)\n", video_frame.len - video_offset);
-               FILE *fp = fopen("frame.raw", "wb");
-               fwrite(video_frame.data, video_frame.len, 1, fp);
-               fclose(fp);
-               //exit(1);
                card->usb->get_video_frame_allocator()->release_frame(video_frame);
                card->usb->get_audio_frame_allocator()->release_frame(audio_frame);
                return;
        }
+       if (audio_frame.len - audio_offset > 30000) {
+               printf("dropping frame with implausible audio length (%ld)\n", audio_frame.len - audio_offset);
+               card->usb->get_video_frame_allocator()->release_frame(video_frame);
+               card->usb->get_audio_frame_allocator()->release_frame(audio_frame);
+               return;
+       }
+
        {
                // Wait until the previous frame was consumed.
                std::unique_lock<std::mutex> lock(bmusb_mutex);