diff --git a/src/main.rs b/src/main.rs index 4bee0ea..cbfc567 100644 --- a/src/main.rs +++ b/src/main.rs @@ -298,16 +298,21 @@ impl Application for App { Message::Tick(frame_time) => { let start = Instant::now(); - let mut video_frame_opt = None; + let mut video_frame_opt: Option = None; { let mut video_frames = self.flags.video_frames_lock.lock().unwrap(); - if let Some(video_frame) = video_frames.pop_front() { + while let Some(video_frame) = video_frames.pop_front() { if video_frame.1.unwrap_or(frame_time) <= frame_time { + if let Some(old_frame) = video_frame_opt { + //TODO: log this outside of locking video_frames_lock? + log::warn!("skipping video frame {:?}", old_frame.0.pts()); + } // Frame is ready to be shown video_frame_opt = Some(video_frame) } else { - // Put frame back + // Put frame back and exit loop video_frames.push_front(video_frame); + break; } } } diff --git a/src/player.rs b/src/player.rs index 8d03be0..c80ce82 100644 --- a/src/player.rs +++ b/src/player.rs @@ -233,8 +233,7 @@ fn ffmpeg_thread>( } })?; - // This is a sync channel to reduce skipping - let (gpu_frame_tx, gpu_frame_rx) = mpsc::sync_channel::<(Video, Option)>(1); + let (gpu_frame_tx, gpu_frame_rx) = mpsc::channel::<(Video, Option)>(); thread::Builder::new() .name("video_map_gpu_cpu".to_string()) .spawn(move || {