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

Commit 21c54213 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "mediaserver: configure and create threadpool for C2AIDL" into main am:...

Merge "mediaserver: configure and create threadpool for C2AIDL" into main am: 8665fad9 am: d3aa8f11

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/3273862



Change-Id: I0e392bb0708f335e45d644a9e59f9966f37bfb6a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents b6158c5e d3aa8f11
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();
}