diff options
author | Dudemanguy <random342@airmail.cc> | 2023-11-08 22:08:57 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-11-09 21:31:58 +0000 |
commit | a89ba2c7497ca42f5b7e21144d5bf1a8da193654 (patch) | |
tree | 6a8c5612520dee562c21da3bb6c6f2b5f3dab708 /video/out/vo.c | |
parent | dffaa9cf6b5d9e5c1abf74928153dc615a547895 (diff) | |
download | mpv-a89ba2c7497ca42f5b7e21144d5bf1a8da193654.tar.bz2 mpv-a89ba2c7497ca42f5b7e21144d5bf1a8da193654.tar.xz |
vo: replace some magic numbers with timer macros
Most importantly, the wait_until addition was missed while doing the
unit conversions to nanoseconds which meant mpv woke up roughly every
second since not nearly enough time was added. It was meant to be 1000
seconds (1e9 in microseconds). Use a macro so it's more readable. Also
put some other wild 1e9 calculations inside of a macro as well.
Fixes a899e14bccb667af243f8fce454160e17ae45c2a.
Diffstat (limited to 'video/out/vo.c')
-rw-r--r-- | video/out/vo.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/video/out/vo.c b/video/out/vo.c index 6d06973a47..2296d25448 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -229,7 +229,7 @@ static void read_opts(struct vo *vo) struct vo_internal *in = vo->in; mp_mutex_lock(&in->lock); - in->timing_offset = (uint64_t)(vo->opts->timing_offset * 1e9); + in->timing_offset = (uint64_t)(MP_TIME_S_TO_NS(vo->opts->timing_offset)); mp_mutex_unlock(&in->lock); } @@ -543,7 +543,7 @@ static void update_vsync_timing_after_swap(struct vo *vo, vsync_skip_detection(vo); MP_STATS(vo, "value %f jitter", in->estimated_vsync_jitter); - MP_STATS(vo, "value %f vsync-diff", in->vsync_samples[0] / 1e9); + MP_STATS(vo, "value %f vsync-diff", MP_TIME_NS_TO_S(in->vsync_samples[0])); } // to be called from VO thread only @@ -890,7 +890,7 @@ static bool render_frame(struct vo *vo) in->dropped_frame &= frame->can_drop; // Even if we're hopelessly behind, rather degrade to 10 FPS playback, // instead of just freezing the display forever. - in->dropped_frame &= now - in->prev_vsync < 100 * 1e6; + in->dropped_frame &= now - in->prev_vsync < MP_TIME_MS_TO_NS(100); in->dropped_frame &= in->hasframe_rendered; // Setup parameters for the next time this frame is drawn. ("frame" is the @@ -1066,7 +1066,7 @@ static MP_THREAD_VOID vo_thread(void *ptr) vo->driver->control(vo, VOCTRL_CHECK_EVENTS, NULL); bool working = render_frame(vo); int64_t now = mp_time_ns(); - int64_t wait_until = now + (working ? 0 : (int64_t)1e9); + int64_t wait_until = now + MP_TIME_S_TO_NS(working ? 0 : 1000); mp_mutex_lock(&in->lock); if (in->wakeup_pts) { @@ -1300,7 +1300,7 @@ double vo_get_delay(struct vo *vo) res = 0; } mp_mutex_unlock(&in->lock); - return res ? (res - mp_time_ns()) / 1e9 : 0; + return res ? MP_TIME_NS_TO_S(res - mp_time_ns()) : 0; } void vo_discard_timing_info(struct vo *vo) |