mirror of https://github.com/mpv-player/mpv
cocoa-cb: fix a warning with swift 4.1 and slight cleanup
the icc profile data is mutated to an UnsafeMutablePointer and could possibly changed. therefore the size of it should be accessed before a possible change.
This commit is contained in:
parent
b2dc69e347
commit
41d559c4a9
|
@ -127,9 +127,13 @@ class MPVHelper: NSObject {
|
|||
|
||||
func setRenderICCProfile(_ profile: NSColorSpace) {
|
||||
if mpvRenderContext == nil { return }
|
||||
var iccData = profile.iccProfileData
|
||||
iccData!.withUnsafeMutableBytes { (u8Ptr: UnsafeMutablePointer<UInt8>) in
|
||||
let iccBstr = bstrdup(nil, bstr(start: u8Ptr, len: iccData!.count))
|
||||
guard var iccData = profile.iccProfileData else {
|
||||
sendWarning("Invalid ICC profile data.")
|
||||
return
|
||||
}
|
||||
let iccSize = iccData.count
|
||||
iccData.withUnsafeMutableBytes { (u8Ptr: UnsafeMutablePointer<UInt8>) in
|
||||
let iccBstr = bstrdup(nil, bstr(start: u8Ptr, len: iccSize))
|
||||
var icc = mpv_byte_array(data: iccBstr.start, size: iccBstr.len)
|
||||
let params = mpv_render_param(type: MPV_RENDER_PARAM_ICC_PROFILE, data: &icc)
|
||||
mpv_render_context_set_parameter(mpvRenderContext, params)
|
||||
|
|
Loading…
Reference in New Issue