diff --git a/osdep/mac/swift_compat.swift b/osdep/mac/swift_compat.swift index 6924d5cfca..54fadee3e2 100644 --- a/osdep/mac/swift_compat.swift +++ b/osdep/mac/swift_compat.swift @@ -15,6 +15,16 @@ * License along with mpv. If not, see . */ +#if !swift(>=5.7) +extension NSCondition { + func withLock(_ body: () throws -> R) rethrows -> R { + self.lock() + defer { self.unlock() } + return try body() + } +} +#endif + #if !swift(>=5.0) extension Data { mutating func withUnsafeMutableBytes(_ body: (UnsafeMutableRawBufferPointer) throws -> Type) rethrows -> Type {