diff options
author | Akemi <der.richter@gmx.de> | 2018-05-01 16:39:00 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-06-12 01:51:01 +0300 |
commit | 20dffe0621b3e26674850ef0b46ba3e689931d87 (patch) | |
tree | 9ba5a45f6b89d2ec8c6f9f6fadb9b19a1b2564e7 | |
parent | f66ee85fdf39a1f085f5564bee427524c749aaca (diff) |
vo_libmpv: pass vo struct to the control callback
-rw-r--r-- | video/out/cocoa_cb_common.swift | 19 | ||||
-rw-r--r-- | video/out/libmpv.h | 2 | ||||
-rw-r--r-- | video/out/vo_libmpv.c | 3 |
3 files changed, 13 insertions, 11 deletions
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift index 659f9f84ce..32e1d42b28 100644 --- a/video/out/cocoa_cb_common.swift +++ b/video/out/cocoa_cb_common.swift @@ -80,21 +80,22 @@ class CocoaCB: NSObject { window.orderOut(nil) } - func reconfig() { + func reconfig(_ vo: UnsafeMutablePointer<vo>) { if backendState == .needsInit { - initBackend() + initBackend(vo) } else { layer.setVideo(true) - updateWindowSize() + updateWindowSize(vo) layer.update() } } - func initBackend() { + func initBackend(_ vo: UnsafeMutablePointer<vo>) { + let opts: mp_vo_opts = vo.pointee.opts.pointee NSApp.setActivationPolicy(.regular) let targetScreen = getTargetScreen(forFullscreen: false) ?? NSScreen.main() - let wr = getWindowGeometry(forScreen: targetScreen!, videoOut: mpv.mpctx!.pointee.video_out) + let wr = getWindowGeometry(forScreen: targetScreen!, videoOut: vo) let win = Window(contentRect: wr, styleMask: window.styleMask, screen: targetScreen, cocoaCB: self) win.title = window.title @@ -126,9 +127,9 @@ class CocoaCB: NSObject { backendState = .init } - func updateWindowSize() { + func updateWindowSize(_ vo: UnsafeMutablePointer<vo>) { let targetScreen = getTargetScreen(forFullscreen: false) ?? NSScreen.main() - let wr = getWindowGeometry(forScreen: targetScreen!, videoOut: mpv.mpctx!.pointee.video_out) + let wr = getWindowGeometry(forScreen: targetScreen!, videoOut: vo) if !window.isVisible { window.makeKeyAndOrderFront(nil) } @@ -380,7 +381,7 @@ class CocoaCB: NSObject { return ev } - var controlCallback: mp_render_cb_control_fn = { ( ctx, events, request, data ) -> Int32 in + var controlCallback: mp_render_cb_control_fn = { ( vo, ctx, events, request, data ) -> Int32 in let ccb: CocoaCB = MPVHelper.bridge(ptr: ctx!) switch mp_voctrl(request) { @@ -444,7 +445,7 @@ class CocoaCB: NSObject { return VO_TRUE case VOCTRL_RECONFIG: DispatchQueue.main.async { - ccb.reconfig() + ccb.reconfig(vo!) } return VO_TRUE default: diff --git a/video/out/libmpv.h b/video/out/libmpv.h index dc9d523b23..2fe33386f4 100644 --- a/video/out/libmpv.h +++ b/video/out/libmpv.h @@ -15,7 +15,7 @@ void *get_mpv_render_param(mpv_render_param *params, mpv_render_param_type type, #define GET_MPV_RENDER_PARAM(params, type, ctype, def) \ (*(ctype *)get_mpv_render_param(params, type, &(ctype){(def)})) -typedef int (*mp_render_cb_control_fn)(void *cb_ctx, int *events, +typedef int (*mp_render_cb_control_fn)(struct vo *vo, void *cb_ctx, int *events, uint32_t request, void *data); void mp_render_context_set_control_callback(mpv_render_context *ctx, mp_render_cb_control_fn callback, diff --git a/video/out/vo_libmpv.c b/video/out/vo_libmpv.c index 59d3b6883c..1df63a5197 100644 --- a/video/out/vo_libmpv.c +++ b/video/out/vo_libmpv.c @@ -626,7 +626,8 @@ static int control(struct vo *vo, uint32_t request, void *data) pthread_mutex_lock(&ctx->control_lock); if (ctx->control_cb) { int events = 0; - r = ctx->control_cb(ctx->control_cb_ctx, &events, request, data); + r = p->ctx->control_cb(vo, p->ctx->control_cb_ctx, + &events, request, data); vo_event(vo, events); } pthread_mutex_unlock(&ctx->control_lock); |