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
20typealias swift_wakeup_cb_fn = (@convention(c) (UnsafeMutableRawPointer?) -> Void)?20typealias swift_wakeup_cb_fn = (@convention(c) (UnsafeMutableRawPointer?) -> Void)?
21 21
22class OptionHelper: NSObject {22class OptionHelper: NSObject {
23 var vo: UnsafeMutablePointer<vo>
24 var optsCachePtr: UnsafeMutablePointer<m_config_cache>23 var optsCachePtr: UnsafeMutablePointer<m_config_cache>
25 var macOptsCachePtr: UnsafeMutablePointer<m_config_cache>24 var macOptsCachePtr: UnsafeMutablePointer<m_config_cache>
26 25
@@ -35,11 +34,9 @@ class OptionHelper: NSObject { · 8 unmodified lines
35 var opts: mp_vo_opts { get { return optsPtr.pointee } }34 var opts: mp_vo_opts { get { return optsPtr.pointee } }
36 var macOpts: macos_opts { get { return macOptsPtr.pointee } }35 var macOpts: macos_opts { get { return macOptsPtr.pointee } }
37 36
38 init(_ vo: UnsafeMutablePointer<vo>) {37 init(_ taParent: UnsafeMutableRawPointer, _ global: OpaquePointer?) {
39 self.vo = vo38 guard let cache = m_config_cache_alloc(taParent, global, Application.getVoSubConf()),
40 39 let macCache = m_config_cache_alloc(taParent, global, Application.getMacOSConf()) else
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
43 {40 {
44 // will never be hit, mp_get_config_group asserts for invalid groups41 // will never be hit, mp_get_config_group asserts for invalid groups
45 exit(1)42 exit(1)
video/out/cocoa_cb_common.swift+3−2
@@ -35,11 +35,12 @@ class CocoaCB: Common { · 34 unmodified lines
35 let newlog = mp_log_new(UnsafeMutablePointer<MPContext>(mpvHandle), mp_client_get_log(mpvHandle), "cocoacb")35 let newlog = mp_log_new(UnsafeMutablePointer<MPContext>(mpvHandle), mp_client_get_log(mpvHandle), "cocoacb")
36 libmpv = LibmpvHelper(mpvHandle, newlog)36 libmpv = LibmpvHelper(mpvHandle, newlog)
37 super.init(newlog)37 super.init(newlog)
38 option = OptionHelper(UnsafeMutablePointer(mpvHandle), mp_client_get_global(mpvHandle))
38 layer = GLLayer(cocoaCB: self)39 layer = GLLayer(cocoaCB: self)
39 }40 }
40 41
41 func preinit(_ vo: UnsafeMutablePointer<vo>) {42 func preinit(_ vo: UnsafeMutablePointer<vo>) {
42 option = OptionHelper(vo)43 self.vo = vo
43 input = InputHelper(vo.pointee.input_ctx, option)44 input = InputHelper(vo.pointee.input_ctx, option)
44 45
45 if backendState == .uninitialized {46 if backendState == .uninitialized {
@@ -62,7 +63,7 @@ class CocoaCB: Common { · 16 unmodified lines
62 }63 }
63 64
64 func reconfig(_ vo: UnsafeMutablePointer<vo>) {65 func reconfig(_ vo: UnsafeMutablePointer<vo>) {
65 option?.vo = vo66 self.vo = vo
66 if backendState == .needsInit {67 if backendState == .needsInit {
67 DispatchQueue.main.sync { self.initBackend(vo) }68 DispatchQueue.main.sync { self.initBackend(vo) }
68 } else if option?.opts.auto_window_resize ?? true {69 } 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
22 var option: OptionHelper?22 var option: OptionHelper?
23 var input: InputHelper?23 var input: InputHelper?
24 var log: LogHelper24 var log: LogHelper
25 var vo: UnsafeMutablePointer<vo>?
25 let queue: DispatchQueue = DispatchQueue(label: "io.mpv.queue")26 let queue: DispatchQueue = DispatchQueue(label: "io.mpv.queue")
26 27
27 @objc var window: Window?28 @objc var window: Window?
@@ -483,11 +484,11 @@ class Common: NSObject { · 455 unmodified lines
483 events |= ev484 events |= ev
484 eventsLock.unlock()485 eventsLock.unlock()
485 486
486 guard let vout = option?.vo else {487 guard let vo = vo else {
487 log.sendWarning("vo nil in flagEvents")488 log.sendWarning("vo nil in flagEvents")
488 return489 return
489 }490 }
490 vo_wakeup(vout)491 vo_wakeup(vo)
491 }492 }
492 493
493 func checkEvents() -> Int {494 func checkEvents() -> Int {
video/out/mac_common.swift+3−2
@@ -27,7 +27,8 @@ class MacCommon: Common { · 26 unmodified lines
27 @objc init(_ vo: UnsafeMutablePointer<vo>) {27 @objc init(_ vo: UnsafeMutablePointer<vo>) {
28 let newlog = mp_log_new(vo, vo.pointee.log, "mac")28 let newlog = mp_log_new(vo, vo.pointee.log, "mac")
29 super.init(newlog)29 super.init(newlog)
30 option = OptionHelper(vo)30 self.vo = vo
31 option = OptionHelper(vo, vo.pointee.global)
31 input = InputHelper(vo.pointee.input_ctx, option)32 input = InputHelper(vo.pointee.input_ctx, option)
32 timer = PreciseTimer(common: self)33 timer = PreciseTimer(common: self)
33 34
@@ -38,7 +39,7 @@ class MacCommon: Common { · 4 unmodified lines
38 }39 }
39 40
40 @objc func config(_ vo: UnsafeMutablePointer<vo>) -> Bool {41 @objc func config(_ vo: UnsafeMutablePointer<vo>) -> Bool {
41 option?.vo = vo42 self.vo = vo
42 43
43 DispatchQueue.main.sync {44 DispatchQueue.main.sync {
44 let previousActiveApp = getActiveApp()45 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