Browse Source

DisplayManager: add refreshrate.avoid_25hz_30hz setting

This is experimental and follows the discussion in #415.
Vincent Lang 8 years ago
parent
commit
1b91605e8f
2 changed files with 20 additions and 0 deletions
  1. 5 0
      resources/settings/settings_description.json
  2. 15 0
      src/display/DisplayManager.cpp

+ 5 - 0
resources/settings/settings_description.json

@@ -224,6 +224,11 @@
         "default": 3,
         "hidden": true
       },
+      {
+        "value": "refreshrate.avoid_25hz_30hz",
+        "default": false,
+        "hidden": true
+      },
       {
         "value": "hardwareDecoding",
         "default": [

+ 15 - 0
src/display/DisplayManager.cpp

@@ -9,6 +9,7 @@
 #include "QsLog.h"
 #include "DisplayManager.h"
 #include "math.h"
+#include "settings/SettingsComponent.h"
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 DisplayManager::DisplayManager(QObject* parent) : QObject(parent) {}
@@ -96,6 +97,7 @@ bool DisplayManager::isRateMultipleOf(float refresh, float multiple, bool exact)
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 int DisplayManager::findBestMatch(int display, DMMatchMediaInfo& matchInfo)
 {
+  bool avoid_25_30 = SettingsComponent::Get().value(SETTINGS_SECTION_VIDEO, "refreshrate.avoid_25hz_30hz").toBool();
 
   // Grab current videomode information
   DMVideoModePtr currentVideoMode = getCurrentVideoMode(display);
@@ -112,6 +114,19 @@ int DisplayManager::findBestMatch(int display, DMMatchMediaInfo& matchInfo)
   {
     DMVideoModePtr candidate = modeit.value();
 
+    // avoid switching to 30 fps (prefer a multiple - 60Hz is ideal)
+    // the intention is also to match 30/1.001
+    if ((fabs(candidate->m_refreshRate - 30.0) < 0.5) ||
+        (fabs(candidate->m_refreshRate - 25.0) < 0.5))
+    {
+      if (avoid_25_30)
+      {
+        QLOG_INFO() << "DisplayManager RefreshMatch : skipping rate " << candidate->m_refreshRate << "as requested";
+        modeit++;
+        continue;
+      }
+    }
+
     weights[candidate->m_id] = DMVideoModeWeightPtr(new DMVideoModeWeight);
     weights[candidate->m_id]->m_mode = candidate;
     weights[candidate->m_id]->m_weight = 0;