fix(tvos): update MPVKit teardown
This commit is contained in:
@@ -74,6 +74,7 @@ class MpvPlayerCoreBase: NSObject {
|
|||||||
var isDisposing = false
|
var isDisposing = false
|
||||||
var isPipActive = false
|
var isPipActive = false
|
||||||
var isBackgrounded = false
|
var isBackgrounded = false
|
||||||
|
private var wakeupCallbackContext: UnsafeMutableRawPointer?
|
||||||
private var cachedHDREnabled = true
|
private var cachedHDREnabled = true
|
||||||
private var cachedLastSigPeak = 0.0
|
private var cachedLastSigPeak = 0.0
|
||||||
private var cachedDoviProfile: Int64 = 0
|
private var cachedDoviProfile: Int64 = 0
|
||||||
@@ -218,6 +219,11 @@ class MpvPlayerCoreBase: NSObject {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mpv stores this context without retaining it. Retain manually so the
|
||||||
|
// Swift core cannot deallocate while mpv can still fire wakeup callbacks.
|
||||||
|
let wakeupContext = Unmanaged.passRetained(self).toOpaque()
|
||||||
|
wakeupCallbackContext = wakeupContext
|
||||||
|
|
||||||
mpv_set_wakeup_callback(
|
mpv_set_wakeup_callback(
|
||||||
mpv,
|
mpv,
|
||||||
{ context in
|
{ context in
|
||||||
@@ -225,7 +231,7 @@ class MpvPlayerCoreBase: NSObject {
|
|||||||
let core = Unmanaged<MpvPlayerCoreBase>.fromOpaque(context).takeUnretainedValue()
|
let core = Unmanaged<MpvPlayerCoreBase>.fromOpaque(context).takeUnretainedValue()
|
||||||
core.readEvents()
|
core.readEvents()
|
||||||
},
|
},
|
||||||
UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())
|
wakeupContext
|
||||||
)
|
)
|
||||||
|
|
||||||
mpv_observe_property(mpv, Self.internalSigPeakObserverId, "video-params/sig-peak", MPV_FORMAT_DOUBLE)
|
mpv_observe_property(mpv, Self.internalSigPeakObserverId, "video-params/sig-peak", MPV_FORMAT_DOUBLE)
|
||||||
@@ -441,13 +447,18 @@ class MpvPlayerCoreBase: NSObject {
|
|||||||
cacheLock.unlock()
|
cacheLock.unlock()
|
||||||
|
|
||||||
let mpvHandle = mpv
|
let mpvHandle = mpv
|
||||||
|
let callbackContext = wakeupCallbackContext
|
||||||
mpv = nil
|
mpv = nil
|
||||||
|
wakeupCallbackContext = nil
|
||||||
|
|
||||||
let destroy = {
|
let destroy = {
|
||||||
if let mpvHandle {
|
if let mpvHandle {
|
||||||
mpv_set_wakeup_callback(mpvHandle, nil, nil)
|
mpv_set_wakeup_callback(mpvHandle, nil, nil)
|
||||||
mpv_terminate_destroy(mpvHandle)
|
mpv_terminate_destroy(mpvHandle)
|
||||||
}
|
}
|
||||||
|
if let callbackContext {
|
||||||
|
Unmanaged<MpvPlayerCoreBase>.fromOpaque(callbackContext).release()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if destroySynchronously {
|
if destroySynchronously {
|
||||||
|
|||||||
@@ -712,7 +712,7 @@
|
|||||||
repositoryURL = "https://github.com/edde746/MPVKit";
|
repositoryURL = "https://github.com/edde746/MPVKit";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = revision;
|
kind = revision;
|
||||||
revision = 86dcf97f04e572abb5641e74780251a1d5634ff3;
|
revision = 8b921258a0e963b574f96a919c26c1d1e185af72;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
/* End XCRemoteSwiftPackageReference section */
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/edde746/MPVKit",
|
"location" : "https://github.com/edde746/MPVKit",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "86dcf97f04e572abb5641e74780251a1d5634ff3"
|
"revision" : "8b921258a0e963b574f96a919c26c1d1e185af72"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/edde746/MPVKit",
|
"location" : "https://github.com/edde746/MPVKit",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "86dcf97f04e572abb5641e74780251a1d5634ff3"
|
"revision" : "8b921258a0e963b574f96a919c26c1d1e185af72"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user