From e42a194062cb29e538f19d12902c1610c1b30aef Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 13 Mar 2018 12:34:26 +0100 Subject: vo: move display-fps internal option value to VO opts Removes the awkward notification through VO_EVENT_WIN_STATE. Unfortunately, some awkwardness remains in mp_property_display_fps(), because the property has conflicting semantics with the option. --- options/options.c | 3 +-- options/options.h | 2 +- player/command.c | 15 ++++----------- video/out/vo.c | 32 ++++++++++++++++++-------------- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/options/options.c b/options/options.c index 7c7a30ed27..a2322e7bb1 100644 --- a/options/options.c +++ b/options/options.c @@ -139,6 +139,7 @@ static const m_option_t mp_vo_opt_list[] = { OPT_FLAG("keepaspect-window", keepaspect_window, 0), OPT_FLAG("hidpi-window-scale", hidpi_window_scale, 0), OPT_FLAG("native-fs", native_fs, 0), + OPT_DOUBLE("display-fps", override_display_fps, M_OPT_MIN, .min = 0), OPT_DOUBLERANGE("video-timing-offset", timing_offset, 0, 0.0, 1.0), #if HAVE_X11 OPT_CHOICE("x11-netwm", x11_netwm, 0, @@ -612,8 +613,6 @@ const m_option_t mp_opts[] = { {"decoder+vo", 3})), OPT_FLAG("video-latency-hacks", video_latency_hacks, 0), - OPT_DOUBLE("display-fps", frame_drop_fps, M_OPT_MIN, .min = 0), - OPT_FLAG("untimed", untimed, 0), OPT_STRING("stream-dump", stream_dump, M_OPT_FILE), diff --git a/options/options.h b/options/options.h index 303b2e5761..ac852b6484 100644 --- a/options/options.h +++ b/options/options.h @@ -50,6 +50,7 @@ typedef struct mp_vo_opts { char *mmcss_profile; + double override_display_fps; double timing_offset; // vo_drm @@ -224,7 +225,6 @@ typedef struct MPOpts { int autosync; int frame_dropping; int video_latency_hacks; - double frame_drop_fps; int term_osd; int term_osd_bar; char *term_osd_bar_chars; diff --git a/player/command.c b/player/command.c index 67cc1db250..628dc98a34 100644 --- a/player/command.c +++ b/player/command.c @@ -2724,17 +2724,10 @@ static int mp_property_display_fps(void *ctx, struct m_property *prop, int action, void *arg) { MPContext *mpctx = ctx; - double fps = mpctx->opts->frame_drop_fps; - struct vo *vo = mpctx->video_out; - if (vo) - fps = vo_get_display_fps(vo); - if (action == M_PROPERTY_SET) { - int ret = mp_property_generic_option(mpctx, prop, action, arg); - if (vo) - vo_event(vo, VO_EVENT_WIN_STATE); - return ret; - } - return m_property_double_ro(action, arg, fps); + double fps = mpctx->video_out ? vo_get_display_fps(mpctx->video_out) : 0; + if (fps > 0 && action != M_PROPERTY_SET) + return m_property_double_ro(action, arg, fps); + return mp_property_generic_option(mpctx, prop, action, arg); } static int mp_property_framedrop(void *ctx, struct m_property *prop, diff --git a/video/out/vo.c b/video/out/vo.c index fc4630b731..7db43eaa44 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -163,6 +163,7 @@ struct vo_internal { uint64_t current_frame_id; double display_fps; + double reported_display_fps; int opt_framedrop; }; @@ -533,27 +534,30 @@ static void update_display_fps(struct vo *vo) mp_read_option_raw(vo->global, "framedrop", &m_option_type_choice, &in->opt_framedrop); - double display_fps; - mp_read_option_raw(vo->global, "display-fps", &m_option_type_double, - &display_fps); - - if (display_fps <= 0) - vo->driver->control(vo, VOCTRL_GET_DISPLAY_FPS, &display_fps); + double fps = 0; + vo->driver->control(vo, VOCTRL_GET_DISPLAY_FPS, &fps); pthread_mutex_lock(&in->lock); - if (in->display_fps != display_fps) { - in->display_fps = display_fps; - MP_VERBOSE(vo, "Assuming %f FPS for display sync.\n", display_fps); + in->reported_display_fps = fps; + } - // make sure to update the player - in->queued_events |= VO_EVENT_WIN_STATE; - wakeup_core(vo); - } + double display_fps = vo->opts->override_display_fps; + if (display_fps <= 0) + display_fps = in->reported_display_fps; - in->nominal_vsync_interval = in->display_fps > 0 ? 1e6 / in->display_fps : 0; + if (in->display_fps != display_fps) { + in->nominal_vsync_interval = display_fps > 0 ? 1e6 / display_fps : 0; in->vsync_interval = MPMAX(in->nominal_vsync_interval, 1); + in->display_fps = display_fps; + + MP_VERBOSE(vo, "Assuming %f FPS for display sync.\n", display_fps); + + // make sure to update the player + in->queued_events |= VO_EVENT_WIN_STATE; + wakeup_core(vo); } + pthread_mutex_unlock(&in->lock); } -- cgit v1.2.3