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
fourteen-wip
Andy Hung 2 years ago committed by Simon1511
parent 26c9c2eab6
commit 5a7d061dca
  1. 3
      audio/impl/Device.cpp
  2. 3
      audio/impl/DevicesFactory.cpp

@ -30,6 +30,7 @@
#include <algorithm>
#include <android/log.h>
#include <hidl/HidlTransportSupport.h>
#include <mediautils/MemoryLeakTrackUtil.h>
#include <memunreachable/memunreachable.h>
@ -183,6 +184,7 @@ std::tuple<Result, sp<IStreamOut>> 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<Result, sp<IStreamIn>> 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);

@ -23,6 +23,8 @@
#include <string.h>
#include <android/log.h>
#include <hidl/HidlTransportSupport.h>
#include <system/thread_defs.h>
namespace android {
namespace hardware {
@ -103,6 +105,7 @@ Return<void> 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;

Loading…
Cancel
Save