1
0
Fork 0

[Backend+Cmake] Improved newer MPV version checking.

This commit is contained in:
NamedKitten 2018-11-26 19:03:37 +00:00
parent b2afcc99f5
commit 1f17f32b07
4 changed files with 30 additions and 33 deletions

View file

@ -21,15 +21,20 @@ pkg_check_modules(MPV REQUIRED mpv)
pkg_check_modules(X11 REQUIRED x11)
pkg_check_modules(Xext REQUIRED xext)
set(SOURCES
src/main.cpp
src/MpvPlayerBackend.cpp
src/DirectMpvPlayerBackend.cpp
src/utils.cpp
src/enums.hpp
)
if(MPV_VERSION VERSION_GREATER_EQUAL "1.28.0")
set(SOURCES ${SOURCES} src/MpvPlayerBackend.cpp)
else()
add_definitions(-DDISABLE_MpvPlayerBackend)
endif(MPV_VERSION VERSION_GREATER_EQUAL "1.28.0")
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)

View file

@ -4,8 +4,6 @@
#include "MpvPlayerBackend.h"
#ifndef DISABLE_MpvPlayerBackend
#include "utils.hpp"
#include <QApplication>
#include <QOpenGLContext>
@ -584,4 +582,3 @@ MpvPlayerBackend::createRenderer() const
return new MpvRenderer(const_cast<MpvPlayerBackend*>(this));
}
#endif

View file

@ -1,13 +1,8 @@
#include <mpv/client.h>
#include <mpv/qthelper.hpp>
#if MPV_CLIENT_API_VERSION <= MPV_MAKE_VERSION(1, 27)
#define DISABLE_MpvPlayerBackend
#endif
#ifndef MpvPlayerBackend_H
#define MpvPlayerBackend_H
#include <mpv/client.h>
#include <mpv/qthelper.hpp>
#include <mpv/render_gl.h>
@ -30,9 +25,7 @@ class MpvPlayerBackend
Q_OBJECT
mpv_handle* mpv;
#ifndef DISABLE_MpvPlayerBackend
mpv_render_context* mpv_gl;
#endif
bool onTop = false;
QString totalDurationString;

View file

@ -3,7 +3,9 @@
#endif
#include "DirectMpvPlayerBackend.h"
#ifndef DISABLE_MpvPlayerBackend
#include "MpvPlayerBackend.h"
#endif
#include "enums.hpp"
#include "utils.hpp"
@ -116,10 +118,11 @@ main(int argc, char* argv[])
for (int i = 1; i < argc; ++i) {
if (!qstrcmp(argv[i], "--update")) {
Utils::updateAppImage();
} else if (!qstrcmp(argv[i], "--backend=mpv") || backendSetting == "mpv") {
}
else if (!qstrcmp(argv[i], "--backend=mpv") || backendSetting == "mpv") {
backend = Enums::Backends::MpvBackend;
} else if (!qstrcmp(argv[i], "--backend=direct-mpv") ||
backendSetting == "direct-mpv") {
}
else if (!qstrcmp(argv[i], "--backend=direct-mpv") || backendSetting == "direct-mpv") {
backend = Enums::Backends::DirectMpvBackend;
}
}
@ -146,8 +149,7 @@ main(int argc, char* argv[])
#ifndef DISABLE_MpvPlayerBackend
qmlRegisterType<MpvPlayerBackend>("player", 1, 0, "PlayerBackend");
#else
qDebug() << "Normal MPV backend not available, resetting backend option "
"to blank.";
qDebug() << "Normal MPV backend not available, resetting backend option to blank.";
settings.setValue("Backend/backend", "direct-mpv");
app.exit();
#endif