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

Commit 39bf2c31 authored by Shunkai Yao's avatar Shunkai Yao
Browse files

Audio AIDL HAL priority update

Enable RT priority inheritance.
Set minimum Audio AIDL HAL Binder access priority to ANDROID_PRIORITY_AUDIO.

Bug: 261496726
Test: atest VtsHalAudioEffectTargetTest
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I584d80f4fe344e4bfae5765cac2afb92313b6a39
parent 1186b991
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -15,10 +15,13 @@
 */

#define LOG_TAG "AHAL_EffectFactory"
#include <android-base/logging.h>
#include <dlfcn.h>
#include <unordered_set>

#include <android-base/logging.h>
#include <android/binder_ibinder_platform.h>
#include <system/thread_defs.h>

#include "effect-impl/EffectTypes.h"
#include "effect-impl/EffectUUID.h"
#include "effectFactory-impl/EffectFactory.h"
@@ -109,6 +112,8 @@ ndk::ScopedAStatus Factory::createEffect(const AudioUuid& in_impl_uuid,
            return ndk::ScopedAStatus::fromExceptionCode(EX_TRANSACTION_FAILED);
        }
        *_aidl_return = effectSp;
        AIBinder_setMinSchedulerPolicy(effectSp->asBinder().get(), SCHED_NORMAL,
                                       ANDROID_PRIORITY_AUDIO);
        mEffectUuidMap[std::weak_ptr<IEffect>(effectSp)] = in_impl_uuid;
        LOG(DEBUG) << __func__ << ": instance " << effectSp.get() << " created successfully";
        return ndk::ScopedAStatus::ok();
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#define LOG_TAG "AHAL_Module"
#include <android-base/logging.h>
#include <android/binder_ibinder_platform.h>

#include <Utils.h>
#include <aidl/android/media/audio/common/AudioInputFlags.h>
@@ -307,6 +308,8 @@ ndk::ScopedAStatus Module::setModuleDebug(
ndk::ScopedAStatus Module::getTelephony(std::shared_ptr<ITelephony>* _aidl_return) {
    if (mTelephony == nullptr) {
        mTelephony = ndk::SharedRefBase::make<Telephony>();
        AIBinder_setMinSchedulerPolicy(mTelephony->asBinder().get(), SCHED_NORMAL,
                                       ANDROID_PRIORITY_AUDIO);
    }
    *_aidl_return = mTelephony;
    LOG(DEBUG) << __func__ << ": returning instance of ITelephony: " << _aidl_return->get();
@@ -525,6 +528,7 @@ ndk::ScopedAStatus Module::openInputStream(const OpenInputStreamArguments& in_ar
    if (auto status = stream->init(); !status.isOk()) {
        return status;
    }
    AIBinder_setMinSchedulerPolicy(stream->asBinder().get(), SCHED_NORMAL, ANDROID_PRIORITY_AUDIO);
    StreamWrapper streamWrapper(stream);
    auto patchIt = mPatches.find(in_args.portConfigId);
    if (patchIt != mPatches.end()) {
@@ -575,6 +579,7 @@ ndk::ScopedAStatus Module::openOutputStream(const OpenOutputStreamArguments& in_
    if (auto status = stream->init(); !status.isOk()) {
        return status;
    }
    AIBinder_setMinSchedulerPolicy(stream->asBinder().get(), SCHED_NORMAL, ANDROID_PRIORITY_AUDIO);
    StreamWrapper streamWrapper(stream);
    auto patchIt = mPatches.find(in_args.portConfigId);
    if (patchIt != mPatches.end()) {
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ service vendor.audio-effect-hal-aidl /vendor/bin/hw/android.hardware.audio.effec
    # media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
    group audio media
    capabilities BLOCK_SUSPEND
    # setting RLIMIT_RTPRIO allows binder RT priority inheritance
    rlimit rtprio 10 10
    ioprio rt 4
    task_profiles ProcessCapacityHigh HighPerformance
    onrestart restart audioserver
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ service vendor.audio-hal-aidl /vendor/bin/hw/android.hardware.audio.service-aidl
    # media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
    group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct wakelock context_hub
    capabilities BLOCK_SUSPEND
    # setting RLIMIT_RTPRIO allows binder RT priority inheritance
    rlimit rtprio 10 10
    ioprio rt 4
    task_profiles ProcessCapacityHigh HighPerformance
    onrestart restart audioserver
+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "core-impl/Module.h"

#include <android-base/logging.h>
#include <android/binder_ibinder_platform.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>

@@ -44,6 +45,8 @@ int main() {

    // Make the default module
    auto moduleDefault = ndk::SharedRefBase::make<Module>();
    AIBinder_setMinSchedulerPolicy(moduleDefault->asBinder().get(), SCHED_NORMAL,
                                   ANDROID_PRIORITY_AUDIO);
    const std::string moduleDefaultName = std::string() + Module::descriptor + "/default";
    status = AServiceManager_addService(moduleDefault->asBinder().get(), moduleDefaultName.c_str());
    CHECK_EQ(STATUS_OK, status);