diff --git a/clientscr/Mac_Saver_Module.h b/clientscr/Mac_Saver_Module.h index 86e12067b1..49e2f4fdd6 100644 --- a/clientscr/Mac_Saver_Module.h +++ b/clientscr/Mac_Saver_Module.h @@ -48,6 +48,7 @@ void setGFXDefaultPeriod(double value); void setGFXSciencePeriod(double value); void setGGFXChangePeriod(double value); double getDTime(); +void doBoinc_Sleep(double seconds); void print_to_log_file(const char *format, ...); void strip_cr(char *buf); void PrintBacktrace(void); diff --git a/clientscr/Mac_Saver_ModuleView.h b/clientscr/Mac_Saver_ModuleView.h index e3cf558eb2..3adfeced3a 100644 --- a/clientscr/Mac_Saver_ModuleView.h +++ b/clientscr/Mac_Saver_ModuleView.h @@ -57,4 +57,5 @@ void setGFXSciencePeriod(double value); void setGGFXChangePeriod(double value); bool validateNumericString(CFStringRef s); double getDTime(); +void doBoinc_Sleep(double seconds); extern void print_to_log_file(const char *format, ...); diff --git a/clientscr/Mac_Saver_ModuleView.m b/clientscr/Mac_Saver_ModuleView.m index 8ab4fb2941..9f1afac10e 100644 --- a/clientscr/Mac_Saver_ModuleView.m +++ b/clientscr/Mac_Saver_ModuleView.m @@ -244,7 +244,7 @@ int signof(float x) { NSPoint imagePosition; char *msg; CFStringRef cf_msg; - AbsoluteTime timeToUnblock, frameStartTime = UpTime(); + double timeToBlock, frameStartTime = getDTime(); kern_return_t kernResult = kIOReturnError; UInt64 params; IOByteCount rcnt = sizeof(UInt64); @@ -490,8 +490,10 @@ int signof(float x) { [ self setAnimationTimeInterval:(1.0/newFrequency) ]; // setAnimationTimeInterval does not seem to be working, so we // throttle the screensaver directly here. - timeToUnblock = AddDurationToAbsolute(durationSecond/newFrequency, frameStartTime); - MPDelayUntil(&timeToUnblock); + timeToBlock = (1.0/newFrequency) - (getDTime() - frameStartTime); + if (timeToBlock > 0.0) { + doBoinc_Sleep(timeToBlock); + } } } diff --git a/clientscr/mac_saver_module.cpp b/clientscr/mac_saver_module.cpp index 3efef198d5..b3f43aa982 100644 --- a/clientscr/mac_saver_module.cpp +++ b/clientscr/mac_saver_module.cpp @@ -222,6 +222,11 @@ double getDTime() { } +void doBoinc_Sleep(double seconds) { + boinc_sleep(seconds); +} + + CScreensaver::CScreensaver() { struct ss_periods periods;