summaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2022-12-05 13:55:31 -0800
committerAndy Hung <hunga@google.com>2022-12-05 14:42:48 -0800
commit43966208b7ef50c51a58e82c6d7c10ee9e115860 (patch)
tree770a65fa1c2bda2e84ea7c9339cfda7994f3ea53 /audio
parent2c7c34e466586c927d16aa44be8da97574040194 (diff)
audio HAL: 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
Diffstat (limited to 'audio')
-rw-r--r--audio/core/all-versions/default/Device.cpp3
-rw-r--r--audio/core/all-versions/default/DevicesFactory.cpp3
-rw-r--r--audio/effect/all-versions/default/EffectsFactory.cpp3
3 files changed, 9 insertions, 0 deletions
diff --git a/audio/core/all-versions/default/Device.cpp b/audio/core/all-versions/default/Device.cpp
index b954fcd6f8..d03118ae5d 100644
--- a/audio/core/all-versions/default/Device.cpp
+++ b/audio/core/all-versions/default/Device.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);
diff --git a/audio/core/all-versions/default/DevicesFactory.cpp b/audio/core/all-versions/default/DevicesFactory.cpp
index f44daf0b0e..011f9ac4c2 100644
--- a/audio/core/all-versions/default/DevicesFactory.cpp
+++ b/audio/core/all-versions/default/DevicesFactory.cpp
@@ -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;
diff --git a/audio/effect/all-versions/default/EffectsFactory.cpp b/audio/effect/all-versions/default/EffectsFactory.cpp
index e93ad893a8..9bf309c224 100644
--- a/audio/effect/all-versions/default/EffectsFactory.cpp
+++ b/audio/effect/all-versions/default/EffectsFactory.cpp
@@ -32,6 +32,7 @@
#include <UuidUtils.h>
#include <android/log.h>
+#include <hidl/HidlTransportSupport.h>
#include <media/EffectsFactoryApi.h>
#include <system/audio_effects/effect_aec.h>
#include <system/audio_effects/effect_agc.h>
@@ -44,6 +45,7 @@
#include <system/audio_effects/effect_presetreverb.h>
#include <system/audio_effects/effect_virtualizer.h>
#include <system/audio_effects/effect_visualizer.h>
+#include <system/thread_defs.h>
#include <util/EffectUtils.h>
namespace android {
@@ -189,6 +191,7 @@ Return<void> EffectsFactory::createEffectImpl(const Uuid& uuid, int32_t session,
status = (*handle)->get_descriptor(handle, &halDescriptor);
if (status == OK) {
effect = dispatchEffectInstanceCreation(halDescriptor, handle);
+ android::hardware::setMinSchedulerPolicy(effect, SCHED_NORMAL, ANDROID_PRIORITY_AUDIO);
effectId = EffectMap::getInstance().add(handle);
} else {
ALOGE("Error querying effect descriptor for %s: %s",