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.
This commit is contained in:
wm4 2018-03-13 12:34:26 +01:00 committed by Kevin Mitchell
parent 2c572e2bb1
commit e42a194062
4 changed files with 27 additions and 31 deletions

View File

@ -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),

View File

@ -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;

View File

@ -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;
}
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,

View File

@ -163,6 +163,7 @@ struct vo_internal {
uint64_t current_frame_id;
double display_fps;
double reported_display_fps;
int opt_framedrop;
};
@ -533,17 +534,23 @@ 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);
in->reported_display_fps = fps;
}
double display_fps = vo->opts->override_display_fps;
if (display_fps <= 0)
display_fps = in->reported_display_fps;
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
@ -551,9 +558,6 @@ static void update_display_fps(struct vo *vo)
wakeup_core(vo);
}
in->nominal_vsync_interval = in->display_fps > 0 ? 1e6 / in->display_fps : 0;
in->vsync_interval = MPMAX(in->nominal_vsync_interval, 1);
}
pthread_mutex_unlock(&in->lock);
}