EffectChain setVolume with EffectChainmutex held
Bug: 315995877
Test: atest AudioTrackTest AudioRecordTest audioeffect_tests
Test: flush to Pixel and test audio functionality
Change-Id: I1389b6cefa1d38c364e24d01a038712e52834ff2
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 244a262..ac8018b 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1862,22 +1862,20 @@
}
}
-void ThreadBase::lockEffectChains_l(
- Vector<sp<IAfEffectChain>>& effectChains)
-NO_THREAD_SAFETY_ANALYSIS // calls EffectChain::lock()
+void ThreadBase::lockEffectChains_l(Vector<sp<IAfEffectChain>>& effectChains)
+ NO_THREAD_SAFETY_ANALYSIS // calls EffectChain::lock()
{
effectChains = mEffectChains;
- for (size_t i = 0; i < mEffectChains.size(); i++) {
- mEffectChains[i]->mutex().lock();
+ for (const auto& effectChain : effectChains) {
+ effectChain->mutex().lock();
}
}
-void ThreadBase::unlockEffectChains(
- const Vector<sp<IAfEffectChain>>& effectChains)
-NO_THREAD_SAFETY_ANALYSIS // calls EffectChain::unlock()
+void ThreadBase::unlockEffectChains(const Vector<sp<IAfEffectChain>>& effectChains)
+ NO_THREAD_SAFETY_ANALYSIS // calls EffectChain::unlock()
{
- for (size_t i = 0; i < effectChains.size(); i++) {
- effectChains[i]->mutex().unlock();
+ for (const auto& effectChain : effectChains) {
+ effectChain->mutex().unlock();
}
}
@@ -5501,7 +5499,7 @@
sp<IAfEffectChain> chain = getEffectChain_l(AUDIO_SESSION_OUTPUT_MIX);
if (chain != 0) {
uint32_t v = (uint32_t)(masterVolume * (1 << 24));
- chain->setVolume_l(&v, &v);
+ chain->setVolume(&v, &v);
masterVolume = (float)((v + (1 << 23)) >> 24);
chain.clear();
}
@@ -5836,7 +5834,7 @@
mixedTracks++;
- // track->mainBuffer() != mSinkBuffer or mMixerBuffer means
+ // track->mainBuffer() != mSinkBuffer and mMixerBuffer means
// there is an effect chain connected to the track
chain.clear();
if (track->mainBuffer() != mSinkBuffer &&
@@ -5940,7 +5938,7 @@
track->setFinalVolume(vrf, vlf);
// Delegate volume control to effect in track effect chain if needed
- if (chain != 0 && chain->setVolume_l(&vl, &vr)) {
+ if (chain != 0 && chain->setVolume(&vl, &vr)) {
// Do not ramp volume if volume is controlled by effect
param = AudioMixer::VOLUME;
// Update remaining floating point volume levels
@@ -6680,8 +6678,8 @@
// Convert volumes from float to 8.24
uint32_t vl = (uint32_t)(left * (1 << 24));
uint32_t vr = (uint32_t)(right * (1 << 24));
- // Direct/Offload effect chains set output volume in setVolume_l().
- (void)mEffectChains[0]->setVolume_l(&vl, &vr);
+ // Direct/Offload effect chains set output volume in setVolume().
+ (void)mEffectChains[0]->setVolume(&vl, &vr);
} else {
// otherwise we directly set the volume.
setVolumeForOutput_l(left, right);
@@ -11026,7 +11024,7 @@
// only one effect chain can be present on DirectOutputThread, so if
// there is one, the track is connected to it
if (!mEffectChains.isEmpty()) {
- mEffectChains[0]->setVolume_l(&vol, &vol);
+ mEffectChains[0]->setVolume(&vol, &vol);
volume = (float)vol / (1 << 24);
}
// Try to use HW volume control and fall back to SW control if not implemented