summaryrefslogtreecommitdiffstats
path: root/osdep/macos/mpv_helper.swift
diff options
context:
space:
mode:
Diffstat (limited to 'osdep/macos/mpv_helper.swift')
-rw-r--r--osdep/macos/mpv_helper.swift18
1 files changed, 15 insertions, 3 deletions
diff --git a/osdep/macos/mpv_helper.swift b/osdep/macos/mpv_helper.swift
index 171687bd89..6fde975c06 100644
--- a/osdep/macos/mpv_helper.swift
+++ b/osdep/macos/mpv_helper.swift
@@ -86,17 +86,23 @@ class MPVHelper {
func setOption(fullscreen: Bool) {
optsPtr.pointee.fullscreen = fullscreen
- m_config_cache_write_opt(optsCachePtr, UnsafeMutableRawPointer(&optsPtr.pointee.fullscreen))
+ _ = withUnsafeMutableBytes(of: &optsPtr.pointee.fullscreen) { (ptr: UnsafeMutableRawBufferPointer) in
+ m_config_cache_write_opt(optsCachePtr, ptr.baseAddress)
+ }
}
func setOption(minimized: Bool) {
optsPtr.pointee.window_minimized = Int32(minimized)
- m_config_cache_write_opt(optsCachePtr, UnsafeMutableRawPointer(&optsPtr.pointee.window_minimized))
+ _ = withUnsafeMutableBytes(of: &optsPtr.pointee.window_minimized) { (ptr: UnsafeMutableRawBufferPointer) in
+ m_config_cache_write_opt(optsCachePtr, ptr.baseAddress)
+ }
}
func setOption(maximized: Bool) {
optsPtr.pointee.window_maximized = Int32(maximized)
- m_config_cache_write_opt(optsCachePtr, UnsafeMutableRawPointer(&optsPtr.pointee.window_maximized))
+ _ = withUnsafeMutableBytes(of: &optsPtr.pointee.window_maximized) { (ptr: UnsafeMutableRawBufferPointer) in
+ m_config_cache_write_opt(optsCachePtr, ptr.baseAddress)
+ }
}
func setMacOptionCallback(_ callback: swift_wakeup_cb_fn, context object: AnyObject) {
@@ -141,4 +147,10 @@ class MPVHelper {
closure(pointers)
}
+
+ class func getPointer<T>(_ value: inout T) -> UnsafeMutableRawPointer? {
+ return withUnsafeMutableBytes(of: &value) { (ptr: UnsafeMutableRawBufferPointer) in
+ ptr.baseAddress
+ }
+ }
}