unique_lock<mutex> lock(queue_lock);
queues_not_empty.wait(lock, [this]{ return dequeue_thread_should_quit || (!pending_video_frames.empty() && !pending_audio_frames.empty()); });
+ if (dequeue_thread_should_quit) break;
+
uint16_t video_timecode = pending_video_frames.front().timecode;
uint16_t audio_timecode = pending_audio_frames.front().timecode;
if (uint16_less_than_with_wraparound(video_timecode, audio_timecode)) {