External player: how to use the graphical screen?
#1
I want to create a custom external player to play some special contents (actually a slideshow with on-the-fly crop and zoom). I plan to develop the player in Python with Pygame, the platform is a Raspberry Pi with the Raspberry OS.

When Kodi is stopped, my proof-of-concept player runs nicely from the command line; it uses the fbcon driver and it shows its graphical output on the screen.

Then I declared my custom player into userdata/playercorefactory.xml: it appears under the context menu and I can start it. Unfortunately the player is executed but it fails to initialize the graphics driver. Using Pygame I try to initialize three drivers: directfb, fbcon and svgalib, but none of them succeed.

I got an strace of the failing process and I see the following open() which fails (instead it succeed when Kodi is not running):

openat(AT_FDCWD, "/dev/tty", O_RDWR)    = -1 ENXIO (No such device or address)

I tried to toggle some settings of the external player definition (hidexbmc and hideconsole), but without success.

It seems tha Kodi does not allow the external player to use the screen. Any suggestion?
Reply
#2
After many hours of trying and failing, it turned out that it is not possibile to start an external program from Kodi and use the graphic display; at least it is not possible if Kodi is running without a full windowing system (e.g. X11).

When Kodi is installed on the Raspberry Pi using the RaspiOS operating system (based on Debian GNU/Linux 11 Bullseye), the program is started by the binary program kodi.bin using the argument --standalone. The program kodi-standalone on the Raspberry Pi uses the GBM (Generic Buffer Management) windowing system to draw its graphics via the Mesa (an open source implementation of the OpenGL API). Other platforms supported by kodi-standalone are X11 and Wayland. You can see the following line into the kodi.log:
 
Code:
INFO <general>: CApplication::CreateGUI - using the gbm windowing system

GBM/KMS only supports one “DRM master”. Other applications can only use the screen when going through this master. Kodi is launched through a wrapper that uses chvt to switch X away from being the DRM master and allow kodi to become it. Without kodi supporting relinquishing being the master when launching the app and reacquiring it afterwards then launching another gui app isn't possible.

You can verify if it is possibile to lanuch a simple graphical program like kmscube (from the homonymous Debian package). Just execute the command:

bash:
# /dev/dri/card0 is /dev/dri/by-path/platform-soc:gpu-card
kmscube -D /dev/dri/card0

If Kodi is not running the kmscube runs nicely, but if Kodi is running (you can launch the program using xbmc.executescript() from a Kodi plugin), you will get the following error:

Code:
failed to set mode: Permission denied

If you use strace to debug the error, you can see that the problem is with the /dev/dri/by-path/platform-soc:gpu-card device:

Code:
ioctl(3, DRM_IOCTL_MODE_SETCRTC, 0x7e9e17f8) = -1 EACCES (Permission denied)
Reply

Logout Mark Read Team Forum Stats Members Help
External player: how to use the graphical screen?0