]> git.sesse.net Git - bmusb/commitdiff
Fix issues with the queue locking up when there is no signal.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 12 Oct 2015 22:09:40 +0000 (00:09 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 12 Oct 2015 22:09:40 +0000 (00:09 +0200)
bmusb.cpp

index ac02852cb2d4af37fd64f5a7d2454cc1d54a9f98..fbf31dd95177c8480dca45c6579ae696b126b7d2 100644 (file)
--- a/bmusb.cpp
+++ b/bmusb.cpp
@@ -198,6 +198,21 @@ void BMUSBCapture::start_new_frame(const uint8_t *start)
        uint16_t timecode = (start[1] << 8) | start[0];
 
        if (current_video_frame.len > 0) {
+               // If format is 0x0800 (no signal), add a fake (empty) audio
+               // frame to get it out of the queue.
+               // TODO: Figure out if there are other formats that come with
+               // no audio, and treat them the same.
+               if (format == 0x0800) {
+                       FrameAllocator::Frame fake_audio_frame = audio_frame_allocator->alloc_frame();
+                       if (fake_audio_frame.data == nullptr) {
+                               // Oh well, it's just a no-signal frame anyway.
+                               printf("Couldn't allocate fake audio frame, also dropping no-signal video frame.\n");
+                               current_video_frame.owner->release_frame(current_video_frame);
+                               current_video_frame = video_frame_allocator->alloc_frame();
+                               return;
+                       }
+                       queue_frame(format, timecode, fake_audio_frame, &pending_audio_frames);
+               }
                //dump_frame();
                queue_frame(format, timecode, current_video_frame, &pending_video_frames);
        }