Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac/type: change array type from Any to Sendable #15611

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions osdep/mac/event_helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension EventHelper {
let bool: Bool?
let int: Int64?
let double: Double?
let array: [Any?]
let array: [Sendable?]

init(
name: String = "",
Expand All @@ -51,8 +51,7 @@ extension EventHelper {
bool: Bool? = nil,
int: Int64? = nil,
double: Double? = nil,
array: [Any?] = []

array: [Sendable?] = []
) {
self.name = name
self.format = format
Expand Down
6 changes: 3 additions & 3 deletions osdep/mac/remote_command_center.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class RemoteCommandCenter: EventSubscriber {
]) { (_, new) in new }
}

func updateCover(tracks: [Any?]) {
func updateCover(tracks: [Sendable?]) {
coverLock.withLock {
coverTime = mach_absolute_time()
coverPath = nil
Expand All @@ -183,12 +183,12 @@ class RemoteCommandCenter: EventSubscriber {
}
}

func generateCover(tracks: [Any?], time: UInt64) {
func generateCover(tracks: [Sendable?], time: UInt64) {
var imageCoverPath: String?
var externalCoverPath: String?

for item in tracks {
guard let track = item as? [String: Any?] else { continue }
guard let track = item as? [String: Sendable?] else { continue }
if (track["image"] as? Bool) == true {
// opened file is an image
if track["external"] as? Bool == false && track["albumart"] as? Bool == false && imageCoverPath == nil {
Expand Down
14 changes: 7 additions & 7 deletions osdep/mac/type_helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,35 @@ class TypeHelper {
}

// MPV_FORMAT_NODE > MPV_FORMAT_NODE_ARRAY
class func nodeToArray(_ node: mpv_node?) -> [Any?] {
var array: [Any?] = []
class func nodeToArray(_ node: mpv_node?) -> [Sendable?] {
var array: [Sendable?] = []
guard let list = node?.u.list?.pointee,
let values = list.values else { return array }

for index in 0..<Int(list.num) {
array.append(TypeHelper.nodeToAny(values[index]))
array.append(TypeHelper.nodeToAnyValue(values[index]))
}

return array
}

// MPV_FORMAT_NODE > MPV_FORMAT_NODE_MAP
class func nodeToDict(_ node: mpv_node?) -> [String: Any?] {
var dict: [String: Any?] = [:]
class func nodeToDict(_ node: mpv_node?) -> [String: Sendable?] {
var dict: [String: Sendable?] = [:]
guard let list = node?.u.list?.pointee,
let values = list.values else { return dict }

for index in 0..<Int(list.num) {
guard let keyPtr = list.keys?[index] else { continue }
let key = String(cString: keyPtr)
dict[key] = TypeHelper.nodeToAny(values[index])
dict[key] = TypeHelper.nodeToAnyValue(values[index])
}

return dict
}

// MPV_FORMAT_NODE
class func nodeToAny(_ node: mpv_node) -> Any? {
class func nodeToAnyValue(_ node: mpv_node) -> Sendable? {
switch node.format {
case MPV_FORMAT_STRING: return TypeHelper.nodeToString(node)
case MPV_FORMAT_FLAG: return TypeHelper.nodeToBool(node)
Expand Down
Loading