summaryrefslogtreecommitdiffstats
path: root/video/out/vo.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/vo.c')
-rw-r--r--video/out/vo.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/video/out/vo.c b/video/out/vo.c
index fe53102577..3b7d9aa9a1 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -146,9 +146,10 @@ struct vo_internal {
int64_t frame_pts; // realtime of intended display
int64_t frame_duration; // realtime frame duration (for framedrop)
- int64_t vsync_interval;
+ double display_fps;
// --- The following fields can be accessed from the VO thread only
+ int64_t vsync_interval;
int64_t vsync_interval_approx;
int64_t last_flip;
char *window_title;
@@ -232,7 +233,6 @@ static struct vo *vo_create(bool probing, struct mpv_global *global,
talloc_steal(vo, log);
*vo->in = (struct vo_internal) {
.dispatch = mp_dispatch_create(vo),
- .internal_events = VO_EVENT_WIN_STATE,
};
mp_make_wakeup_pipe(vo->in->wakeup_pipe);
mp_dispatch_set_wakeup_fn(vo->in->dispatch, dispatch_wakeup_cb, vo);
@@ -312,18 +312,17 @@ static void update_display_fps(struct vo *vo)
pthread_mutex_unlock(&in->lock);
- double display_fps = 1e6; // assume infinite if unset
+ double display_fps = 0;
if (vo->global->opts->frame_drop_fps > 0) {
display_fps = vo->global->opts->frame_drop_fps;
} else {
vo->driver->control(vo, VOCTRL_GET_DISPLAY_FPS, &display_fps);
}
- int64_t n_interval = MPMAX((int64_t)(1e6 / display_fps), 1);
pthread_mutex_lock(&in->lock);
- if (vo->in->vsync_interval != n_interval)
- MP_VERBOSE(vo, "Assuming %f FPS for framedrop.\n", display_fps);
- vo->in->vsync_interval = n_interval;
+
+ in->display_fps = display_fps;
+ MP_VERBOSE(vo, "Assuming %f FPS for framedrop.\n", display_fps);
}
pthread_mutex_unlock(&in->lock);
}
@@ -567,6 +566,9 @@ static bool render_frame(struct vo *vo)
pthread_mutex_lock(&in->lock);
+ vo->in->vsync_interval = in->display_fps > 0 ? 1e6 / in->display_fps : 0;
+ vo->in->vsync_interval = MPMAX(vo->in->vsync_interval, 1);
+
int64_t pts = in->frame_pts;
int64_t duration = in->frame_duration;
struct mp_image *img = in->frame_queued;
@@ -731,6 +733,9 @@ static void *vo_thread(void *ptr)
if (r < 0)
return NULL;
+ update_display_fps(vo);
+ vo_event(vo, VO_WIN_STATE_MINIMIZED);
+
while (1) {
mp_dispatch_queue_process(vo->in->dispatch, 0);
if (in->terminate)
@@ -908,6 +913,7 @@ void vo_set_flip_queue_params(struct vo *vo, int64_t offset_us, bool vsync_timed
pthread_mutex_unlock(&in->lock);
}
+// to be called from the VO thread only
int64_t vo_get_vsync_interval(struct vo *vo)
{
struct vo_internal *in = vo->in;
@@ -917,6 +923,15 @@ int64_t vo_get_vsync_interval(struct vo *vo)
return res;
}
+double vo_get_display_fps(struct vo *vo)
+{
+ struct vo_internal *in = vo->in;
+ pthread_mutex_lock(&in->lock);
+ double res = vo->in->display_fps;
+ pthread_mutex_unlock(&in->lock);
+ return res;
+}
+
// Set specific event flags, and wakeup the playback core if needed.
// vo_query_and_reset_events() can retrieve the events again.
void vo_event(struct vo *vo, int event)