From: Steinar H. Gunderson Date: Mon, 12 Oct 2015 22:09:40 +0000 (+0200) Subject: Fix issues with the queue locking up when there is no signal. X-Git-Tag: 0.4~53 X-Git-Url: https://git.sesse.net/?p=bmusb;a=commitdiff_plain;h=6fd0f2d883caf80001dc04e324ac4036ae396e06 Fix issues with the queue locking up when there is no signal. --- diff --git a/bmusb.cpp b/bmusb.cpp index ac02852..fbf31dd 100644 --- 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); }