diff options
author | luca020400 <luca.stefani.ge1@gmail.com> | 2016-04-24 19:59:01 +0200 |
---|---|---|
committer | Luca Stefani <luca.stefani.ge1@gmail.com> | 2016-04-25 12:43:49 -0700 |
commit | 08d2d0b19723e1a745e26a651eceb73d843fdd65 (patch) | |
tree | ee6a355da3cec8d903596ff2aa09546e69664628 /cmds | |
parent | eb9f3d3421cbadc386a7c9d443fd68d243ca5ef2 (diff) | |
download | frameworks_base-08d2d0b19723e1a745e26a651eceb73d843fdd65.zip frameworks_base-08d2d0b19723e1a745e26a651eceb73d843fdd65.tar.gz frameworks_base-08d2d0b19723e1a745e26a651eceb73d843fdd65.tar.bz2 |
bootanimation: Switch to readahead
Change-Id: I287132e311e96c0437df67c76b86bb47b8f8380e
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 4e7c9c4..9b8b135 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -27,6 +27,7 @@ #include <time.h> #include <pthread.h> #include <sys/select.h> +#include <sys/syscall.h> #include <cutils/properties.h> @@ -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 |