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(X11 REQUIRED x11)
pkg_check_modules(Xext REQUIRED xext) pkg_check_modules(Xext REQUIRED xext)
set(SOURCES set(SOURCES
src/main.cpp src/main.cpp
src/MpvPlayerBackend.cpp
src/DirectMpvPlayerBackend.cpp src/DirectMpvPlayerBackend.cpp
src/utils.cpp src/utils.cpp
src/enums.hpp 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) find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND) if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)

View file

@ -4,8 +4,6 @@
#include "MpvPlayerBackend.h" #include "MpvPlayerBackend.h"
#ifndef DISABLE_MpvPlayerBackend
#include "utils.hpp" #include "utils.hpp"
#include <QApplication> #include <QApplication>
#include <QOpenGLContext> #include <QOpenGLContext>
@ -584,4 +582,3 @@ MpvPlayerBackend::createRenderer() const
return new MpvRenderer(const_cast<MpvPlayerBackend*>(this)); 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 #ifndef MpvPlayerBackend_H
#define MpvPlayerBackend_H #define MpvPlayerBackend_H
#include <mpv/client.h>
#include <mpv/qthelper.hpp>
#include <mpv/render_gl.h> #include <mpv/render_gl.h>
@ -30,9 +25,7 @@ class MpvPlayerBackend
Q_OBJECT Q_OBJECT
mpv_handle* mpv; mpv_handle* mpv;
#ifndef DISABLE_MpvPlayerBackend
mpv_render_context* mpv_gl; mpv_render_context* mpv_gl;
#endif
bool onTop = false; bool onTop = false;
QString totalDurationString; QString totalDurationString;

View file

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