1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 14:20:32 +05:30

Fix crashes when using mpv

This commit is contained in:
Arkadiusz Fal 2022-11-10 23:26:25 +01:00
parent 01d8e28d7c
commit c821285664

View File

@ -406,17 +406,20 @@ final class MPVClient: ObservableObject {
} }
func setDoubleAsync(_ name: String, _ value: Double) { func setDoubleAsync(_ name: String, _ value: Double) {
guard mpv != nil else { return }
var data = value var data = value
mpv_set_property_async(mpv, 0, name, MPV_FORMAT_DOUBLE, &data) mpv_set_property_async(mpv, 0, name, MPV_FORMAT_DOUBLE, &data)
} }
private func getDouble(_ name: String) -> Double { private func getDouble(_ name: String) -> Double {
guard mpv != nil else { return 0.0 }
var data = Double() var data = Double()
mpv_get_property(mpv, name, MPV_FORMAT_DOUBLE, &data) mpv_get_property(mpv, name, MPV_FORMAT_DOUBLE, &data)
return data return data
} }
private func getInt(_ name: String) -> Int { private func getInt(_ name: String) -> Int {
guard mpv != nil else { return 0 }
var data = Int64() var data = Int64()
mpv_get_property(mpv, name, MPV_FORMAT_INT64, &data) mpv_get_property(mpv, name, MPV_FORMAT_INT64, &data)
return Int(data) return Int(data)