From ba57ecb965bdcc8ba9cabcd210c3e82864ab2fe8 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 27 Jun 2022 00:23:34 +0200 Subject: [PATCH] Disable hardware decoding on Intel --- Model/Player/Backends/MPVClient.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Model/Player/Backends/MPVClient.swift b/Model/Player/Backends/MPVClient.swift index f26ccf08..585e3c0a 100644 --- a/Model/Player/Backends/MPVClient.swift +++ b/Model/Player/Backends/MPVClient.swift @@ -49,7 +49,7 @@ final class MPVClient: ObservableObject { checkError(mpv_set_option_string(mpv, "cache-secs", "20")) checkError(mpv_set_option_string(mpv, "cache-pause-wait", "2")) checkError(mpv_set_option_string(mpv, "keep-open", "yes")) - checkError(mpv_set_option_string(mpv, "hwdec", "auto-safe")) + checkError(mpv_set_option_string(mpv, "hwdec", machine == "x86_64" ? "no" : "auto-safe")) checkError(mpv_set_option_string(mpv, "vo", "libmpv")) checkError(mpv_initialize(mpv)) @@ -321,11 +321,24 @@ final class MPVClient: ObservableObject { return strArgs } - func checkError(_ status: CInt) { + private func checkError(_ status: CInt) { if status < 0 { logger.error(.init(stringLiteral: "MPV API error: \(String(cString: mpv_error_string(status)))\n")) } } + + private var machine: String { + var systeminfo = utsname() + uname(&systeminfo) + return withUnsafeBytes(of: &systeminfo.machine) { bufPtr -> String in + let data = Data(bufPtr) + if let lastIndex = data.lastIndex(where: { $0 != 0 }) { + return String(data: data[0 ... lastIndex], encoding: .isoLatin1)! + } else { + return String(data: data, encoding: .isoLatin1)! + } + } + } } #if os(macOS)