Show frames at correct time
This commit is contained in:
parent
b3689dd693
commit
8eface2200
1 changed files with 11 additions and 11 deletions
22
src/main.rs
22
src/main.rs
|
|
@ -298,20 +298,20 @@ impl Application for App {
|
||||||
Message::Tick(frame_time) => {
|
Message::Tick(frame_time) => {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
let video_frame_opt = {
|
let mut video_frame_opt = None;
|
||||||
|
{
|
||||||
let mut video_frames = self.flags.video_frames_lock.lock().unwrap();
|
let mut video_frames = self.flags.video_frames_lock.lock().unwrap();
|
||||||
//TODO: show frames at desired presentation time instead of clearing
|
if let Some(video_frame) = video_frames.pop_front() {
|
||||||
let mut video_frame_opt = video_frames.pop_front();
|
if video_frame.1.unwrap_or(frame_time) <= frame_time {
|
||||||
while video_frames.len() >= 4 {
|
// Frame is ready to be shown
|
||||||
if let Some(extra_frame) = video_frames.pop_front() {
|
video_frame_opt = Some(video_frame)
|
||||||
if let Some(old_frame) = video_frame_opt {
|
} else {
|
||||||
log::warn!("skipping video frame {:?}", old_frame.0.pts());
|
// Put frame back
|
||||||
}
|
video_frames.push_front(video_frame);
|
||||||
video_frame_opt = Some(extra_frame);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
video_frame_opt
|
}
|
||||||
};
|
|
||||||
match video_frame_opt {
|
match video_frame_opt {
|
||||||
Some(video_frame) => {
|
Some(video_frame) => {
|
||||||
let pts = video_frame.0.pts();
|
let pts = video_frame.0.pts();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue