media codec2: Remove use of hardcoded PAGE_SIZE 4096
bionic hard codes the PAGE_SIZE macro as 4096. This is going away as
Android begins to support larger page sizes. Remove the usage of this
assumption from media codec2 source; use instead getpagesize() which
provides the real pagesize.
Test: mma
Bug: 295016003
Change-Id: If70250d4ef1e838756082974abd4d2e41e28f343
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
diff --git a/media/codec2/vndk/C2AllocatorIon.cpp b/media/codec2/vndk/C2AllocatorIon.cpp
index a6a733e..582a993 100644
--- a/media/codec2/vndk/C2AllocatorIon.cpp
+++ b/media/codec2/vndk/C2AllocatorIon.cpp
@@ -179,6 +179,7 @@
static Impl *Alloc(int ionFd, size_t size, size_t align, unsigned heapMask, unsigned flags, C2Allocator::id_t id);
c2_status_t map(size_t offset, size_t size, C2MemoryUsage usage, C2Fence *fence, void **addr) {
+ static const size_t kPageSize = getpagesize();
(void)fence; // TODO: wait for fence
*addr = nullptr;
if (!mMappings.lock()->empty()) {
@@ -201,7 +202,7 @@
prot |= PROT_WRITE;
}
- size_t alignmentBytes = offset % PAGE_SIZE;
+ size_t alignmentBytes = offset % kPageSize;
size_t mapOffset = offset - alignmentBytes;
size_t mapSize = size + alignmentBytes;
Mapping map = { nullptr, alignmentBytes, mapSize };