Skip to content

Commit

Permalink
Gregorio Gervasio's fix preventing unncessary mode changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Gardiner committed Apr 12, 2013
1 parent 69cd78b commit adeca4c
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions mythtv/libs/libmythui/DisplayRes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ bool DisplayRes::Initialize(void)
double tAspect = 0.0;
double tRate = 0.0;

m_last.Init();
m_curMode = GUI;
m_pixelAspectRatio = 1.0;

// Initialise DESKTOP mode
Expand All @@ -63,6 +61,9 @@ bool DisplayRes::Initialize(void)
LOG(VB_GENERAL, LOG_NOTICE, QString("Desktop video mode: %1x%2 %3 Hz")
.arg(tW).arg(tH).arg(tRate, 0, 'f', 3));

m_last = m_mode[DESKTOP];
m_curMode = DESKTOP;

// Initialize GUI mode
m_mode[GUI].Init();
tW = tH = 0;
Expand Down Expand Up @@ -146,8 +147,11 @@ bool DisplayRes::SwitchToVideo(int iwidth, int iheight, double frate)

// need to change video mode?
DisplayResScreen::FindBestMatch(GetVideoModes(), next, target_rate);
next.ClearRefreshRates();
next.AddRefreshRate(target_rate);

bool chg = !(next == m_last) ||
bool chg = !(next.Width() == m_last.Width()) ||
!(next.Height() == m_last.Height()) ||
!(DisplayResScreen::compare_rates(m_last.RefreshRate(),
target_rate));

Expand Down Expand Up @@ -182,14 +186,22 @@ bool DisplayRes::SwitchToGUI(tmode next_mode)
{
DisplayResScreen next = m_mode[next_mode];

// If GuiVidModeRefreshRate is 0, assume last refresh rate is good enough.
double target_rate;
if ((int) next.RefreshRate() == 0)
target_rate = m_last.RefreshRate();
else
target_rate = next.RefreshRate();

// need to change video mode?
double target_rate = next.RefreshRate();
DisplayResScreen::FindBestMatch(GetVideoModes(), next, target_rate);
// If GuiVidModeRefreshRate is 0, assume any refresh rate is good enough.
bool chg = (!(next == m_last) ||
(((int) next.RefreshRate()) != 0
&& !(DisplayResScreen::compare_rates(m_last.RefreshRate(),
target_rate))));
next.ClearRefreshRates();
next.AddRefreshRate(target_rate);

bool chg = !(next.Width() == m_last.Width()) ||
!(next.Height() == m_last.Height()) ||
!(DisplayResScreen::compare_rates(m_last.RefreshRate(),
target_rate));

LOG(VB_GENERAL, LOG_INFO, QString("Trying %1x%2 %3 Hz")
.arg(next.Width()).arg(next.Height()).arg(target_rate, 0, 'f', 3));
Expand All @@ -199,7 +211,7 @@ bool DisplayRes::SwitchToGUI(tmode next_mode)
LOG(VB_GENERAL, LOG_ERR,
QString("SwitchToGUI: xrandr failed for %1x%2 %3 Hz")
.arg(next.Width()).arg(next.Height())
.arg(next.RefreshRate(), 0, 'f', 3));
.arg(target_rate, 0, 'f', 3));
return false;
}

Expand Down

0 comments on commit adeca4c

Please sign in to comment.