player: less naive rounding

This commit is contained in:
wm4 2015-11-11 19:52:35 +01:00
parent b7398cbdd8
commit 7c4fe02d01
1 changed files with 1 additions and 1 deletions

View File

@ -1004,7 +1004,7 @@ static void handle_display_sync_frame(struct MPContext *mpctx,
// We use the speed-adjusted (i.e. real) frame duration for this.
double frame_duration = adjusted_duration / mpctx->speed_factor_v;
double ratio = (frame_duration + mpctx->display_sync_error) / vsync;
int num_vsyncs = MPMAX(floor(ratio + 0.5), 0);
int num_vsyncs = MPMAX(lrint(ratio), 0);
double prev_error = mpctx->display_sync_error;
mpctx->display_sync_error += frame_duration - num_vsyncs * vsync;
frame->vsync_offset = mpctx->display_sync_error * 1e6;