summaryrefslogtreecommitdiff
path: root/audio/effect/all-versions/default/Effect.cpp
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-08 17:29:03 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-08 17:29:03 +0000
commit9ac16c42d3722424277f971e9a44a99e6ee1679d (patch)
tree9f13793d31ef6c216531cc322e5780fe38a84fbe /audio/effect/all-versions/default/Effect.cpp
parentc79e56f9faf756d4b0b034df7d2bf83897c4b715 (diff)
parentd62835f99043f85ecfc1d7283add550b047068f9 (diff)
Snap for 10276566 from d62835f99043f85ecfc1d7283add550b047068f9 to tm-platform-release
Change-Id: I11db7571dfc38ac69bd4d2c34c27d42ae30ca595
Diffstat (limited to 'audio/effect/all-versions/default/Effect.cpp')
-rw-r--r--audio/effect/all-versions/default/Effect.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/audio/effect/all-versions/default/Effect.cpp b/audio/effect/all-versions/default/Effect.cpp
index 87e1ab7a7d..5aecd324eb 100644
--- a/audio/effect/all-versions/default/Effect.cpp
+++ b/audio/effect/all-versions/default/Effect.cpp
@@ -240,16 +240,6 @@ class ProcessThread : public Thread {
};
bool ProcessThread::threadLoop() {
- // For a spatializer effect, we perform scheduler adjustments to reduce glitches and power.
- {
- effect_descriptor_t halDescriptor{};
- if ((*mEffect)->get_descriptor(mEffect, &halDescriptor) == NO_ERROR &&
- memcmp(&halDescriptor.type, FX_IID_SPATIALIZER, sizeof(effect_uuid_t)) == 0) {
- const status_t status = scheduler::updateSpatializerPriority(gettid());
- ALOGW_IF(status != OK, "Failed to update Spatializer priority");
- }
- }
-
// This implementation doesn't return control back to the Thread until it decides to stop,
// as the Thread uses mutexes, and this can lead to priority inversion.
while (!std::atomic_load_explicit(mStop, std::memory_order_acquire)) {
@@ -570,6 +560,15 @@ Return<void> Effect::prepareForProcessing(prepareForProcessing_cb _hidl_cb) {
return Void();
}
+ // For a spatializer effect, we perform scheduler adjustments to reduce glitches and power.
+ // We do it here instead of the ProcessThread::threadLoop to ensure that mHandle is valid.
+ if (effect_descriptor_t halDescriptor{};
+ (*mHandle)->get_descriptor(mHandle, &halDescriptor) == NO_ERROR &&
+ memcmp(&halDescriptor.type, FX_IID_SPATIALIZER, sizeof(effect_uuid_t)) == 0) {
+ const status_t status = scheduler::updateSpatializerPriority(mProcessThread->getTid());
+ ALOGW_IF(status != OK, "Failed to update Spatializer priority");
+ }
+
mStatusMQ = std::move(tempStatusMQ);
_hidl_cb(Result::OK, *mStatusMQ->getDesc());
return Void();