Skip to content

Commit

Permalink
set correct display-fps value
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Nov 26, 2023
1 parent c76df02 commit 3910dc9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Player {
virtual GLAddrLoadFunc GetGLAddrFunc() = 0;
virtual std::string GetClipboardString() = 0;
virtual void GetMonitorSize(int *w, int *h) = 0;
virtual int GetMonitorRefreshRate() = 0;
virtual void GetFramebufferSize(int *w, int *h) = 0;
virtual void MakeContextCurrent() = 0;
virtual void DeleteContext() = 0;
Expand Down
1 change: 1 addition & 0 deletions include/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Window : Player {
GLAddrLoadFunc GetGLAddrFunc() override;
std::string GetClipboardString() override;
void GetMonitorSize(int *w, int *h) override;
int GetMonitorRefreshRate() override;
void GetFramebufferSize(int *w, int *h) override;
void MakeContextCurrent() override;
void DeleteContext() override;
Expand Down
4 changes: 4 additions & 0 deletions source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ bool Player::init(std::map<std::string, std::string> &options) {
mpv->option("osd-playing-msg", "${media-title}");
mpv->option("screenshot-directory", "~~desktop/");

// override-display-fps is renamed to display-fps-override in mpv 0.37.0
mpv->option<int64_t, MPV_FORMAT_INT64>("override-display-fps", GetMonitorRefreshRate());
mpv->option<int64_t, MPV_FORMAT_INT64>("display-fps-override", GetMonitorRefreshRate());

if (!config->Data.Mpv.UseConfig) {
writeMpvConf();
mpv->option("osc", "no");
Expand Down
5 changes: 5 additions & 0 deletions source/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ void Window::GetMonitorSize(int* w, int* h) {
*h = mode->height;
}

int Window::GetMonitorRefreshRate() {
const GLFWvidmode* mode = glfwGetVideoMode(getMonitor(window));
return mode->refreshRate;
}

void Window::GetFramebufferSize(int* w, int* h) { glfwGetFramebufferSize(window, w, h); }

void Window::MakeContextCurrent() { glfwMakeContextCurrent(window); }
Expand Down

0 comments on commit 3910dc9

Please sign in to comment.