mirror of https://github.com/mpv-player/mpv
vo_drm: refactor getting display fps
Reduces code duplication between OpenGL backend and DRM VO. (The control() for OpenGL backend isn't sufficiently similar to the VO's control() to consider merging it as a whole - I extracted only the FPS code.)
This commit is contained in:
parent
abbc8fc84a
commit
1648ff8a0f
|
@ -215,6 +215,11 @@ void kms_destroy(struct kms *kms)
|
|||
talloc_free(kms);
|
||||
}
|
||||
|
||||
double kms_get_display_fps(const struct kms *kms)
|
||||
{
|
||||
return kms->mode.clock * 1000.0 / kms->mode.htotal / kms->mode.vtotal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// VT switcher ----------------------------------------------------------------
|
||||
|
|
|
@ -49,5 +49,6 @@ void vt_switcher_release(struct vt_switcher *s, void (*handler)(void*), void *us
|
|||
struct kms *kms_create(struct mp_log *log);
|
||||
bool kms_setup(struct kms *kms, const char *device_path, int conn_id, int mode_id);
|
||||
void kms_destroy(struct kms *kms);
|
||||
double kms_get_display_fps(const struct kms *kms);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -370,11 +370,7 @@ static int drm_egl_control(struct MPGLContext *ctx, int *events, int request,
|
|||
struct priv *p = ctx->priv;
|
||||
switch (request) {
|
||||
case VOCTRL_GET_DISPLAY_FPS: {
|
||||
double fps =
|
||||
p->kms->mode.clock
|
||||
* 1000.0
|
||||
/ p->kms->mode.htotal
|
||||
/ p->kms->mode.vtotal;
|
||||
double fps = kms_get_display_fps(p->kms);
|
||||
if (fps <= 0)
|
||||
break;
|
||||
*(double*)arg = fps;
|
||||
|
|
|
@ -482,11 +482,7 @@ static int control(struct vo *vo, uint32_t request, void *arg)
|
|||
reconfig(vo, vo->params);
|
||||
return VO_TRUE;
|
||||
case VOCTRL_GET_DISPLAY_FPS: {
|
||||
double fps =
|
||||
p->kms->mode.clock
|
||||
* 1000.0
|
||||
/ p->kms->mode.htotal
|
||||
/ p->kms->mode.vtotal;
|
||||
double fps = kms_get_display_fps(p->kms);
|
||||
if (fps <= 0)
|
||||
break;
|
||||
*(double*)arg = fps;
|
||||
|
|
Loading…
Reference in New Issue