From 946c6bcea17febf0bfc18891ddc6341b43c87136 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Schieli?= <cschieli@gmail.com>
Date: Sat, 24 May 2014 17:42:22 +0200
Subject: Force refresh of xf86VidMode current modeline
After changing the mode with XRRSetScreenConfigAndRate, the modeline returned
by XF86VidModeGetModeLine is wrong until XRRGetScreenInfo is called (at
least for X.Org 1.14.5 and 1.15.0 with Intel video driver).
DisplayResX::SwitchToVideo first calls XRRGetScreenInfo, then calls
XRRSetScreenConfigAndRate. This leads to XF86VidModeGetModeLine always
returning the previous modeline instead of the current one.
This was causing juddering in some cases, because the refreshrate used
in MythPlayer for initializing avsync_predictor is obtained from
XF86VidModeGetModeLine.
For example the following scenario was causing me consistent juddering
every second:
The display has modelines for 24 Hz, 50 Hz and 60 Hz modes, and the desktop
mode is 60 Hz.
I first play a 23.976 fps video. The display switches to 24 Hz mode, but the
refreshrate used by avsync_predictor is set to 60. This does not cause
noticeable judderng. Then, I play a 25 fps video. The display switches to
50 Hz mode, and the refreshrate is set to 24 (the previous one). Every second
the avsync_predictor kicks in and drops some frames.
This patch fixes this issue by calling XRRGetScreenInfo after the mode is
changed by XRRSetScreenConfigAndRate.
---
mythtv/libs/libmythui/DisplayResX.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mythtv/libs/libmythui/DisplayResX.cpp b/mythtv/libs/libmythui/DisplayResX.cpp
index e1326b4..6808e38 100644
|
a
|
b
|
bool DisplayResX::SwitchToVideoMode(int width, int height, double desired_rate)
|
| 87 | 87 | CurrentTime); |
| 88 | 88 | |
| 89 | 89 | XRRFreeScreenConfigInfo(cfg); |
| | 90 | |
| | 91 | // Force refresh of xf86VidMode current modeline |
| | 92 | cfg = XRRGetScreenInfo(display->GetDisplay(), root); |
| | 93 | if (cfg) |
| | 94 | XRRFreeScreenConfigInfo(cfg); |
| | 95 | |
| 90 | 96 | delete display; |
| 91 | 97 | |
| 92 | 98 | if (RRSetConfigSuccess != status) |