Skip to content

Commit

Permalink
bootanimation: Switch to readahead
Browse files Browse the repository at this point in the history
Change-Id: I287132e311e96c0437df67c76b86bb47b8f8380e
  • Loading branch information
luca020400 committed Apr 25, 2016
1 parent eb9f3d3 commit 08d2d0b
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions cmds/bootanimation/BootAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <time.h>
#include <pthread.h>
#include <sys/select.h>
#include <sys/syscall.h>

#include <cutils/properties.h>

Expand Down Expand Up @@ -438,19 +439,14 @@ status_t BootAnimation::readyToRun() {
return NO_ERROR;

if (fd != NULL) {
// We could use readahead..
// ... if bionic supported it :(
//readahead(fd, 0, INT_MAX);
void *crappyBuffer = malloc(2*1024*1024);
if (crappyBuffer != NULL) {
// Read all the zip
while (!feof(fd))
fread(crappyBuffer, 1024, 2*1024, fd);

free(crappyBuffer);
} else {
ALOGW("Unable to allocate memory to preload the animation");
}
// Since including fcntl.h doesn't give us the wrapper, use the syscall.
// 32 bits takes LO/HI offset (we don't care about endianness of 0).
#if defined(__aarch64__) || defined(__x86_64__)
if (syscall(__NR_readahead, fd, 0, INT_MAX))
#else
if (syscall(__NR_readahead, fd, 0, 0, INT_MAX))
#endif
ALOGW("Unable to cache the animation");
fclose(fd);
}
#endif
Expand Down

0 comments on commit 08d2d0b

Please sign in to comment.