summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_cb_common.swift
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2021-03-26 02:32:49 -0500
committerrcombs <rcombs@rcombs.me>2021-11-28 16:37:07 -0600
commita0e56cbff993ca4ac30590175d3ecd2f3cf8e28b (patch)
treed2cfc75b578f0097450058a2c292a730e3c5b0db /video/out/cocoa_cb_common.swift
parent4991ffa859384814e687c25d25d739f9db5f9033 (diff)
downloadmpv-a0e56cbff993ca4ac30590175d3ecd2f3cf8e28b.tar.bz2
mpv-a0e56cbff993ca4ac30590175d3ecd2f3cf8e28b.tar.xz
Swift: avoid unnecessary unsafe conversions; fixes crash in debug buildsrcombs/swift
Diffstat (limited to 'video/out/cocoa_cb_common.swift')
-rw-r--r--video/out/cocoa_cb_common.swift10
1 files changed, 2 insertions, 8 deletions
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift
index dd0738f7e3..db366737aa 100644
--- a/video/out/cocoa_cb_common.swift
+++ b/video/out/cocoa_cb_common.swift
@@ -170,13 +170,7 @@ class CocoaCB: Common {
var controlCallback: mp_render_cb_control_fn = { ( v, ctx, e, request, d ) -> Int32 in
let ccb = unsafeBitCast(ctx, to: CocoaCB.self)
- // the data pointer can be a null pointer, the libmpv control callback
- // provides nil instead of the 0 address like the usual control call of
- // an internal vo, workaround to create a null pointer instead of nil
- var data = UnsafeMutableRawPointer.init(bitPattern: 0).unsafelyUnwrapped
- if let dunwrapped = d {
- data = dunwrapped
- }
+ let data = UnsafeMutableRawPointer(d)
guard let vo = v, let events = e else {
ccb.log.sendWarning("Unexpected nil value in Control Callback")
@@ -189,7 +183,7 @@ class CocoaCB: Common {
override func control(_ vo: UnsafeMutablePointer<vo>,
events: UnsafeMutablePointer<Int32>,
request: UInt32,
- data: UnsafeMutableRawPointer) -> Int32
+ data: UnsafeMutableRawPointer?) -> Int32
{
switch mp_voctrl(request) {
case VOCTRL_PREINIT: