audio: Allow vendors to configure hwbinder RPC buffer size
If persist.vendor.audio.hw.binder.size_kbyte property is set, its
value is used to configure the size of hwbinder's MMap buffer.
Bug: 114776290
Test: set the property, check logcat
Change-Id: Icb6a4d0ebe98eb702201f8a9f0fed3a91a24f7ba
diff --git a/audio/common/all-versions/default/service/service.cpp b/audio/common/all-versions/default/service/service.cpp
index c7ce638..ff1394e 100644
--- a/audio/common/all-versions/default/service/service.cpp
+++ b/audio/common/all-versions/default/service/service.cpp
@@ -24,16 +24,26 @@
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
#include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h>
#include <binder/ProcessState.h>
+#include <cutils/properties.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/LegacySupport.h>
+#include <hwbinder/ProcessState.h>
using namespace android::hardware;
using android::OK;
int main(int /* argc */, char* /* argv */ []) {
- android::ProcessState::initWithDriver("/dev/vndbinder");
+ ::android::ProcessState::initWithDriver("/dev/vndbinder");
// start a threadpool for vndbinder interactions
- android::ProcessState::self()->startThreadPool();
+ ::android::ProcessState::self()->startThreadPool();
+
+ const int32_t defaultValue = -1;
+ int32_t value =
+ property_get_int32("persist.vendor.audio.service.hwbinder.size_kbyte", defaultValue);
+ if (value != defaultValue) {
+ ALOGD("Configuring hwbinder with mmap size %d KBytes", value);
+ ProcessState::initWithMmapSize(static_cast<size_t>(value) * 1024);
+ }
configureRpcThreadpool(16, true /*callerWillJoin*/);
bool fail = registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK &&