Allow more skipping if video is behind
This commit is contained in:
parent
8eface2200
commit
c726fca224
2 changed files with 9 additions and 5 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -298,16 +298,21 @@ impl Application for App {
|
||||||
Message::Tick(frame_time) => {
|
Message::Tick(frame_time) => {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
let mut video_frame_opt = None;
|
let mut video_frame_opt: Option<VideoFrame> = None;
|
||||||
{
|
{
|
||||||
let mut video_frames = self.flags.video_frames_lock.lock().unwrap();
|
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 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
|
// Frame is ready to be shown
|
||||||
video_frame_opt = Some(video_frame)
|
video_frame_opt = Some(video_frame)
|
||||||
} else {
|
} else {
|
||||||
// Put frame back
|
// Put frame back and exit loop
|
||||||
video_frames.push_front(video_frame);
|
video_frames.push_front(video_frame);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -233,8 +233,7 @@ fn ffmpeg_thread<P: AsRef<Path>>(
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// This is a sync channel to reduce skipping
|
let (gpu_frame_tx, gpu_frame_rx) = mpsc::channel::<(Video, Option<Instant>)>();
|
||||||
let (gpu_frame_tx, gpu_frame_rx) = mpsc::sync_channel::<(Video, Option<Instant>)>(1);
|
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.name("video_map_gpu_cpu".to_string())
|
.name("video_map_gpu_cpu".to_string())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue