- fix app crash with old version of IntelPowerGadget (#202)

This commit is contained in:
Serhiy Mytrovtsiy
2020-11-30 17:02:53 +01:00
parent 96a21051ea
commit 4b73023b43

View File

@@ -280,11 +280,26 @@ public class FrequencyReader: Reader<Double> {
return
}
let PG_InitializePointer = CFBundleGetFunctionPointerForName(self.bundle, "PG_Initialize" as CFString)
let PG_ShutdownPointer = CFBundleGetFunctionPointerForName(self.bundle, "PG_Shutdown" as CFString)
let PG_ReadSamplePointer = CFBundleGetFunctionPointerForName(self.bundle, "PG_ReadSample" as CFString)
let PGSample_GetIAFrequencyPointer = CFBundleGetFunctionPointerForName(self.bundle, "PGSample_GetIAFrequency" as CFString)
let PGSample_ReleasePointer = CFBundleGetFunctionPointerForName(self.bundle, "PGSample_Release" as CFString)
guard let PG_InitializePointer = CFBundleGetFunctionPointerForName(self.bundle, "PG_Initialize" as CFString) else {
os_log(.error, log: log, "failed to find PG_Initialize")
return
}
guard let PG_ShutdownPointer = CFBundleGetFunctionPointerForName(self.bundle, "PG_Shutdown" as CFString) else {
os_log(.error, log: log, "failed to find PG_Shutdown")
return
}
guard let PG_ReadSamplePointer = CFBundleGetFunctionPointerForName(self.bundle, "PG_ReadSample" as CFString) else {
os_log(.error, log: log, "failed to find PG_ReadSample")
return
}
guard let PGSample_GetIAFrequencyPointer = CFBundleGetFunctionPointerForName(self.bundle, "PGSample_GetIAFrequency" as CFString) else {
os_log(.error, log: log, "failed to find PGSample_GetIAFrequency")
return
}
guard let PGSample_ReleasePointer = CFBundleGetFunctionPointerForName(self.bundle, "PGSample_Release" as CFString) else {
os_log(.error, log: log, "failed to find PGSample_Release")
return
}
let PG_Initialize = unsafeBitCast(PG_InitializePointer, to: PG_InitializePointerFunction.self)
self.PG_Shutdown = unsafeBitCast(PG_ShutdownPointer, to: PG_ShutdownPointerFunction.self)