Skip to content

Commit

Permalink
Merge pull request #43 from ua0lnj/master
Browse files Browse the repository at this point in the history
Version 1.7.3.
  • Loading branch information
ua0lnj authored Jul 20, 2024
2 parents 89eb133 + c1be4c8 commit ee525d9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 43 deletions.
2 changes: 1 addition & 1 deletion mpv.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "menu_options.h"
#include "mpv_service.h"

static const char *VERSION = "1.7.2"
static const char *VERSION = "1.7.3"
#ifdef GIT_REV
"-GIT" GIT_REV
#endif
Expand Down
100 changes: 58 additions & 42 deletions player.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <locale.h>
#include <string>
#include <vector>
#include <vdr/plugin.h>

#include "player.h"
#include "config.h"
Expand Down Expand Up @@ -49,6 +50,7 @@ xcb_connection_t *Connect = NULL;
xcb_window_t VideoWindow = 0;
xcb_pixmap_t pixmap = XCB_NONE;
xcb_cursor_t cursor = XCB_NONE;
int is_softhddevice = 0;

#ifdef __cplusplus
extern "C"
Expand All @@ -70,6 +72,26 @@ static inline void check_error(int status)
}
}

void set_deinterlace(mpv_handle *h)
{
if (strstr(MpvPluginConfig->HwDec.c_str(),"vaapi"))
{
check_error(mpv_set_option_string(h, "vf", "vavpp=deint=auto"));
}
else if (strstr(MpvPluginConfig->HwDec.c_str(),"vdpau"))
{
check_error(mpv_set_option_string(h, "vf", "vdpaupp=deint=yes:deint-mode=temporal-spatial"));
}
else if (strstr(MpvPluginConfig->HwDec.c_str(),"cuda"))
{
check_error(mpv_set_option_string(h, "vd-lavc-o", "deint=adaptive"));
}
else
{
check_error(mpv_set_option_string(h, "deinterlace", "yes"));
}
}

void *cMpvPlayer::XEventThread(void *handle)
{
XEvent event;
Expand All @@ -88,25 +110,30 @@ void *cMpvPlayer::XEventThread(void *handle)
XWindowEvent(Dpy, VideoWindow, KeyPressMask|ButtonPressMask|StructureNotifyMask|SubstructureNotifyMask, &event);
switch (event.type) {
case ButtonPress:
if (event.xbutton.button == 1) {
Time difftime = event.xbutton.time - clicktime;
if (difftime < 500) {
check_error(mpv_set_option_string(Player->hMpv, "fullscreen", toggle ? "yes" : "no"));
toggle = !toggle;
if (is_softhddevice) {
if (event.xbutton.button == 1) {
Time difftime = event.xbutton.time - clicktime;
if (difftime < 500) {
check_error(mpv_set_option_string(Player->hMpv, "fullscreen", toggle ? "yes" : "no"));
toggle = !toggle;
}
clicktime = event.xbutton.time;
}
clicktime = event.xbutton.time;
}
else if (event.xbutton.button == 2) {
FeedKeyPress("XKeySym", "Ok", 0, 0, NULL);
}
else if (event.xbutton.button == 3) {
FeedKeyPress("XKeySym", "Menu", 0, 0, NULL);
}
if (event.xbutton.button == 4) {
FeedKeyPress("XKeySym", "Volume+", 0, 0, NULL);
}
if (event.xbutton.button == 5) {
FeedKeyPress("XKeySym", "Volume-", 0, 0, NULL);
else if (event.xbutton.button == 2) {
FeedKeyPress("XKeySym", "Ok", 0, 0, NULL);
}
else if (event.xbutton.button == 3) {
FeedKeyPress("XKeySym", "Menu", 0, 0, NULL);
}
if (event.xbutton.button == 4) {
FeedKeyPress("XKeySym", "Volume+", 0, 0, NULL);
}
if (event.xbutton.button == 5) {
FeedKeyPress("XKeySym", "Volume-", 0, 0, NULL);
}
} else {
check_error(mpv_set_option_string(Player->hMpv, "fullscreen", toggle ? "yes" : "no"));
toggle = !toggle;
}
break;
case ButtonRelease:
Expand Down Expand Up @@ -194,6 +221,7 @@ void *cMpvPlayer::ObserverThread(void *handle)
case MPV_EVENT_PLAYBACK_RESTART :
Player->ChangeFrameRate(Player->CurrentFps()); // switching directly after the fps event causes black screen
Player->PlayerIdle = 0;
if (MpvPluginConfig->UseDeinterlace && !Player->Image()) set_deinterlace(Player->hMpv);
break;

case MPV_EVENT_LOG_MESSAGE :
Expand Down Expand Up @@ -517,6 +545,7 @@ void cMpvPlayer::PlayerStart()
PlayerIdle = 0;
PlayerSpeed = 1;
PlayerDiscNav = 0;
isImage = 0;

SwitchOsdToMpv();

Expand All @@ -542,6 +571,7 @@ void cMpvPlayer::PlayerStart()
check_error(mpv_set_option_string(hMpv, "vo", MpvPluginConfig->VideoOut.c_str()));
check_error(mpv_set_option_string(hMpv, "hwdec", MpvPluginConfig->HwDec.c_str()));
check_error(mpv_set_option_string(hMpv, "gpu-context", MpvPluginConfig->GpuCtx.c_str()));
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
#ifdef USE_DRM
if (!strcmp(MpvPluginConfig->GpuCtx.c_str(),"drm") || !strcmp(MpvPluginConfig->VideoOut.c_str(),"drm"))
{
Expand All @@ -567,30 +597,7 @@ void cMpvPlayer::PlayerStart()
}
if (MpvPluginConfig->UseDeinterlace)
{
if (strstr(MpvPluginConfig->HwDec.c_str(),"vaapi"))
{
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
check_error(mpv_set_option_string(hMpv, "vf", "vavpp=deint=auto"));
}
else if (strstr(MpvPluginConfig->HwDec.c_str(),"vdpau"))
{
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
check_error(mpv_set_option_string(hMpv, "vf", "vdpaupp=deint=yes:deint-mode=temporal-spatial"));
}
else if (strstr(MpvPluginConfig->HwDec.c_str(),"cuda"))
{
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
check_error(mpv_set_option_string(hMpv, "vd-lavc-o", "deint=adaptive"));
}
else if (strstr(MpvPluginConfig->HwDec.c_str(),"nvdec"))
{
check_error(mpv_set_option_string(hMpv, "hwdec-codecs", "all"));
check_error(mpv_set_option_string(hMpv, "deinterlace", "yes"));
}
else
{
check_error(mpv_set_option_string(hMpv, "deinterlace", "yes"));
}
set_deinterlace(hMpv);
}
check_error(mpv_set_option_string(hMpv, "audio-device", MpvPluginConfig->AudioOut.c_str()));
check_error(mpv_set_option_string(hMpv, "slang", MpvPluginConfig->Languages.c_str()));
Expand Down Expand Up @@ -681,6 +688,10 @@ void cMpvPlayer::PlayerStart()
pthread_create(&XEventThreadHandle, NULL, XEventThread, this);
RemoteStart();
}
if (cPluginManager::GetPlugin("softhddevice"))
{
is_softhddevice = 1;
}
}

void cMpvPlayer::HandlePropertyChange(mpv_event *event)
Expand Down Expand Up @@ -820,6 +831,11 @@ void cMpvPlayer::HandleTracksChange()
TrackLanguage = Node.u.list->values[i].u.list->values[j].u.string;
if (strcmp(Node.u.list->values[i].u.list->keys[j], "title") == 0)
TrackTitle = Node.u.list->values[i].u.list->values[j].u.string;
if (strcmp(Node.u.list->values[i].u.list->keys[j], "image") == 0)
{
isImage = Node.u.list->values[i].u.list->values[j].u.flag;
if (isImage) check_error(mpv_set_option_string(hMpv, "deinterlace", "no"));
}
}
if (TrackType == "audio")
{
Expand Down
2 changes: 2 additions & 0 deletions player.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class cMpvPlayer:public cPlayer
vector<string> ListFilenames; // filenames in playlist
vector<string> ListTitles ; // titles in playlist
int isNetwork; // detect network stream
int isImage;
int windowWidth;
int windowHeight;
int windowX;
Expand Down Expand Up @@ -136,6 +137,7 @@ class cMpvPlayer:public cPlayer
string ListTitle(unsigned int pos) {if (pos <= ListTitles.size() && pos) return ListTitles[pos-1]; else return ""; }
string ListFilename(unsigned int pos) {if (pos <= ListFilenames.size() && pos) return ListFilenames[pos-1]; else return ""; }
int NetworkPlay() { return isNetwork; }
int Image() {return isImage; }
int WindowWidth() { return windowWidth; }
int WindowHeight() { return windowHeight; }
};
Expand Down

0 comments on commit ee525d9

Please sign in to comment.