Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d77d836d authored by Andy Hung's avatar Andy Hung Committed by android-build-team Robot
Browse files

audioserver: impose memory restrictions

Impose restrictions to limit effect of excessive memory
allocation.

adb shell setprop audio.maxmem SOME_VALUE_GREATER_THAN_60MB_IN_BYTES
adb shell pkill audioserver

and see what happens when AudioTracks / AudioRecords are created

Test: as above
Bug: 69927864
Change-Id: I0a6a90db3321f066a25fb2fcd01e9f834d199979
(cherry picked from commit 21052719)
parent b718e342
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@ LOCAL_SHARED_LIBRARIES := \
	liblog \
	liblog \
	libhidltransport \
	libhidltransport \
	libhwbinder \
	libhwbinder \
	libmedia \
	libmedialogservice \
	libmedialogservice \
	libnbaio \
	libnbaio \
	libsoundtriggerservice \
	libsoundtriggerservice \
@@ -35,6 +36,7 @@ LOCAL_C_INCLUDES := \
	frameworks/av/media/libaaudio/include \
	frameworks/av/media/libaaudio/include \
	frameworks/av/media/libaaudio/src \
	frameworks/av/media/libaaudio/src \
	frameworks/av/media/libaaudio/src/binding \
	frameworks/av/media/libaaudio/src/binding \
	frameworks/av/media/libmedia \
	$(call include-path-for, audio-utils) \
	$(call include-path-for, audio-utils) \
	external/sonic \
	external/sonic \


+7 −0
Original line number Original line Diff line number Diff line
@@ -35,12 +35,19 @@
#include "AAudioService.h"
#include "AAudioService.h"
#include "utility/AAudioUtilities.h"
#include "utility/AAudioUtilities.h"
#include "MediaLogService.h"
#include "MediaLogService.h"
#include "MediaUtils.h"
#include "SoundTriggerHwService.h"
#include "SoundTriggerHwService.h"


using namespace android;
using namespace android;


int main(int argc __unused, char **argv)
int main(int argc __unused, char **argv)
{
{
    // TODO: update with refined parameters
    limitProcessMemory(
        "audio.maxmem", /* "ro.audio.maxmem", property that defines limit */
        (size_t)512 * (1 << 20), /* SIZE_MAX, upper limit in bytes */
        20 /* upper limit as percentage of physical RAM */);

    signal(SIGPIPE, SIG_IGN);
    signal(SIGPIPE, SIG_IGN);


    bool doLog = (bool) property_get_bool("ro.test_harness", 0);
    bool doLog = (bool) property_get_bool("ro.test_harness", 0);