mirror of
https://github.com/mpv-player/mpv
synced 2025-02-02 05:01:56 +00:00
vo_libmpv: pass vo struct to the control callback
This commit is contained in:
parent
f66ee85fdf
commit
20dffe0621
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user