jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
543 stars 68 forks source link

Passing x11_display to MpvRenderContext() raises error #169

Closed irfinnew closed 3 years ago

irfinnew commented 3 years ago

I'm experimenting with video acceleration in an EGL context, and to get vaapi working I need to pass libmpv a raw pointer to the X11 window using MPV_RENDER_PARAM_X11_DISPLAY. python-mpv has support for this, but it appears broken.

Simple testcase:

import ctypes
from mpv import MPV, MpvRenderContext

MpvRenderContext(MPV(), 'opengl', x11_display=ctypes.c_void_p(5), opengl_init_params={})

Results in:

Traceback (most recent call last):
  File "simple-test.py", line 4, in <module>
    MpvRenderContext(MPV(), 'opengl', x11_display=ctypes.c_void_p(5), opengl_init_params={})
  File "/home/marcelm/pyopengl/mpv.py", line 1823, in __init__
    _mpv_render_context_create(buf, mpv.handle, kwargs_to_render_param_array(kwargs))
  File "/home/marcelm/pyopengl/mpv.py", line 234, in kwargs_to_render_param_array
    return t(*kwargs.items(), ('invalid', None))
RuntimeError: (MpvRenderParam) <class 'TypeError'>: _ctypes.PyCSimpleType object argument after ** must be a mapping, not c_void_p

Looking at the code in MpvRenderParam.__init__(), there's no way passing x11_display or wl_display could work; the value is supposed to be a void pointer, but it is handled by the fall-through case where it is used as c_void_p(**value).

I'll make a pull request to handle the c_void_p case.

jaseg commented 3 years ago

Closed by #170

jaseg commented 3 years ago

Thanks!