From f4c80d44021dd917aee64f58b0e2a79f20610057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Mon, 18 Sep 2017 20:25:34 +0300 Subject: osdep/io: add android related bullshit This fixes >2GiB files with at least API level 21. See: https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md for the gritty details. * Based on libavformat's things, except we do not care about API versions or NDKs without unistd.h, which contains all sorts of things that we utilize. * Redefines lseek to always point to the 64bit version. * Redefines fseeko to always point towards an inlined static implementation that utilizes the 64bit version of lseek underneath. --- osdep/io.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/osdep/io.h b/osdep/io.h index 35c7c52691..70ba5ac1ae 100644 --- a/osdep/io.h +++ b/osdep/io.h @@ -32,6 +32,33 @@ #include #endif +#ifdef __ANDROID__ +# include +# include + +// replace lseek with the 64bit variant +#ifdef lseek +# undef lseek +#endif +#define lseek(f,p,w) lseek64((f), (p), (w)) + +// replace possible fseeko with a +// lseek64 based solution. +#ifdef fseeko +# undef fseeko +#endif +static inline int mp_fseeko(FILE* fp, off64_t offset, int whence) { + int ret = -1; + if ((ret = fflush(fp)) != 0) { + return ret; + } + + return lseek64(fileno(fp), offset, whence) >= 0 ? 0 : -1; +} +#define fseeko(f,p,w) mp_fseeko((f), (p), (w)) + +#endif // __ANDROID__ + #ifndef O_BINARY #define O_BINARY 0 #endif -- cgit v1.2.3