History

mac/option: make option helper vo struct independent

der richter committed 2 years ago

Commit 6defd491 parent 90c534a4 files · +12 −12Browse files

Unified · Split

4 files
  1. osdep/mac/option_helper.swift +3 −6
  2. video/out/cocoa_cb_common.swift +3 −2
  3. video/out/mac/common.swift +3 −2
  4. video/out/mac_common.swift +3 −2
osdep/mac/option_helper.swift+3−6
@@ -20,7 +20,6 @@ import Cocoa · 19 unmodified lines
2020 typealias swift_wakeup_cb_fn = (@convention(c) (UnsafeMutableRawPointer?) -> Void)?
2121
2222 class OptionHelper: NSObject {
23− var vo: UnsafeMutablePointer<vo>
2423 var optsCachePtr: UnsafeMutablePointer<m_config_cache>
2524 var macOptsCachePtr: UnsafeMutablePointer<m_config_cache>
2625
@@ -35,11 +34,9 @@ class OptionHelper: NSObject { · 8 unmodified lines
3534 var opts: mp_vo_opts { get { return optsPtr.pointee } }
3635 var macOpts: macos_opts { get { return macOptsPtr.pointee } }
3736
38− init(_ vo: UnsafeMutablePointer<vo>) {
39− self.vo = vo
40−
41− guard let cache = m_config_cache_alloc(vo, vo.pointee.global, Application.getVoSubConf()),
42− let macCache = m_config_cache_alloc(vo, vo.pointee.global, Application.getMacOSConf()) else
37+ init(_ taParent: UnsafeMutableRawPointer, _ global: OpaquePointer?) {
38+ guard let cache = m_config_cache_alloc(taParent, global, Application.getVoSubConf()),
39+ let macCache = m_config_cache_alloc(taParent, global, Application.getMacOSConf()) else
4340 {
4441 // will never be hit, mp_get_config_group asserts for invalid groups
4542 exit(1)
video/out/cocoa_cb_common.swift+3−2
@@ -35,11 +35,12 @@ class CocoaCB: Common { · 34 unmodified lines
3535 let newlog = mp_log_new(UnsafeMutablePointer<MPContext>(mpvHandle), mp_client_get_log(mpvHandle), "cocoacb")
3636 libmpv = LibmpvHelper(mpvHandle, newlog)
3737 super.init(newlog)
38+ option = OptionHelper(UnsafeMutablePointer(mpvHandle), mp_client_get_global(mpvHandle))
3839 layer = GLLayer(cocoaCB: self)
3940 }
4041
4142 func preinit(_ vo: UnsafeMutablePointer<vo>) {
42− option = OptionHelper(vo)
43+ self.vo = vo
4344 input = InputHelper(vo.pointee.input_ctx, option)
4445
4546 if backendState == .uninitialized {
@@ -62,7 +63,7 @@ class CocoaCB: Common { · 16 unmodified lines
6263 }
6364
6465 func reconfig(_ vo: UnsafeMutablePointer<vo>) {
65− option?.vo = vo
66+ self.vo = vo
6667 if backendState == .needsInit {
6768 DispatchQueue.main.sync { self.initBackend(vo) }
6869 } else if option?.opts.auto_window_resize ?? true {
video/out/mac/common.swift+3−2
@@ -22,6 +22,7 @@ class Common: NSObject { · 21 unmodified lines
2222 var option: OptionHelper?
2323 var input: InputHelper?
2424 var log: LogHelper
25+ var vo: UnsafeMutablePointer<vo>?
2526 let queue: DispatchQueue = DispatchQueue(label: "io.mpv.queue")
2627
2728 @objc var window: Window?
@@ -483,11 +484,11 @@ class Common: NSObject { · 455 unmodified lines
483484 events |= ev
484485 eventsLock.unlock()
485486
486− guard let vout = option?.vo else {
487+ guard let vo = vo else {
487488 log.sendWarning("vo nil in flagEvents")
488489 return
489490 }
490− vo_wakeup(vout)
491+ vo_wakeup(vo)
491492 }
492493
493494 func checkEvents() -> Int {
video/out/mac_common.swift+3−2
@@ -27,7 +27,8 @@ class MacCommon: Common { · 26 unmodified lines
2727 @objc init(_ vo: UnsafeMutablePointer<vo>) {
2828 let newlog = mp_log_new(vo, vo.pointee.log, "mac")
2929 super.init(newlog)
30− option = OptionHelper(vo)
30+ self.vo = vo
31+ option = OptionHelper(vo, vo.pointee.global)
3132 input = InputHelper(vo.pointee.input_ctx, option)
3233 timer = PreciseTimer(common: self)
3334
@@ -38,7 +39,7 @@ class MacCommon: Common { · 4 unmodified lines
3839 }
3940
4041 @objc func config(_ vo: UnsafeMutablePointer<vo>) -> Bool {
41− option?.vo = vo
42+ self.vo = vo
4243
4344 DispatchQueue.main.sync {
4445 let previousActiveApp = getActiveApp()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t