// libmpv wrapper for V. The declarations follow mpv's own headers: client.h, // render.h and render_gl.h. @[has_globals] module mpv #flag -lmpv $if linux { #flag -lGL #flag -DGL_GLEXT_PROTOTYPES } $if windows { // The win64 kit ships the libmpv headers, an import library generated from // the DLL's export table, and nothing else; see mpv/win64/README.md. #flag windows -I @VMODROOT/mpv/win64/include #flag windows -L @VMODROOT/mpv/win64/lib #flag windows -lmpv // wgl_proc asks opengl32.dll for GL entry points. #flag windows -lopengl32 } $if android { // The android kit ships the libmpv headers and takes the libmpv shared // library for the architecture being linked; see mpv/android/README.md. // One directory for the library, because vab compiles the V sources once // and lets the NDK compile the C per architecture — the -L line has to be // the same for every arch, so a build links one architecture at a time // and vab's --libs dir carries the runtime copies into the APK. #flag android -I @VMODROOT/mpv/android/include #flag android -L @VMODROOT/mpv/android/lib // android_gl_proc resolves GL entry points from libGLESv3 by dlsym and // falls back to libEGL's trampolines for extensions; the surface's // texture work links GLESv3 directly. liblog and libandroid come with // the NativeActivity build the sokol backend expects. #flag android -lEGL #flag android -lGLESv3 #flag android -llog #flag android -landroid } $if linux { #flag -std=gnu99 } $if macos { // libmpv comes from Homebrew or MacPorts: clang on macOS searches none // of those prefixes by default, so all are given and clang ignores the // ones that do not exist (Homebrew keeps /opt/homebrew on Apple Silicon // and /usr/local on Intel; MacPorts /opt/local). A libmpv installed // anywhere else reaches the build through -cflags '-I -L'. #flag darwin -I/opt/homebrew/include #flag darwin -I/usr/local/include #flag darwin -I/opt/local/include #flag darwin -L/opt/homebrew/lib #flag darwin -L/usr/local/lib #flag darwin -L/opt/local/lib // The surface's GL calls link straight against the framework, the way // the Linux path links -lGL. #flag darwin -framework OpenGL } $if openbsd { // libmpv comes from the packages tree (/usr/local), which clang on // OpenBSD searches none of; the GL side needs no path here, because // xenocara's /usr/X11R6 tree is put on the search paths by sokol's own // OpenBSD flags, which every module's build shares. #flag openbsd -I/usr/local/include #flag openbsd -L/usr/local/lib } $if netbsd { // libmpv comes from pkgsrc (/usr/pkg), which clang on NetBSD does not // search; the GL side needs no path here, because the base system's // X11R7 tree is put on the search paths by sokol's own NetBSD flags. #flag netbsd -I/usr/pkg/include #flag netbsd -L/usr/pkg/lib } $if dragonfly { // Everything comes from dports (/usr/local), the FreeBSD layout, and // clang on DragonFly searches it no better than OpenBSD's does. #flag dragonfly -I/usr/local/include #flag dragonfly -L/usr/local/lib } $if solaris { // Solaris needs no path: its IPS packages install libmpv, the X11 and GL // trees and their headers into /usr, which the compiler and the linker // search by default (both bitnesses, the 64-bit one through the driver's // own /usr/lib/amd64). A libmpv from OpenCSW (/opt/csw) reaches the // build through -cflags '-I -L'. } #include "mpv/client.h" #include "mpv/render.h" #include "mpv/render_gl.h" $if linux || freebsd || openbsd || netbsd || dragonfly || solaris || macos || android { #include } $if windows { #include } $if android { #include } pub const format_string = 1 pub const format_flag = 3 pub const format_double = 5 pub const event_none = 0 pub const event_get_property_reply = 3 pub const event_set_property_reply = 4 pub const event_log_message = 2 pub const event_shutdown = 1 pub const event_start_file = 6 pub const event_end_file = 7 pub const event_file_loaded = 8 pub const event_command_reply = 5 pub const event_seek = 20 pub const event_playback_restart = 21 pub const event_property_change = 22 const render_param_invalid = 0 const render_param_api_type = 1 const render_param_opengl_init_params = 2 const render_param_opengl_fbo = 3 const render_param_flip_y = 4 // render_param_advanced_control is MPV_RENDER_PARAM_ADVANCED_CONTROL. The int // it points at turns on the render thread's advanced mode: the core prepares // frames ahead and decoding may render straight to a texture. The API user // must guarantee the render thread never waits on the core while it is on. const render_param_advanced_control = 10 // render_param_block_for_target_time is MPV_RENDER_PARAM_BLOCK_FOR_TARGET_TIME. // The int it points at decides whether render_context_draw waits for the // target display time (the default, up to video-timing-offset, 50 ms) before // returning. const render_param_block_for_target_time = 12 const render_param_next_frame_info = 11 const render_param_skip_rendering = 13 // render_frame_info_present is MPV_RENDER_FRAME_INFO_PRESENT: the info // describes a queued frame rather than "no next frame". pub const render_frame_info_present = 1 << 0 pub const render_frame_info_redraw = 1 << 1 // render_frame_info_repeat is MPV_RENDER_FRAME_INFO_REPEAT: the queued frame // re-presents the picture already on screen, held over its vsyncs. pub const render_frame_info_repeat = 1 << 2 const render_param_x11_display = 8 // RenderParam matches mpv_render_param: a type tag, then a pointer. struct RenderParam { typ i32 data voidptr } // OpenglFbo matches mpv_opengl_fbo. struct OpenglFbo { fbo i32 w i32 h i32 internal_format i32 } // OpenglInitParams matches mpv_opengl_init_params. struct OpenglInitParams { get_proc_address fn (voidptr, &char) voidptr @[required] get_proc_address_ctx voidptr } fn C.mpv_create() voidptr fn C.mpv_initialize(voidptr) i32 fn C.mpv_destroy(voidptr) fn C.mpv_terminate_destroy(voidptr) fn C.mpv_error_string(i32) &char fn C.mpv_free(voidptr) fn C.mpv_client_name(voidptr) &char fn C.mpv_set_option_string(voidptr, &char, &char) i32 fn C.mpv_command(voidptr, voidptr) i32 fn C.mpv_command_async(voidptr, u64, voidptr) i32 fn C.mpv_set_property_async(voidptr, u64, &char, i32, voidptr) i32 fn C.mpv_set_property(voidptr, &char, i32, voidptr) i32 fn C.mpv_set_property_string(voidptr, &char, &char) i32 fn C.mpv_get_property(voidptr, &char, i32, voidptr) i32 fn C.mpv_get_property_string(voidptr, &char) &char fn C.mpv_observe_property(voidptr, u64, &char, i32) i32 fn C.mpv_wait_event(voidptr, f64) voidptr fn C.mpv_render_context_create(&voidptr, voidptr, voidptr) i32 fn C.mpv_render_context_render(voidptr, voidptr) i32 fn C.mpv_render_context_free(voidptr) fn C.mpv_render_context_set_update_callback(voidptr, UpdateCallback, voidptr) fn C.mpv_get_property_async(voidptr, u64, &char, i32) i32 fn C.mpv_render_context_report_swap(voidptr) @[typedef] pub struct C.mpv_render_param { type int data voidptr } fn C.mpv_render_context_get_info(voidptr, C.mpv_render_param) i32 fn C.mpv_get_time_us(voidptr) i64 fn C.mpv_render_context_update(voidptr) u64 fn C.mpv_request_log_messages(voidptr, &char) i32 $if linux || freebsd || openbsd || netbsd || dragonfly || solaris || macos || android { // Linux and the BSDs dlsym libGL's global symbol table (dlfcn ships in // the C library on all of them); macOS dlopens the OpenGL framework // first, so dlopen is declared for all of them. fn C.dlopen(&char, i32) voidptr fn C.dlsym(voidptr, &char) voidptr } $if android { type AvJniSetJavaVm = fn (voidptr, voidptr) i32 // register_java_vm gives libavcodec the JavaVM before mpv starts: mpv's // Android audio output and hardware decoding reach Java through it. The // library is already loaded as libmpv's dependency, so dlopen answers with // the handle that is in use, and RTLD_NOW is 2 on Android. pub fn register_java_vm(vm voidptr) { avcodec := C.dlopen(c'libavcodec.so', 2) if avcodec == unsafe { nil } { return } setter := C.dlsym(avcodec, c'av_jni_set_java_vm') if setter == unsafe { nil } { return } unsafe { AvJniSetJavaVm(setter)(vm, nil) } } } $if windows { fn C.wglGetProcAddress(&char) voidptr fn C.LoadLibraryA(&char) voidptr // wgl_proc resolves an OpenGL entry point the way mpv's get_proc_address // needs on Windows: wglGetProcAddress answers for everything newer than // GL 1.1 once a context is current, and the GL 1.1 names export from // opengl32.dll itself, which the WGL backend of sokol has already loaded. // The surface code asks the same question for its texture work. pub fn wgl_proc(name &char) voidptr { proc := C.wglGetProcAddress(name) if proc != unsafe { nil } { return proc } gl := C.LoadLibraryA(c'opengl32.dll') if gl != unsafe { nil } { return C.GetProcAddress(gl, &u8(name)) } return unsafe { nil } } } $if macos { // macOS resolves GL entry points out of the OpenGL framework binary // directly, the way Linux dlsyms libGL: everything up to GL 4.1 exports // from it, so dlopen + dlsym answers every name mpv asks for. The handle // is cached because mpv asks for hundreds of entry points at // render-context creation, and without the cache every one of those asks // would open the framework again before it could resolve its target. __global macos_gl_handle = unsafe { nil } pub fn macos_gl_proc(name &char) voidptr { if macos_gl_handle == unsafe { nil } { // RTLD_LAZY is 1; dlfcn.h is included above. macos_gl_handle = C.dlopen(c'/System/Library/Frameworks/OpenGL.framework/OpenGL', 1) } if macos_gl_handle == unsafe { nil } { return unsafe { nil } } proc := C.dlsym(macos_gl_handle, name) if proc != unsafe { nil } { return proc } return C.dlsym(unsafe { nil }, name) } } $if android { // Android resolves GL entry points through libEGL: the driver's EGL // answers for every name mpv asks for while the context sokol's Android // backend made current is on, which is how mpv-android resolves its own // render API. eglGetProcAddress returns nil for a name the driver does // not carry, and mpv treats that as the missing function it is. fn C.eglGetProcAddress(&char) voidptr // android_gl_handle caches the libGLESv3 handle: its own symbols are the // driver's real entry points, which dlsym answers for every core GL name. __global android_gl_handle = unsafe { nil } pub fn android_gl_proc(name &char) voidptr { // dlsym first: the linked libGLESv3 exports every core GLES entry // point directly, and eglGetProcAddress's trampolines have been seen // misbehaving for some of them on Adreno (mpv's mapped-buffer upload // path lands black tiles in the video texture). Extensions fall back // to EGL, which remains the only source for those names. if android_gl_handle == unsafe { nil } { android_gl_handle = C.dlopen(c'libGLESv3.so', 2) } if android_gl_handle != unsafe { nil } { proc := C.dlsym(android_gl_handle, name) if proc != unsafe { nil } { return proc } } return C.eglGetProcAddress(name) } } // gl_get_proc_address resolves OpenGL entry points from the GL library the // program links against, which is what mpv asks for through get_proc_address. // GlxGetProcAddress is glXGetProcAddressARB, found through dlsym so no GLX header // is needed; a plain C declaration without its prototype would truncate pointers. type GlxGetProcAddress = fn (&char) voidptr // glx_get_proc_ptr caches glXGetProcAddressARB, and gl_scope_handle caches the // main-program handle the scope lookups run through: mpv asks for hundreds of // entry points at render-context creation, and without the caches every one of // those asks runs dlsym for the resolver itself before it can resolve its // target. __global glx_get_proc_ptr = unsafe { nil } __global gl_scope_handle = unsafe { nil } $if windows { fn win32_gl_get_proc(name &char) voidptr { return wgl_proc(name) } } fn gl_get_proc_address(_ voidptr, name &char) voidptr { $if windows { return win32_gl_get_proc(name) } $if macos { return macos_gl_proc(name) } $if android { return android_gl_proc(name) } $if linux || freebsd || openbsd || netbsd || dragonfly || solaris { // Same Mesa libGL on all, but dlsym's nil handle does not ask the // same question on all: glibc answers it with the global scope; // the BSDs' dlsym(nil, ...) searches the caller's own object and — // on FreeBSD and DragonFly — nothing else, and the main program // merely references libGL, so there every name came back nil and // the render context died on mpv's "Can't load OpenGL functions" // while sokol's link-time GL calls kept working. dlopen(nil, ...) // hands back a handle on the global symbol object, which every // rtld documents as the main program and its startup dependencies, // and dlsym through that handle searches the global scope on all, // which is what libGL needs. RTLD_LAZY is 1 on all. if gl_scope_handle == unsafe { nil } { gl_scope_handle = C.dlopen(unsafe { nil }, 1) } if glx_get_proc_ptr == unsafe { nil } && gl_scope_handle != unsafe { nil } { glx_get_proc_ptr = C.dlsym(gl_scope_handle, c'glXGetProcAddressARB') } if glx_get_proc_ptr != unsafe { nil } { proc := unsafe { GlxGetProcAddress(glx_get_proc_ptr)(name) } if proc != unsafe { nil } { return proc } } if gl_scope_handle != unsafe { nil } { return C.dlsym(gl_scope_handle, name) } return unsafe { nil } } } // create makes a handle. Set options with set_option, then call initialize. pub fn create() voidptr { return C.mpv_create() } pub fn initialize(ctx voidptr) i32 { return C.mpv_initialize(ctx) } // destroy tears the core down, not just the client handle: mpv_destroy would // only detach, leaving the core and its audio output running — a destroyed // player's pulse/pipewire connection would stay open until process exit // closed everything at once. Call sites all mean a full teardown, so the // terminating variant is what destroy is here. pub fn destroy(ctx voidptr) { C.mpv_terminate_destroy(ctx) } // error_string describes a negative return code. pub fn error_string(code i32) string { return unsafe { cstring_to_vstring(C.mpv_error_string(code)) } } pub fn client_name(ctx voidptr) string { return unsafe { cstring_to_vstring(C.mpv_client_name(ctx)) } } // set_option sets an option. Before initialize every option is accepted; after // it, only the runtime options are. pub fn set_option(ctx voidptr, name string, value string) i32 { return C.mpv_set_option_string(ctx, name.str, value.str) } // command runs a command with separate arguments, so a path may contain spaces. pub fn command(ctx voidptr, args []string) i32 { mut argv := []voidptr{cap: args.len + 1} for arg in args { argv << voidptr(arg.str) } argv << unsafe { voidptr(nil) } return C.mpv_command(ctx, argv.data) } // command_async queues the command and returns at once. Its result arrives as a // COMMAND_REPLY event carrying reply_userdata. Use it from the UI thread: a // blocking call waits for mpv's core, which may itself be waiting for a frame. pub fn command_async(ctx voidptr, reply_userdata u64, args []string) i32 { mut argv := []voidptr{cap: args.len + 1} for arg in args { argv << voidptr(arg.str) } argv << unsafe { voidptr(nil) } return C.mpv_command_async(ctx, reply_userdata, argv.data) } // set_double_async sets a double property without waiting for mpv's core. pub fn set_double_async(ctx voidptr, reply_userdata u64, name string, value f64) i32 { mut v := value return C.mpv_set_property_async(ctx, reply_userdata, name.str, format_double, voidptr(&v)) } // set_string_async sets a string property without waiting for mpv's core. pub fn set_string_async(ctx voidptr, reply_userdata u64, name string, value string) i32 { mut v := value.str return C.mpv_set_property_async(ctx, reply_userdata, name.str, format_string, voidptr(&v)) } // set_flag_async sets a flag property without waiting for mpv's core. pub fn set_flag_async(ctx voidptr, reply_userdata u64, name string, value bool) i32 { mut flag := i32(0) flag = i32(value) return C.mpv_set_property_async(ctx, reply_userdata, name.str, format_flag, voidptr(&flag)) } pub fn loadfile(ctx voidptr, path string) i32 { return command(ctx, ['loadfile', path]) } pub fn stop(ctx voidptr) i32 { return command(ctx, ['stop']) } pub fn seek(ctx voidptr, seconds f64) i32 { return command(ctx, ['seek', '${seconds:.3f}', 'absolute']) } pub fn set_property_string(ctx voidptr, name string, value string) i32 { return C.mpv_set_property_string(ctx, name.str, value.str) } pub fn set_flag(ctx voidptr, name string, value bool) i32 { mut flag := i32(0) flag = i32(value) return C.mpv_set_property(ctx, name.str, format_flag, voidptr(&flag)) } pub fn get_string(ctx voidptr, name string) ?string { res := C.mpv_get_property_string(ctx, name.str) if res == unsafe { nil } { return none } defer { C.mpv_free(voidptr(res)) } return unsafe { tos_clone(&u8(res)) } } pub fn get_flag(ctx voidptr, name string) ?bool { mut value := i32(0) if C.mpv_get_property(ctx, name.str, format_flag, voidptr(&value)) < 0 { return none } return value != 0 } pub fn get_double(ctx voidptr, name string) ?f64 { mut value := f64(0) if C.mpv_get_property(ctx, name.str, format_double, voidptr(&value)) < 0 { return none } return value } // wait_event returns the next queued event. With timeout 0 it does not block; // check event_id against event_none to find the end of the queue. pub fn wait_event(ctx voidptr, timeout f64) voidptr { return C.mpv_wait_event(ctx, timeout) } // request_log_messages makes mpv send its log as LOG_MESSAGE events at this // level: "fatal", "error", "warn", "info", "v", or "debug". pub fn request_log_messages(ctx voidptr, level string) i32 { return C.mpv_request_log_messages(ctx, level.str) } // log_message_text reads a LOG_MESSAGE event. mpv_event_log_message is // {prefix, level, text} and its pointer is at offset 16 of mpv_event. pub fn log_message_text(ev voidptr) string { data := unsafe { *(&voidptr(u64(ev) + 16)) } return unsafe { cstring_to_vstring(*(&&char(u64(data) + 16))) } } // event_data reads mpv_event.data, which sits at offset 16. fn event_data(ev voidptr) voidptr { return unsafe { *(&voidptr(u64(ev) + 16)) } } // property_name reads the name of a PROPERTY_CHANGE event. pub fn property_name(ev voidptr) string { prop := u64(event_data(ev)) name := unsafe { *(&&char(prop)) } return unsafe { cstring_to_vstring(name) } } // property_value returns the data pointer of a PROPERTY_CHANGE event, or nil when // mpv has no value for the property (for example when no file is loaded). fn property_value(ev voidptr) voidptr { prop := event_data(ev) return unsafe { *(&voidptr(u64(prop) + 16)) } } // property_string reads the value of a string-format PROPERTY_CHANGE event. pub fn property_string(ev voidptr) ?string { value := property_value(ev) if value == unsafe { nil } { return none } text := unsafe { *(&&char(value)) } if text == unsafe { nil } { return none } return unsafe { tos_clone(&u8(text)) } } pub fn property_double(ev voidptr) ?f64 { value := property_value(ev) if value == unsafe { nil } { return none } return unsafe { *(&f64(value)) } } pub fn property_flag(ev voidptr) ?bool { value := property_value(ev) if value == unsafe { nil } { return none } return unsafe { *(&i32(value)) } != 0 } pub fn event_reply_userdata(ev voidptr) u64 { return unsafe { *(&u64(u64(ev) + 8)) } } // event_error reads mpv_event.error, the status of a reply: 0 or more on // success, a negative mpv error code otherwise. It sits at offset 4. pub fn event_error(ev voidptr) i32 { return unsafe { *(&i32(u64(ev) + 4)) } } // event_id reads mpv_event.event_id, the first field of every event. pub fn event_id(ev voidptr) i32 { return unsafe { *(&i32(ev)) } } pub fn observe_property(ctx voidptr, reply_userdata u64, name string, format i32) i32 { return C.mpv_observe_property(ctx, reply_userdata, name.str, format) } // get_property_async queues a property read and returns at once. The reply // arrives on the event queue as a GET_PROPERTY_REPLY event carrying the // reply_userdata; its value reads out of the same accessors as property // changes (property_name, property_string, ...). pub fn get_property_async(ctx voidptr, reply_userdata u64, name string, format i32) i32 { return C.mpv_get_property_async(ctx, reply_userdata, name.str, format) } // UpdateCallback is the mpv_render_update_callback: called on a libmpv thread // when a new frame may be available. It must never call mpv_render_* // functions; wake the render loop and return. pub type UpdateCallback = fn (voidptr) // render_context_set_update_callback registers the update callback. Advanced // control requires it to be set soon after the render context is created. pub fn render_context_set_update_callback(render voidptr, cb UpdateCallback, user_data voidptr) { C.mpv_render_context_set_update_callback(render, cb, user_data) } // render_context_create_gl creates an OpenGL render context on the GL context // that is current. Create it after initialize and before loading a file, or mpv // has nowhere to draw video. Returns nil on failure. pub fn render_context_create_gl(ctx voidptr, x11_display voidptr) voidptr { return render_context_create_gl_advanced(ctx, x11_display, false) } // render_context_create_gl_advanced is render_context_create_gl with // MPV_RENDER_PARAM_ADVANCED_CONTROL. While it is on, the core may prepare // frames ahead and decode straight to a texture, but the thread calling the // mpv_render_* functions must never wait on the core: synchronous property // reads from that thread can deadlock it for good. // On Linux, the BSDs and Solaris the X11 display is passed along (sometimes // used by hwdec); on Windows and macOS there is no such render parameter, so // the argument is ignored — macOS's GL backend reads the context that is // already current. pub fn render_context_create_gl_advanced(ctx voidptr, x11_display voidptr, advanced bool) voidptr { init_params := OpenglInitParams{ get_proc_address: gl_get_proc_address get_proc_address_ctx: unsafe { nil } } api_type := c'opengl' advanced_flag := if advanced { i32(1) } else { i32(0) } mut params := [ RenderParam{ typ: render_param_api_type data: voidptr(api_type) }, RenderParam{ typ: render_param_opengl_init_params data: voidptr(&init_params) }, ] $if linux || freebsd || openbsd || netbsd || dragonfly || solaris { params << RenderParam{ typ: render_param_x11_display data: x11_display } } params << [ RenderParam{ typ: render_param_advanced_control data: voidptr(&advanced_flag) }, RenderParam{ typ: render_param_invalid data: unsafe { nil } }, ] mut render := voidptr(unsafe { nil }) if C.mpv_render_context_create(&render, ctx, params.data) < 0 { return unsafe { nil } } return render } // RenderFrameInfo mirrors mpv_render_frame_info: the flags of the next // queued frame and the absolute time (mpv_get_time_us clock, microseconds) at // which it should be displayed. pub struct RenderFrameInfo { pub mut: flags u64 target_time i64 } // render_context_frame_info asks about the frame that render_context_draw // would show next. Info without the render_frame_info_present bit means no // frame is queued. pub fn render_context_frame_info(render voidptr) RenderFrameInfo { mut info := RenderFrameInfo{} param := C.mpv_render_param{ type: render_param_next_frame_info data: voidptr(&info) } C.mpv_render_context_get_info(render, param) return info } // get_time_us is mpv_get_time_us on the handle's clock, the clock target_time // values are on. pub fn get_time_us(ctx voidptr) i64 { return C.mpv_get_time_us(ctx) } // render_context_draw renders the current video frame into the framebuffer // fbo, which must be w by h pixels. The rows are bottom-up, as GL textures are. // When skip is true, mpv discards the frame instead of drawing it — an // output-side drop: the surface keeps its previous picture and the queue // moves on, which is how a slow machine sheds late frames without stalling. // render_context_draw renders the current video frame into the framebuffer // fbo, which must be w by h pixels. The rows are bottom-up, as GL textures // are. When skip is true, mpv discards the frame instead of drawing it — an // already late frame is dropped on the output side rather than shown late. // When block_for_target_time is true (mpv's default), the call waits out the // frame's target display time before returning, which is what makes the // caller's swap land on the vsync the frame was scheduled for; repeats and // redraws return at once regardless. // flip_on_android selects the flip_y render param per platform. fn flip_on_android() bool { $if mpv_noflip ? { return false } return true } pub fn render_context_draw( render voidptr, fbo u32, w i32, h i32, skip bool, block_for_target_time bool ) i32 { target := OpenglFbo{ fbo: i32(fbo) w: w h: h } flip := i32(if flip_on_android() { 1 } else { 0 }) block := i32(if block_for_target_time { 1 } else { 0 }) skip_flag := i32(if skip { 1 } else { 0 }) params := [ RenderParam{ typ: render_param_opengl_fbo data: voidptr(&target) }, RenderParam{ typ: render_param_flip_y data: voidptr(&flip) }, RenderParam{ typ: render_param_block_for_target_time data: voidptr(&block) }, RenderParam{ typ: render_param_skip_rendering data: voidptr(&skip_flag) }, RenderParam{ typ: render_param_invalid data: unsafe { nil } }, ] return C.mpv_render_context_render(render, params.data) } // render_context_update reports the pending work: render_update_frame is set // when a new video frame should be drawn with render_context_draw. pub fn render_context_update(render voidptr) u64 { return C.mpv_render_context_update(render) } // render_context_report_swap tells mpv a frame was presented. Optional, but // with advanced control on mpv's video timing depends on it: without the // reports its timing logic degrades and A/V sync drifts under load. pub fn render_context_report_swap(render voidptr) { C.mpv_render_context_report_swap(render) } pub const render_update_frame = u64(1) pub fn render_context_free(render voidptr) { C.mpv_render_context_free(render) }