u8sand / Baka-MPlayer

The libmpv based media player
https://u8sand.github.io/Baka-MPlayer/
GNU General Public License v2.0
433 stars 93 forks source link

What about wayland support? #188

Open pshirshov opened 8 years ago

pshirshov commented 8 years ago

baka-mplayer crashes under wayland for now while mpv itself works successfully.

u8sand commented 8 years ago

I'm assuming you've added the relevant Qt compilation flag; the other thing that would cause it to crash is the X11 specific code in src/platform/linux.cpp

Can you confirm that it works when you apply this patch?

diff --git a/src/platform/linux.cpp b/src/platform/linux.cpp
index 0321f9d..6f370a1 100644
--- a/src/platform/linux.cpp
+++ b/src/platform/linux.cpp
@@ -7,9 +7,6 @@
 #include <QDir>
 #include <QUrl>

-#include <QX11Info>
-#include <X11/Xlib.h>
-
 namespace Util {

 QString VersionFileUrl()
@@ -24,33 +21,11 @@ QString DownloadFileUrl()

 bool DimLightsSupported()
 {
-    QString tmp = "_NET_WM_CM_S"+QString::number(QX11Info::appScreen());
-    Atom a = XInternAtom(QX11Info::display(), tmp.toUtf8().constData(), false);
-    if(a && XGetSelectionOwner(QX11Info::display(), a)) // hack for QX11Info::isCompositingManagerRunning()
-        return true;
     return false;
 }

 void SetAlwaysOnTop(WId wid, bool ontop)
 {
-    Display *display = QX11Info::display();
-    XEvent event;
-    event.xclient.type = ClientMessage;
-    event.xclient.serial = 0;
-    event.xclient.send_event = True;
-    event.xclient.display = display;
-    event.xclient.window  = wid;
-    event.xclient.message_type = XInternAtom (display, "_NET_WM_STATE", False);
-    event.xclient.format = 32;
-
-    event.xclient.data.l[0] = ontop;
-    event.xclient.data.l[1] = XInternAtom (display, "_NET_WM_STATE_ABOVE", False);
-    event.xclient.data.l[2] = 0; //unused.
-    event.xclient.data.l[3] = 0;
-    event.xclient.data.l[4] = 0;
-
-    XSendEvent(display, DefaultRootWindow(display), False,
-                           SubstructureRedirectMask|SubstructureNotifyMask, &event);
 }

 QString SettingsLocation()
tidux commented 7 years ago

Baka-mplayer now segfaults under https://github.com/SirCmpwn/Sway

$ baka-mplayer 
qt5ct: using qt5ct plugin
qt5ct: D-Bus global menu: no
Using Wayland-EGL
qt5ct: D-Bus system tray: no
zsh: segmentation fault (core dumped)  baka-mplayer
$ 
u8sand commented 7 years ago

@tidux did you try the patch above? The last person who used wayland didn't get back to us--I don't have a proper wayland setup to test it myself, though I will get one soon. I expect it would segfault without the patch because it is attempting to access X11 specific attributes which wouldn't be available.

tidux commented 7 years ago

The patch works to get the UI up and running, but the OpenGL stuff is still dependent on X, leading to a segfault when I actually try to play anything:

~/src/Baka-MPlayer/build > ./baka-mplayer                                                                                           
qt5ct: using qt5ct plugin                                                                                                           
Icon theme "gnome" not found.                                                                                                       
Icon theme "crystalsvg" not found.                                                                                                  
qt5ct: D-Bus global menu: no                                                                                                        
Using Wayland-EGL                                                                                                                   
qt5ct: D-Bus system tray: no                                                                                                        
QObject::connect: invalid null parameter                                                                                            
Using the 'xdg-shell-v6' shell integration                                                                                          
libGL error: failed to create drawable                                                                                              
libGL error: failed to create drawable                                                                                              
zsh: segmentation fault (core dumped)  ./baka-mplayer     

Note that regular mpv works 100% on this setup, so it's got to be baka-mplayer specific code rather than libmpv.

u8sand commented 7 years ago

@tidux You may have some luck playing with the mpv vo parameter in ~/.config/bakamplayer.ini; the default is vdpau which is X11 only. Some things that might work are opengl (safest option) or vaapi (intel va api), there is also a vo called wayland maybe that's what you need.

...

    "mpv": {
...
        "vo": "wayland",
...
    },
...

You can also try removing the vo option to have mpv autoselect (I hope, maybe baka will just put it back though, you can also try making it empty string). Do tell me if any of these things work.

I use i3 myself so I may try setting up Sway.

tidux commented 7 years ago

vo = opengl crashes again. vo = wayland causes a new empty region (not even blank, just the wallpaper) to work although audio does play. I'm seeing similar behavior for vo = wayland on raw mpv (vo = opengl works there) so it may be a Sway bug.

u8sand commented 7 years ago

@tidux sounds like maybe the vo driver is working properly but passing the win handle to mpv isn't (hence why you aren't seeing anything). I have a feeling this might end up working properly when we use opengl-cb; I'll keep you up to date on if I can get it working on my side. Thanks for trying those things out

u8sand commented 7 years ago

@tidux I installed sway on my system and got it running by making vo a blank string, I was able to watch a video. I'm using archlinux, noveau early KMS, and baka-mplayer-git

tidux commented 7 years ago

I'm using baka-mplayer from git master, Arch, and Intel drivers. That just crashes for me.

simonbcn commented 6 years ago
Arch Linux
GNOME Shell 3.28.2 on Wayland
Qt 5.11.0
baka-mplayer 2.0.4-3 (installed from Arch official repositories)

qtdiag-qt5

I can't execute baka-mplayer on Wayland, it crashes:

$ baka-mplayer 
Using Wayland-EGL
[1]    7570 segmentation fault (core dumped)  baka-mplayer

I've obtained this stack trace: https://pastebin.com/rN1wUrb9

u8sand commented 6 years ago

Please confirm whether or not mpv crashes on Wayland. Or Wayland support would be solely dependent on qt's (which I implemented in the patch) and mpv's (which should be an issue on their repo)

In fact I found this on mpv:

gpu-context=wayland

Put that in the mpv options of bakamplayer.ini and it may just work.

Though it's strange because Wayland was working for me a while back. Also make sure you have Qt-Wayland installed for qt's Wayland support

On Mon, Jun 11, 2018, 4:08 AM Simón notifications@github.com wrote:

Arch Linux GNOME Shell 3.28.2 on Wayland Qt 5.11.0

qtdiag-qt5 https://pastebin.com/na5vBqQp

I can't execute baka-mplayer on Wayland, it crashes:

$ baka-mplayer Using Wayland-EGL [1] 7570 segmentation fault (core dumped) baka-mplayer

I've obtained this stack trace: https://pastebin.com/rN1wUrb9

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/u8sand/Baka-MPlayer/issues/188#issuecomment-396158270, or mute the thread https://github.com/notifications/unsubscribe-auth/ABR5pXwR4gHl5oCV7LxNju8kFvTi4ubcks5t7iWGgaJpZM4HEOQI .

simonbcn commented 6 years ago

mpv works well.

mufeedali commented 4 years ago

Any progress on this? mpv does work perfectly on Wayland now. By now, KDE's Wayland support is also pretty good. So, it would be cool to have Baka-MPlayer working too.

ranenvious commented 2 years ago

I don't know if it's unrelated or not (given this thread was last active in 2019) but I am also getting a segmentation fault when running it on an about 3 week old EndeavourOS install that is up to date. If I install the AUR git variant it at least launches, but doesn't seem to play anything ( sometimes I do get audio though )