diff --git a/src/graphics.cpp b/src/graphics.cpp index 01e80c7..43542be 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -34,6 +34,7 @@ #include "etc-internal.h" #include "binding.h" #include "perftimer.h" +#include "debugwriter.h" #include #include @@ -41,6 +42,7 @@ #include #include +#include #include struct PingPong @@ -342,8 +344,19 @@ private: struct timespec req; req.tv_sec = 0; req.tv_nsec = ticks / tickFreqNS; + while (nanosleep(&req, &req) == -1) - ; + { + if (errno != EINTR) + { + Debug() << "nanosleep failed for ticks =" << ticks; + errno = 0; + + break; + } + + errno = 0; + } #else SDL_Delay(ticks / tickFreqMS); #endif