mirror of
https://github.com/mpv-player/mpv
synced 2024-12-22 14:52:43 +00:00
vo: define <= 0 as unsupported for last_queue_display_time
Also sanitize vsync values, just in case.
This commit is contained in:
parent
ed8b3cef5f
commit
0a799547aa
@ -513,6 +513,14 @@ static void update_vsync_timing_after_swap(struct vo *vo,
|
||||
if (in->num_successive_vsyncs <= 2)
|
||||
return;
|
||||
|
||||
if (vsync_time <= 0 || vsync_time <= prev_vsync) {
|
||||
in->prev_vsync = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (prev_vsync <= 0)
|
||||
return;
|
||||
|
||||
if (in->num_vsync_samples >= MAX_VSYNC_SAMPLES)
|
||||
in->num_vsync_samples -= 1;
|
||||
MP_TARRAY_INSERT_AT(in, in->vsync_samples, in->num_vsync_samples, 0,
|
||||
@ -526,8 +534,10 @@ static void update_vsync_timing_after_swap(struct vo *vo,
|
||||
}
|
||||
|
||||
double avg = 0;
|
||||
for (int n = 0; n < in->num_vsync_samples; n++)
|
||||
for (int n = 0; n < in->num_vsync_samples; n++) {
|
||||
assert(in->vsync_samples[n] > 0);
|
||||
avg += in->vsync_samples[n];
|
||||
}
|
||||
in->estimated_vsync_interval = avg / in->num_vsync_samples;
|
||||
in->estimated_vsync_jitter =
|
||||
vsync_stddef(vo, in->vsync_interval) / in->vsync_interval;
|
||||
@ -948,7 +958,7 @@ static bool render_frame(struct vo *vo)
|
||||
vo->driver->get_vsync(vo, &vsync);
|
||||
|
||||
// Make up some crap if presentation feedback is missing.
|
||||
if (vsync.last_queue_display_time < 0)
|
||||
if (vsync.last_queue_display_time <= 0)
|
||||
vsync.last_queue_display_time = mp_time_ns();
|
||||
|
||||
stats_time_end(in->stats, "video-flip");
|
||||
|
@ -262,7 +262,7 @@ struct vo_frame {
|
||||
struct vo_vsync_info {
|
||||
// mp_time_ns() timestamp at which the last queued frame will likely be
|
||||
// displayed (this is in the future, unless the frame is instantly output).
|
||||
// -1 if unset or unsupported.
|
||||
// 0 or lower if unset or unsupported.
|
||||
// This implies the latency of the output.
|
||||
int64_t last_queue_display_time;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user