|
55 | 55 | #define SYSTEM_BOOTANIMATION_FILE "/system/media/bootanimation.zip" |
56 | 56 | #define SYSTEM_ENCRYPTED_BOOTANIMATION_FILE "/system/media/bootanimation-encrypted.zip" |
57 | 57 |
|
| 58 | +extern "C" int clock_nanosleep(clockid_t clock_id, int flags, |
| 59 | + const struct timespec *request, |
| 60 | + struct timespec *remain); |
| 61 | + |
58 | 62 | namespace android { |
59 | 63 |
|
60 | 64 | // --------------------------------------------------------------------------- |
@@ -476,6 +480,7 @@ bool BootAnimation::movie() |
476 | 480 | for (int r=0 ; !part.count || r<part.count ; r++) { |
477 | 481 | for (int j=0 ; j<fcount && !exitPending(); j++) { |
478 | 482 | const Animation::Frame& frame(part.frames[j]); |
| 483 | + nsecs_t lastFrame = systemTime(); |
479 | 484 |
|
480 | 485 | if (r > 0) { |
481 | 486 | glBindTexture(GL_TEXTURE_2D, frame.tid); |
@@ -508,10 +513,18 @@ bool BootAnimation::movie() |
508 | 513 |
|
509 | 514 | nsecs_t now = systemTime(); |
510 | 515 | nsecs_t delay = frameDuration - (now - lastFrame); |
| 516 | + //ALOGD("%lld, %lld", ns2ms(now - lastFrame), ns2ms(delay)); |
511 | 517 | lastFrame = now; |
512 | | - long wait = ns2us(delay); |
513 | | - if (wait > 0) |
514 | | - usleep(wait); |
| 518 | + |
| 519 | + if (delay > 0) { |
| 520 | + struct timespec spec; |
| 521 | + spec.tv_sec = (now + delay) / 1000000000; |
| 522 | + spec.tv_nsec = (now + delay) % 1000000000; |
| 523 | + int err; |
| 524 | + do { |
| 525 | + err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL); |
| 526 | + } while (err<0 && errno == EINTR); |
| 527 | + } |
515 | 528 | } |
516 | 529 | usleep(part.pause * ns2us(frameDuration)); |
517 | 530 | } |
|
0 commit comments