From 64a2e656f614ab72fe3603faef304bc2324dca30 Mon Sep 17 00:00:00 2001 From: Collecting Date: Fri, 9 Jan 2026 05:31:18 +0000 Subject: [PATCH] fix(msvc/android): Compiler Errors for core.cpp Signed-off-by: Collecting --- src/core/core.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index eb261c4b0..0e45db065 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -11,13 +11,25 @@ #include #ifdef __linux__ +#include +#ifndef __ANDROID__ #include -#include // Required for madvise +#endif #endif #ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif #include #include + +#undef GetCurrentTime +#undef ERROR +#undef GetMessage #endif #include "audio_core/audio_core.h" @@ -495,11 +507,16 @@ struct System::Impl { if (device_memory) { #ifdef __linux__ - // Use BackingBasePointer() to get the raw pointer madvise(device_memory->buffer.BackingBasePointer(), device_memory->buffer.backing_size, MADV_DONTNEED); + + // Only call malloc_trim on non-Android Linux (glibc) + #ifndef __ANDROID__ malloc_trim(0); + #endif + + // Give the kernel time to update /proc/stats + std::this_thread::sleep_for(std::chrono::milliseconds(20)); #elif defined(_WIN32) - // Use BackingBasePointer() here as well VirtualAlloc(device_memory->buffer.BackingBasePointer(), device_memory->buffer.backing_size, MEM_RESET, PAGE_READWRITE); #endif }