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

Commit 1ed80f8f authored by Sungtak Lee's avatar Sungtak Lee
Browse files

mediaserver: configure and create threadpool for C2AIDL

Flag: EXEMPT bugfix
Bug: 359802236
Test: presubmit
Change-Id: I8b6c8e86b5d6f10dbc88ad3a69ed18f2aa589886
parent 2d27d437
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ soong_config_module_type {
mediaserver_cc_binary {
    name: "mediaserver",

    defaults: ["libcodec2_hal_selection"],

    srcs: ["main_mediaserver.cpp"],

    shared_libs: [
@@ -61,6 +63,7 @@ mediaserver_cc_binary {
        "libicu",
        "libfmq",
        "libbinder",
        "libbinder_ndk",
        "libhidlbase",
        "liblog",
        "libmediaplayerservice",
+18 −3
Original line number Diff line number Diff line
@@ -17,11 +17,12 @@

#define LOG_TAG "mediaserver"
//#define LOG_NDEBUG 0

#include <android/binder_process.h>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <hidl/HidlTransportSupport.h>
#include <codec2/common/HalSelection.h>
#include <utils/Log.h>
#include "RegisterExtensions.h"

@@ -30,6 +31,14 @@

using namespace android;

namespace {
    constexpr int kCodecThreadPoolCount = 16;

    // This is the default thread count for binder thread pool
    // if the thread count is not configured.
    constexpr int kDefaultBinderThreadPoolCount = 15;
}; // anonymous

int main(int argc __unused, char **argv __unused)
{
    signal(SIGPIPE, SIG_IGN);
@@ -40,8 +49,14 @@ int main(int argc __unused, char **argv __unused)
    MediaPlayerService::instantiate();
    ResourceManagerService::instantiate();
    registerExtensions();
    ::android::hardware::configureRpcThreadpool(16, false);

    bool aidl = ::android::IsCodec2AidlHalSelected();
    if (!aidl) {
        ::android::hardware::configureRpcThreadpool(kCodecThreadPoolCount, false);
    } else {
        ABinderProcess_setThreadPoolMaxThreadCount(
                kCodecThreadPoolCount + kDefaultBinderThreadPoolCount);
    }
    ProcessState::self()->startThreadPool();
    IPCThreadState::self()->joinThreadPool();
    ::android::hardware::joinRpcThreadpool();
}