summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-03-13 11:23:23 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-03-15 23:13:53 -0700
commit2c572e2bb1cfa4e225a6a1599f5ecdbcf4bf2dc6 (patch)
treed1006df2ce7b6ce598e7617cdb0fff6bb9575f69 /video
parent9ca1a1b0686510d2b6471b36df9d0eea3fcfa3b3 (diff)
downloadmpv-2c572e2bb1cfa4e225a6a1599f5ecdbcf4bf2dc6.tar.bz2
mpv-2c572e2bb1cfa4e225a6a1599f5ecdbcf4bf2dc6.tar.xz
video: add an option to tune waiting for video timing
Probably mostly useful for the libmpv render API.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/video/out/vo.c b/video/out/vo.c
index ac4fa9a773..fc4630b731 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -147,6 +147,7 @@ struct vo_internal {
int64_t num_successive_vsyncs;
int64_t flip_queue_offset; // queue flip events at most this much in advance
+ int64_t timing_offset; // same (but from options; not VO configured)
int64_t delayed_count;
int64_t drop_count;
@@ -212,11 +213,23 @@ static void dispatch_wakeup_cb(void *ptr)
vo_wakeup(vo);
}
+// Initialize or update options from vo->opts
+static void read_opts(struct vo *vo)
+{
+ struct vo_internal *in = vo->in;
+
+ pthread_mutex_lock(&in->lock);
+ in->timing_offset = (uint64_t)(vo->opts->timing_offset * 1e6);
+ pthread_mutex_unlock(&in->lock);
+}
+
static void update_opts(void *p)
{
struct vo *vo = p;
if (m_config_cache_update(vo->opts_cache)) {
+ read_opts(vo);
+
// "Legacy" update of video position related options.
if (vo->driver->control)
vo->driver->control(vo, VOCTRL_SET_PANSCAN, NULL);
@@ -728,8 +741,9 @@ bool vo_is_ready_for_frame(struct vo *vo, int64_t next_pts)
if (r && next_pts >= 0) {
// Don't show the frame too early - it would basically freeze the
// display by disallowing OSD redrawing or VO interaction.
- // Actually render the frame at earliest 50ms before target time.
- next_pts -= (uint64_t)(0.050 * 1e6);
+ // Actually render the frame at earliest the given offset before target
+ // time.
+ next_pts -= in->timing_offset;
next_pts -= in->flip_queue_offset;
int64_t now = mp_time_us();
if (next_pts > now)
@@ -1003,6 +1017,7 @@ static void *vo_thread(void *ptr)
if (r < 0)
return NULL;
+ read_opts(vo);
update_display_fps(vo);
vo_event(vo, VO_EVENT_WIN_STATE);