From 2b2e07a3e0b6f1b76a3061a4f1d74824818a1c07 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Mon, 5 Dec 2022 13:55:31 -0800 Subject: [PATCH] sm7125-common: audio: Set minimum Binder access priority Use setMinSchedulerPolicy to enforce minimum thread priority when accessing the audio HAL to ANDROID_PRIORITY_AUDIO Test: instrumented Bug: 261496726 Change-Id: I700b04d3060e9405b1445206882a6131cea0d045 --- audio/impl/Device.cpp | 3 +++ audio/impl/DevicesFactory.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/audio/impl/Device.cpp b/audio/impl/Device.cpp index 6e55e7b..ae015a3 100644 --- a/audio/impl/Device.cpp +++ b/audio/impl/Device.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -183,6 +184,7 @@ std::tuple> Device::openOutputStreamCore(int32_t ioHandle if (status == OK) { streamOut = new StreamOut(this, halStream); ++mOpenedStreamsCount; + android::hardware::setMinSchedulerPolicy(streamOut, SCHED_NORMAL, ANDROID_PRIORITY_AUDIO); } status_t convertStatus = HidlUtils::audioConfigFromHal(halConfig, false /*isInput*/, suggestedConfig); @@ -220,6 +222,7 @@ std::tuple> Device::openInputStreamCore( if (status == OK) { streamIn = new StreamIn(this, halStream); ++mOpenedStreamsCount; + android::hardware::setMinSchedulerPolicy(streamIn, SCHED_NORMAL, ANDROID_PRIORITY_AUDIO); } status_t convertStatus = HidlUtils::audioConfigFromHal(halConfig, true /*isInput*/, suggestedConfig); diff --git a/audio/impl/DevicesFactory.cpp b/audio/impl/DevicesFactory.cpp index f44daf0..011f9ac 100644 --- a/audio/impl/DevicesFactory.cpp +++ b/audio/impl/DevicesFactory.cpp @@ -23,6 +23,8 @@ #include #include +#include +#include namespace android { namespace hardware { @@ -103,6 +105,7 @@ Return DevicesFactory::openDevice(const char* moduleName, Callback _hidl_c int halStatus = loadAudioInterface(moduleName, &halDevice); if (halStatus == OK) { result = new DeviceShim(halDevice); + android::hardware::setMinSchedulerPolicy(result, SCHED_NORMAL, ANDROID_PRIORITY_AUDIO); retval = Result::OK; } else if (halStatus == -EINVAL) { retval = Result::NOT_INITIALIZED;