Merge "Fix lvm process copy length"
diff --git a/media/libaudiohal/impl/EffectConversionHelperAidl.cpp b/media/libaudiohal/impl/EffectConversionHelperAidl.cpp
index 52fed91..4c58fe9 100644
--- a/media/libaudiohal/impl/EffectConversionHelperAidl.cpp
+++ b/media/libaudiohal/impl/EffectConversionHelperAidl.cpp
@@ -72,14 +72,13 @@
 
 EffectConversionHelperAidl::EffectConversionHelperAidl(
         std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
-        int32_t sessionId, int32_t ioId, const Descriptor& desc)
+        int32_t sessionId, int32_t ioId, const Descriptor& desc, bool isProxy)
     : mSessionId(sessionId),
       mIoId(ioId),
       mDesc(desc),
       mEffect(std::move(effect)),
       mIsInputStream(mDesc.common.flags.type == Flags::Type::PRE_PROC),
-      mIsProxyEffect(mDesc.common.id.proxy.has_value() &&
-                     mDesc.common.id.proxy.value() == mDesc.common.id.uuid) {
+      mIsProxyEffect(isProxy) {
     mCommon.session = sessionId;
     mCommon.ioHandle = ioId;
     mCommon.input = mCommon.output = kDefaultAudioConfig;
@@ -319,17 +318,25 @@
             mEffect->setParameter(Parameter::make<Parameter::deviceDescription>(aidlDevices))));
     return *static_cast<int32_t*>(pReplyData) = OK;
 }
+
 status_t EffectConversionHelperAidl::handleSetVolume(uint32_t cmdSize, const void* pCmdData,
-                                                     uint32_t* replySize __unused,
-                                                     void* pReplyData __unused) {
+                                                     uint32_t* replySize, void* pReplyData) {
     if (cmdSize != 2 * sizeof(uint32_t) || !pCmdData) {
         ALOGE("%s parameter invalid %u %p", __func__, cmdSize, pCmdData);
         return BAD_VALUE;
     }
-    Parameter::VolumeStereo volume = {.left = (float)(*(uint32_t*)pCmdData) / (1 << 24),
-                                      .right = (float)(*(uint32_t*)pCmdData + 1) / (1 << 24)};
+
+    constexpr uint32_t unityGain = 1 << 24;
+    Parameter::VolumeStereo volume = {.left = (float)(*(uint32_t*)pCmdData) / unityGain,
+                                      .right = (float)(*(uint32_t*)pCmdData + 1) / unityGain};
     RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
             mEffect->setParameter(Parameter::make<Parameter::volumeStereo>(volume))));
+
+    // write unity gain back if volume was successfully set
+    if (replySize && *replySize == 2 * sizeof(uint32_t) && pReplyData) {
+        constexpr uint32_t vol_ret[2] = {unityGain, unityGain};
+        memcpy(pReplyData, vol_ret, sizeof(vol_ret));
+    }
     return OK;
 }
 
diff --git a/media/libaudiohal/impl/EffectConversionHelperAidl.h b/media/libaudiohal/impl/EffectConversionHelperAidl.h
index 0c682ff..e2cf87f 100644
--- a/media/libaudiohal/impl/EffectConversionHelperAidl.h
+++ b/media/libaudiohal/impl/EffectConversionHelperAidl.h
@@ -54,7 +54,7 @@
     EffectConversionHelperAidl(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc);
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxy);
 
     status_t handleSetParameter(uint32_t cmdSize, const void* pCmdData, uint32_t* replySize,
                                 void* pReplyData);
diff --git a/media/libaudiohal/impl/EffectHalAidl.cpp b/media/libaudiohal/impl/EffectHalAidl.cpp
index faf5f45..a5f2c61 100644
--- a/media/libaudiohal/impl/EffectHalAidl.cpp
+++ b/media/libaudiohal/impl/EffectHalAidl.cpp
@@ -89,64 +89,64 @@
     ALOGI("%s create UUID %s", __func__, typeUuid.toString().c_str());
     if (typeUuid ==
         ::aidl::android::hardware::audio::effect::getEffectTypeUuidAcousticEchoCanceler()) {
-        mConversion =
-                std::make_unique<android::effect::AidlConversionAec>(effect, sessionId, ioId, desc);
+        mConversion = std::make_unique<android::effect::AidlConversionAec>(effect, sessionId, ioId,
+                                                                           desc, mIsProxyEffect);
     } else if (typeUuid == ::aidl::android::hardware::audio::effect::
                                    getEffectTypeUuidAutomaticGainControlV1()) {
         mConversion = std::make_unique<android::effect::AidlConversionAgc1>(effect, sessionId, ioId,
-                                                                            desc);
+                                                                            desc, mIsProxyEffect);
     } else if (typeUuid == ::aidl::android::hardware::audio::effect::
                                    getEffectTypeUuidAutomaticGainControlV2()) {
         mConversion = std::make_unique<android::effect::AidlConversionAgc2>(effect, sessionId, ioId,
-                                                                            desc);
+                                                                            desc, mIsProxyEffect);
     } else if (typeUuid == ::aidl::android::hardware::audio::effect::getEffectTypeUuidBassBoost()) {
-        mConversion = std::make_unique<android::effect::AidlConversionBassBoost>(effect, sessionId,
-                                                                                 ioId, desc);
+        mConversion = std::make_unique<android::effect::AidlConversionBassBoost>(
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else if (typeUuid == ::aidl::android::hardware::audio::effect::getEffectTypeUuidDownmix()) {
-        mConversion = std::make_unique<android::effect::AidlConversionDownmix>(effect, sessionId,
-                                                                               ioId, desc);
+        mConversion = std::make_unique<android::effect::AidlConversionDownmix>(
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else if (typeUuid ==
                ::aidl::android::hardware::audio::effect::getEffectTypeUuidDynamicsProcessing()) {
-        mConversion =
-                std::make_unique<android::effect::AidlConversionDp>(effect, sessionId, ioId, desc);
+        mConversion = std::make_unique<android::effect::AidlConversionDp>(effect, sessionId, ioId,
+                                                                          desc, mIsProxyEffect);
     } else if (typeUuid == ::aidl::android::hardware::audio::effect::getEffectTypeUuidEnvReverb()) {
-        mConversion = std::make_unique<android::effect::AidlConversionEnvReverb>(effect, sessionId,
-                                                                                 ioId, desc);
+        mConversion = std::make_unique<android::effect::AidlConversionEnvReverb>(
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else if (typeUuid == ::aidl::android::hardware::audio::effect::getEffectTypeUuidEqualizer()) {
-        mConversion =
-                std::make_unique<android::effect::AidlConversionEq>(effect, sessionId, ioId, desc);
+        mConversion = std::make_unique<android::effect::AidlConversionEq>(effect, sessionId, ioId,
+                                                                          desc, mIsProxyEffect);
     } else if (typeUuid ==
                ::aidl::android::hardware::audio::effect::getEffectTypeUuidHapticGenerator()) {
         mConversion = std::make_unique<android::effect::AidlConversionHapticGenerator>(
-                effect, sessionId, ioId, desc);
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else if (typeUuid ==
                ::aidl::android::hardware::audio::effect::getEffectTypeUuidLoudnessEnhancer()) {
         mConversion = std::make_unique<android::effect::AidlConversionLoudnessEnhancer>(
-                effect, sessionId, ioId, desc);
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else if (typeUuid ==
                ::aidl::android::hardware::audio::effect::getEffectTypeUuidNoiseSuppression()) {
         mConversion = std::make_unique<android::effect::AidlConversionNoiseSuppression>(
-                effect, sessionId, ioId, desc);
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else if (typeUuid ==
                ::aidl::android::hardware::audio::effect::getEffectTypeUuidPresetReverb()) {
         mConversion = std::make_unique<android::effect::AidlConversionPresetReverb>(
-                effect, sessionId, ioId, desc);
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else if (typeUuid ==
                ::aidl::android::hardware::audio::effect::getEffectTypeUuidSpatializer()) {
         mConversion = std::make_unique<android::effect::AidlConversionSpatializer>(
-                effect, sessionId, ioId, desc);
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else if (typeUuid ==
                ::aidl::android::hardware::audio::effect::getEffectTypeUuidVirtualizer()) {
         mConversion = std::make_unique<android::effect::AidlConversionVirtualizer>(
-                effect, sessionId, ioId, desc);
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else if (typeUuid ==
                ::aidl::android::hardware::audio::effect::getEffectTypeUuidVisualizer()) {
-        mConversion = std::make_unique<android::effect::AidlConversionVisualizer>(effect, sessionId,
-                                                                                  ioId, desc);
+        mConversion = std::make_unique<android::effect::AidlConversionVisualizer>(
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     } else {
         // For unknown UUID, use vendor extension implementation
         mConversion = std::make_unique<android::effect::AidlConversionVendorExtension>(
-                effect, sessionId, ioId, desc);
+                effect, sessionId, ioId, desc, mIsProxyEffect);
     }
     return OK;
 }
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAec.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAec.h
index 3ee419a..61dd36a 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAec.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAec.h
@@ -26,8 +26,9 @@
   public:
     AidlConversionAec(std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
                       int32_t sessionId, int32_t ioId,
-                      const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+                      const ::aidl::android::hardware::audio::effect::Descriptor& desc,
+                      bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionAec() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAgc1.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAgc1.h
index b0509fd..364b473 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAgc1.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAgc1.h
@@ -26,8 +26,9 @@
   public:
     AidlConversionAgc1(std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
                        int32_t sessionId, int32_t ioId,
-                       const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+                       const ::aidl::android::hardware::audio::effect::Descriptor& desc,
+                       bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionAgc1() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAgc2.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAgc2.h
index 8f7eac7..df9a9ec 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAgc2.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionAgc2.h
@@ -26,8 +26,9 @@
   public:
     AidlConversionAgc2(std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
                        int32_t sessionId, int32_t ioId,
-                       const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+                       const ::aidl::android::hardware::audio::effect::Descriptor& desc,
+                       bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionAgc2() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionBassBoost.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionBassBoost.h
index 9664aa1..424b837 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionBassBoost.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionBassBoost.h
@@ -27,8 +27,8 @@
     AidlConversionBassBoost(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionBassBoost() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionDownmix.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionDownmix.h
index 8b28ca3..f963f66 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionDownmix.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionDownmix.h
@@ -26,8 +26,9 @@
   public:
     AidlConversionDownmix(std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
                           int32_t sessionId, int32_t ioId,
-                          const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+                          const ::aidl::android::hardware::audio::effect::Descriptor& desc,
+                          bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionDownmix() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionDynamicsProcessing.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionDynamicsProcessing.h
index c5d5a54..62714c3 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionDynamicsProcessing.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionDynamicsProcessing.h
@@ -26,8 +26,9 @@
   public:
     AidlConversionDp(std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
                      int32_t sessionId, int32_t ioId,
-                     const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+                     const ::aidl::android::hardware::audio::effect::Descriptor& desc,
+                     bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionDp() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEnvReverb.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEnvReverb.h
index 8b92374..95042eb 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEnvReverb.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEnvReverb.h
@@ -27,8 +27,8 @@
     AidlConversionEnvReverb(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionEnvReverb() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEq.cpp b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEq.cpp
index 45b98a1..fc867c7 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEq.cpp
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEq.cpp
@@ -161,6 +161,9 @@
             return param.writeToValue(&bands);
         }
         case EQ_PARAM_LEVEL_RANGE: {
+            if (mDesc.capability.range.getTag() != Range::equalizer) {
+                return OK;
+            }
             const auto& ranges = mDesc.capability.range.get<Range::equalizer>();
             for (const auto& r : ranges) {
                 if (r.min.getTag() == Equalizer::bandLevels &&
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEq.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEq.h
index f94556c..53566e2 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEq.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionEq.h
@@ -25,9 +25,10 @@
 class AidlConversionEq : public EffectConversionHelperAidl {
   public:
     AidlConversionEq(std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
-                      int32_t sessionId, int32_t ioId,
-                      const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+                     int32_t sessionId, int32_t ioId,
+                     const ::aidl::android::hardware::audio::effect::Descriptor& desc,
+                     bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionEq() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionHapticGenerator.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionHapticGenerator.h
index 03114a5..9890bfb 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionHapticGenerator.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionHapticGenerator.h
@@ -27,8 +27,8 @@
     AidlConversionHapticGenerator(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionHapticGenerator() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionLoudnessEnhancer.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionLoudnessEnhancer.h
index c0402f9..2ce14a6 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionLoudnessEnhancer.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionLoudnessEnhancer.h
@@ -27,8 +27,8 @@
     AidlConversionLoudnessEnhancer(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionLoudnessEnhancer() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionNoiseSuppression.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionNoiseSuppression.h
index f51e13a..fac121d 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionNoiseSuppression.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionNoiseSuppression.h
@@ -27,8 +27,8 @@
     AidlConversionNoiseSuppression(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionNoiseSuppression() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionPresetReverb.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionPresetReverb.h
index 397d6e6..b975d72 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionPresetReverb.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionPresetReverb.h
@@ -27,8 +27,8 @@
     AidlConversionPresetReverb(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionPresetReverb() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionSpatializer.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionSpatializer.h
index c44567c..7c60b14 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionSpatializer.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionSpatializer.h
@@ -27,8 +27,8 @@
     AidlConversionSpatializer(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionSpatializer() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVendorExtension.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVendorExtension.h
index fd22e5c..16bfeba 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVendorExtension.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVendorExtension.h
@@ -27,8 +27,8 @@
     AidlConversionVendorExtension(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionVendorExtension() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVirtualizer.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVirtualizer.h
index 91c0fcd..359d884 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVirtualizer.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVirtualizer.h
@@ -27,8 +27,8 @@
     AidlConversionVirtualizer(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionVirtualizer() {}
 
   private:
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVisualizer.h b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVisualizer.h
index e380bc6..bc9320f 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVisualizer.h
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionVisualizer.h
@@ -27,8 +27,8 @@
     AidlConversionVisualizer(
             std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect> effect,
             int32_t sessionId, int32_t ioId,
-            const ::aidl::android::hardware::audio::effect::Descriptor& desc)
-        : EffectConversionHelperAidl(effect, sessionId, ioId, desc) {}
+            const ::aidl::android::hardware::audio::effect::Descriptor& desc, bool isProxyEffect)
+        : EffectConversionHelperAidl(effect, sessionId, ioId, desc, isProxyEffect) {}
     ~AidlConversionVisualizer() {}
 
   private:
diff --git a/media/libaudioprocessing/AudioMixerBase.cpp b/media/libaudioprocessing/AudioMixerBase.cpp
index f30eb54..3c34caa 100644
--- a/media/libaudioprocessing/AudioMixerBase.cpp
+++ b/media/libaudioprocessing/AudioMixerBase.cpp
@@ -453,9 +453,9 @@
                         &track->mVolume[param - VOLUME0],
                         &track->mPrevVolume[param - VOLUME0],
                         &track->mVolumeInc[param - VOLUME0])) {
-                    ALOGV("setParameter(%s, VOLUME%d: %04x)",
-                            target == VOLUME ? "VOLUME" : "RAMP_VOLUME", param - VOLUME0,
-                                    track->volume[param - VOLUME0]);
+                    ALOGV("setParameter(%s, VOLUME%d: %f)",
+                          target == VOLUME ? "VOLUME" : "RAMP_VOLUME", param - VOLUME0,
+                          track->mVolume[param - VOLUME0]);
                     invalidate();
                 }
             } else {
@@ -630,7 +630,7 @@
 
         if (t->volumeInc[0]|t->volumeInc[1]) {
             volumeRamp = true;
-        } else if (!t->doesResample() && t->volumeRL == 0) {
+        } else if (!t->doesResample() && t->isVolumeMuted()) {
             n |= NEEDS_MUTE;
         }
         t->needs = n;
@@ -730,7 +730,7 @@
 
         for (const int name : mEnabled) {
             const std::shared_ptr<TrackBase> &t = mTracks[name];
-            if (!t->doesResample() && t->volumeRL == 0) {
+            if (!t->doesResample() && t->isVolumeMuted()) {
                 t->needs |= NEEDS_MUTE;
                 t->hook = &TrackBase::track__nop;
             } else {
diff --git a/media/libaudioprocessing/include/media/AudioMixerBase.h b/media/libaudioprocessing/include/media/AudioMixerBase.h
index 3419816..0d82255 100644
--- a/media/libaudioprocessing/include/media/AudioMixerBase.h
+++ b/media/libaudioprocessing/include/media/AudioMixerBase.h
@@ -290,6 +290,16 @@
         audio_channel_mask_t mMixerChannelMask;
         uint32_t             mMixerChannelCount;
 
+        // consider volume muted only if all channel volume (floating point) is 0.f
+        inline bool isVolumeMuted() const {
+            for (const auto volume : mVolume) {
+                if (volume != 0) {
+                    return false;
+                }
+            }
+            return true;
+        }
+
       protected:
 
         // hooks
diff --git a/media/libeffects/lvm/wrapper/Aidl/BundleContext.cpp b/media/libeffects/lvm/wrapper/Aidl/BundleContext.cpp
index d026e2b..0db7a73 100644
--- a/media/libeffects/lvm/wrapper/Aidl/BundleContext.cpp
+++ b/media/libeffects/lvm/wrapper/Aidl/BundleContext.cpp
@@ -15,9 +15,11 @@
  */
 
 #include <cstddef>
+#include <cstdio>
 
 #define LOG_TAG "BundleContext"
 #include <android-base/logging.h>
+#include <audio_utils/power.h>
 #include <Utils.h>
 
 #include "BundleContext.h"
@@ -34,7 +36,7 @@
     std::lock_guard lg(mMutex);
     // init with pre-defined preset NORMAL
     for (std::size_t i = 0; i < lvm::MAX_NUM_BANDS; i++) {
-        mBandGaindB[i] = lvm::kSoftPresets[0 /* normal */][i];
+        mBandGainMdB[i] = lvm::kSoftPresets[0 /* normal */][i] * 100;
     }
 
     // allocate lvm instance
@@ -212,7 +214,7 @@
 
         if (eqEnabled) {
             for (int i = 0; i < lvm::MAX_NUM_BANDS; i++) {
-                float bandFactor = mBandGaindB[i] / 15.0;
+                float bandFactor = mBandGainMdB[i] / 1500.0;
                 float bandCoefficient = lvm::kBandEnergyCoefficient[i];
                 float bandEnergy = bandFactor * bandCoefficient * bandCoefficient;
                 if (bandEnergy > 0) energyContribution += bandEnergy;
@@ -221,8 +223,8 @@
             // cross EQ coefficients
             float bandFactorSum = 0;
             for (int i = 0; i < lvm::MAX_NUM_BANDS - 1; i++) {
-                float bandFactor1 = mBandGaindB[i] / 15.0;
-                float bandFactor2 = mBandGaindB[i + 1] / 15.0;
+                float bandFactor1 = mBandGainMdB[i] / 1500.0;
+                float bandFactor2 = mBandGainMdB[i + 1] / 1500.0;
 
                 if (bandFactor1 > 0 && bandFactor2 > 0) {
                     float crossEnergy =
@@ -244,7 +246,7 @@
 
             if (eqEnabled) {
                 for (int i = 0; i < lvm::MAX_NUM_BANDS; i++) {
-                    float bandFactor = mBandGaindB[i] / 15.0;
+                    float bandFactor = mBandGainMdB[i] / 1500.0;
                     float bandCrossCoefficient = lvm::kBassBoostEnergyCrossCoefficient[i];
                     float bandEnergy = boostFactor * bandFactor * bandCrossCoefficient;
                     if (bandEnergy > 0) energyBassBoost += bandEnergy;
@@ -397,15 +399,10 @@
     return db_fix;
 }
 
-// TODO: replace with more generic approach, like: audio_utils_power_from_amplitude
-int16_t BundleContext::VolToDb(uint32_t vol) const {
-    int16_t dB;
-
-    dB = LVC_ToDB_s32Tos16(vol << 7);
-    dB = (dB + 8) >> 4;
-    dB = (dB < -96) ? -96 : dB;
-
-    return dB;
+/* static */
+float BundleContext::VolToDb(float vol) {
+    float dB = audio_utils_power_from_amplitude(vol);
+    return std::max(dB, -96.f);
 }
 
 RetCode BundleContext::setVolumeStereo(const Parameter::VolumeStereo& volume) {
@@ -413,11 +410,12 @@
     LVM_ReturnStatus_en status = LVM_SUCCESS;
 
     // Convert volume to dB
-    int leftdB = VolToDb(volume.left);
-    int rightdB = VolToDb(volume.right);
-    int maxdB = std::max(leftdB, rightdB);
-    int pandB = rightdB - leftdB;
-    setVolumeLevel(maxdB * 100);
+    float leftdB = VolToDb(volume.left);
+    float rightdB = VolToDb(volume.right);
+
+    float maxdB = std::max(leftdB, rightdB);
+    float pandB = rightdB - leftdB;
+    setVolumeLevel(maxdB);
     LOG(DEBUG) << __func__ << " pandB: " << pandB << " maxdB " << maxdB;
 
     {
@@ -441,8 +439,8 @@
     std::vector<Equalizer::BandLevel> bandLevels;
     bandLevels.reserve(lvm::MAX_NUM_BANDS);
     for (std::size_t i = 0; i < lvm::MAX_NUM_BANDS; i++) {
-        bandLevels.emplace_back(
-                Equalizer::BandLevel{static_cast<int32_t>(i), lvm::kSoftPresets[presetIdx][i]});
+        bandLevels.emplace_back(Equalizer::BandLevel{static_cast<int32_t>(i),
+                                                     lvm::kSoftPresets[presetIdx][i] * 100});
     }
 
     RetCode ret = updateControlParameter(bandLevels);
@@ -472,7 +470,8 @@
     std::vector<Equalizer::BandLevel> bandLevels;
     bandLevels.reserve(lvm::MAX_NUM_BANDS);
     for (std::size_t i = 0; i < lvm::MAX_NUM_BANDS; i++) {
-        bandLevels.emplace_back(Equalizer::BandLevel{static_cast<int32_t>(i), mBandGaindB[i]});
+        bandLevels.emplace_back(
+                Equalizer::BandLevel{static_cast<int32_t>(i), mBandGainMdB[i]});
     }
     return bandLevels;
 }
@@ -506,7 +505,7 @@
     RETURN_VALUE_IF(!isBandLevelIndexInRange(bandLevels), RetCode::ERROR_ILLEGAL_PARAMETER,
                     "indexOutOfRange");
 
-    std::array<int, lvm::MAX_NUM_BANDS> tempLevel;
+    std::array<int, lvm::MAX_NUM_BANDS> tempLevel(mBandGainMdB);
     for (const auto& it : bandLevels) {
         tempLevel[it.index] = it.levelMb;
     }
@@ -520,14 +519,16 @@
         for (std::size_t i = 0; i < lvm::MAX_NUM_BANDS; i++) {
             params.pEQNB_BandDefinition[i].Frequency = lvm::kPresetsFrequencies[i];
             params.pEQNB_BandDefinition[i].QFactor = lvm::kPresetsQFactors[i];
-            params.pEQNB_BandDefinition[i].Gain = tempLevel[i];
+            params.pEQNB_BandDefinition[i].Gain =
+                    tempLevel[i] > 0 ? (tempLevel[i] + 50) / 100 : (tempLevel[i] - 50) / 100;
         }
 
         RETURN_VALUE_IF(LVM_SUCCESS != LVM_SetControlParameters(mInstance, &params),
                         RetCode::ERROR_EFFECT_LIB_ERROR, " setControlParamFailed");
     }
-    mBandGaindB = tempLevel;
-    LOG(INFO) << __func__ << " update bandGain to " << ::android::internal::ToString(mBandGaindB);
+    mBandGainMdB = tempLevel;
+    LOG(DEBUG) << __func__ << " update bandGain to " << ::android::internal::ToString(mBandGainMdB)
+               << "mdB";
 
     return RetCode::SUCCESS;
 }
@@ -551,18 +552,18 @@
     return limitLevel();
 }
 
-RetCode BundleContext::setVolumeLevel(int level) {
+RetCode BundleContext::setVolumeLevel(float level) {
     if (mMuteEnabled) {
-        mLevelSaved = level / 100;
+        mLevelSaved = level;
     } else {
-        mVolume = level / 100;
+        mVolume = level;
     }
     LOG(INFO) << __func__ << " success with level " << level;
     return limitLevel();
 }
 
-int BundleContext::getVolumeLevel() const {
-    return (mMuteEnabled ? mLevelSaved * 100 : mVolume * 100);
+float BundleContext::getVolumeLevel() const {
+    return (mMuteEnabled ? mLevelSaved : mVolume);
 }
 
 RetCode BundleContext::setVolumeMute(bool mute) {
diff --git a/media/libeffects/lvm/wrapper/Aidl/BundleContext.h b/media/libeffects/lvm/wrapper/Aidl/BundleContext.h
index 47d5e5a..62bb6e4 100644
--- a/media/libeffects/lvm/wrapper/Aidl/BundleContext.h
+++ b/media/libeffects/lvm/wrapper/Aidl/BundleContext.h
@@ -80,8 +80,8 @@
     RetCode setBassBoostStrength(int strength);
     int getBassBoostStrength() const { return mBassStrengthSaved; }
 
-    RetCode setVolumeLevel(int level);
-    int getVolumeLevel() const;
+    RetCode setVolumeLevel(float level);
+    float getVolumeLevel() const;
 
     RetCode setVolumeMute(bool mute);
     int getVolumeMute() const { return mMuteEnabled; }
@@ -135,20 +135,20 @@
     int mBassStrengthSaved = 0;
     // Equalizer
     int mCurPresetIdx = lvm::PRESET_CUSTOM; /* Current preset being used */
-    std::array<int, lvm::MAX_NUM_BANDS> mBandGaindB;
+    std::array<int, lvm::MAX_NUM_BANDS> mBandGainMdB; /* band gain in millibels */
     // Virtualizer
     int mVirtStrengthSaved = 0; /* Conversion between Get/Set */
     bool mVirtualizerTempDisabled = false;
     ::aidl::android::media::audio::common::AudioDeviceDescription mForceDevice;
     // Volume
-    int mLevelSaved = 0; /* for when mute is set, level must be saved */
-    int mVolume = 0;
+    float mLevelSaved = 0; /* for when mute is set, level must be saved */
+    float mVolume = 0;
     bool mMuteEnabled = false; /* Must store as mute = -96dB level */
 
     void initControlParameter(LVM_ControlParams_t& params) const;
     void initHeadroomParameter(LVM_HeadroomParams_t& params) const;
     RetCode limitLevel();
-    int16_t VolToDb(uint32_t vol) const;
+    static float VolToDb(float vol);
     LVM_INT16 LVC_ToDB_s32Tos16(LVM_INT32 Lin_fix) const;
     RetCode updateControlParameter(const std::vector<Equalizer::BandLevel>& bandLevels);
     bool isBandLevelIndexInRange(const std::vector<Equalizer::BandLevel>& bandLevels) const;
diff --git a/media/libeffects/lvm/wrapper/Aidl/BundleTypes.h b/media/libeffects/lvm/wrapper/Aidl/BundleTypes.h
index 3bc889c..143329d 100644
--- a/media/libeffects/lvm/wrapper/Aidl/BundleTypes.h
+++ b/media/libeffects/lvm/wrapper/Aidl/BundleTypes.h
@@ -73,9 +73,9 @@
         MAKE_RANGE(Equalizer, preset, 0, MAX_NUM_PRESETS - 1),
         MAKE_RANGE(Equalizer, bandLevels,
                    std::vector<Equalizer::BandLevel>{
-                           Equalizer::BandLevel({.index = 0, .levelMb = -15})},
+                           Equalizer::BandLevel({.index = 0, .levelMb = -1500})},
                    std::vector<Equalizer::BandLevel>{
-                           Equalizer::BandLevel({.index = MAX_NUM_BANDS - 1, .levelMb = 15})}),
+                           Equalizer::BandLevel({.index = MAX_NUM_BANDS - 1, .levelMb = 1500})}),
         /* capability definition */
         MAKE_RANGE(Equalizer, bandFrequencies, kEqBandFrequency, kEqBandFrequency),
         MAKE_RANGE(Equalizer, presets, kEqPresets, kEqPresets),
diff --git a/media/libeffects/lvm/wrapper/Aidl/EffectBundleAidl.cpp b/media/libeffects/lvm/wrapper/Aidl/EffectBundleAidl.cpp
index cd9fb60..eb7ab1a 100644
--- a/media/libeffects/lvm/wrapper/Aidl/EffectBundleAidl.cpp
+++ b/media/libeffects/lvm/wrapper/Aidl/EffectBundleAidl.cpp
@@ -355,7 +355,7 @@
     auto tag = id.get<Volume::Id::commonTag>();
     switch (tag) {
         case Volume::levelDb: {
-            volParam.set<Volume::levelDb>(mContext->getVolumeLevel());
+            volParam.set<Volume::levelDb>(static_cast<int>(mContext->getVolumeLevel()));
             break;
         }
         case Volume::mute: {
@@ -384,6 +384,7 @@
 
     if (id.getTag() == Virtualizer::Id::speakerAnglesPayload) {
         auto angles = mContext->getSpeakerAngles(id.get<Virtualizer::Id::speakerAnglesPayload>());
+        RETURN_IF(angles.size() == 0, EX_ILLEGAL_ARGUMENT, "getSpeakerAnglesFailed");
         Virtualizer param = Virtualizer::make<Virtualizer::speakerAngles>(angles);
         specific->set<Parameter::Specific::virtualizer>(param);
         return ndk::ScopedAStatus::ok();
diff --git a/services/audioflinger/afutils/Android.bp b/services/audioflinger/afutils/Android.bp
index 4309bf5..5eac519 100644
--- a/services/audioflinger/afutils/Android.bp
+++ b/services/audioflinger/afutils/Android.bp
@@ -7,11 +7,108 @@
     default_applicable_licenses: ["frameworks_av_services_audioflinger_license"],
 }
 
+audioflinger_utils_tidy_errors = [
+    // https://clang.llvm.org/extra/clang-tidy/checks/list.html
+    // For many categories, the checks are too many to specify individually.
+    // Feel free to disable as needed - as warnings are generally ignored,
+    // we treat warnings as errors.
+    "android-*",
+    "bugprone-*",
+    "cert-*",
+    "clang-analyzer-security*",
+    "google-*",
+    "misc-*",
+    //"modernize-*",  // explicitly list the modernize as they can be subjective.
+    "modernize-avoid-bind",
+    //"modernize-avoid-c-arrays", // std::array<> can be verbose
+    "modernize-concat-nested-namespaces",
+    //"modernize-deprecated-headers", // C headers still ok even if there is C++ equivalent.
+    "modernize-deprecated-ios-base-aliases",
+    "modernize-loop-convert",
+    "modernize-make-shared",
+    "modernize-make-unique",
+    // "modernize-pass-by-value",
+    "modernize-raw-string-literal",
+    "modernize-redundant-void-arg",
+    "modernize-replace-auto-ptr",
+    "modernize-replace-random-shuffle",
+    "modernize-return-braced-init-list",
+    "modernize-shrink-to-fit",
+    "modernize-unary-static-assert",
+    // "modernize-use-auto",  // found in MediaMetricsService.h, debatable - auto can obscure type
+    "modernize-use-bool-literals",
+    "modernize-use-default-member-init",
+    "modernize-use-emplace",
+    "modernize-use-equals-default",
+    "modernize-use-equals-delete",
+    // "modernize-use-nodiscard",
+    "modernize-use-noexcept",
+    "modernize-use-nullptr",
+    "modernize-use-override",
+    //"modernize-use-trailing-return-type", // not necessarily more readable
+    "modernize-use-transparent-functors",
+    "modernize-use-uncaught-exceptions",
+    "modernize-use-using",
+    "performance-*",
+
+    // Remove some pedantic stylistic requirements.
+    "-google-readability-casting", // C++ casts not always necessary and may be verbose
+    "-google-readability-todo",    // do not require TODO(info)
+
+    "-bugprone-unhandled-self-assignment",
+    "-bugprone-suspicious-string-compare",
+    "-cert-oop54-cpp", // found in TransactionLog.h
+    "-bugprone-narrowing-conversions", // b/182410845
+
+    // TODO(b/275642749) Reenable these warnings
+    "-misc-non-private-member-variables-in-classes",
+]
+
+// Eventually use common tidy defaults
+cc_defaults {
+    name: "audioflinger_utils_flags_defaults",
+    // https://clang.llvm.org/docs/UsersManual.html#command-line-options
+    // https://clang.llvm.org/docs/DiagnosticsReference.html
+    cflags: [
+        "-Wall",
+        "-Wdeprecated",
+        "-Werror",
+        "-Werror=implicit-fallthrough",
+        "-Werror=sometimes-uninitialized",
+        "-Werror=conditional-uninitialized",
+        "-Wextra",
+
+        // suppress some warning chatter.
+        "-Wno-deprecated-copy-with-dtor",
+        "-Wno-deprecated-copy-with-user-provided-dtor",
+
+        "-Wredundant-decls",
+        "-Wshadow",
+        "-Wstrict-aliasing",
+        "-fstrict-aliasing",
+        "-Wthread-safety",
+        //"-Wthread-safety-negative", // experimental - looks broken in R.
+        "-Wunreachable-code",
+        "-Wunreachable-code-break",
+        "-Wunreachable-code-return",
+        "-Wunused",
+        "-Wused-but-marked-unused",
+        "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
+    ],
+    // https://clang.llvm.org/extra/clang-tidy/
+    tidy: true,
+    tidy_checks: audioflinger_utils_tidy_errors,
+    tidy_checks_as_errors: audioflinger_utils_tidy_errors,
+    tidy_flags: [
+      "-format-style=file",
+    ],
+}
+
 cc_library {
     name: "libaudioflinger_utils",
 
     defaults: [
-        "audioflinger_flags_defaults",
+        "audioflinger_utils_flags_defaults",
     ],
 
     srcs: [
diff --git a/services/audioflinger/afutils/AudioWatchdog.cpp b/services/audioflinger/afutils/AudioWatchdog.cpp
index 877e776..48a07a5 100644
--- a/services/audioflinger/afutils/AudioWatchdog.cpp
+++ b/services/audioflinger/afutils/AudioWatchdog.cpp
@@ -38,12 +38,12 @@
             mUnderruns, mLogs, buf);
 }
 
-bool AudioWatchdog::threadLoop()
+bool AudioWatchdog::threadLoop() NO_THREAD_SAFETY_ANALYSIS // unique_lock
 {
     {
-        AutoMutex _l(mMyLock);
+        std::unique_lock _l(mLock);
         if (mPaused) {
-            mMyCond.wait(mMyLock);
+            mCond.wait(_l);
             // ignore previous timestamp after resume()
             mOldTsValid = false;
             // force an immediate log on first underrun after resume()
@@ -65,7 +65,7 @@
         return true;
     }
     time_t sec = newTs.tv_sec - mOldTs.tv_sec;
-    long nsec = newTs.tv_nsec - mOldTs.tv_nsec;
+    auto nsec = newTs.tv_nsec - mOldTs.tv_nsec;
     if (nsec < 0) {
         --sec;
         nsec += 1000000000;
@@ -81,7 +81,8 @@
         }
     }
     mLogTs.tv_sec += sec;
-    if ((mLogTs.tv_nsec += nsec) >= 1000000000) {
+    mLogTs.tv_nsec += nsec;
+    if (mLogTs.tv_nsec >= 1000000000) {
         mLogTs.tv_sec++;
         mLogTs.tv_nsec -= 1000000000;
     }
@@ -89,7 +90,7 @@
         mDump->mUnderruns = ++mUnderruns;
         if (mLogTs.tv_sec >= MIN_TIME_BETWEEN_LOGS_SEC) {
             mDump->mLogs = ++mLogs;
-            mDump->mMostRecent = time(NULL);
+            mDump->mMostRecent = time(nullptr /* tloc */);
             ALOGW("Insufficient CPU for load: expected=%.1f actual=%.1f ms; underruns=%u logs=%u",
                 mPeriodNs * 1e-6, cycleNs * 1e-6, mUnderruns, mLogs);
             mLogTs.tv_sec = 0;
@@ -99,7 +100,7 @@
     struct timespec req;
     req.tv_sec = 0;
     req.tv_nsec = mPeriodNs;
-    rc = nanosleep(&req, NULL);
+    rc = nanosleep(&req, nullptr /* remaining */);
     if (!((rc == 0) || (rc == -1 && errno == EINTR))) {
         pause();
         return false;
@@ -116,22 +117,23 @@
 
 void AudioWatchdog::pause()
 {
-    AutoMutex _l(mMyLock);
+    const std::lock_guard _l(mLock);
     mPaused = true;
 }
 
 void AudioWatchdog::resume()
 {
-    AutoMutex _l(mMyLock);
+    const std::lock_guard _l(mLock);
     if (mPaused) {
         mPaused = false;
-        mMyCond.signal();
+        mCond.notify_one();
     }
 }
 
 void AudioWatchdog::setDump(AudioWatchdogDump *dump)
 {
-    mDump = dump != NULL ? dump : &mDummyDump;
+    const std::lock_guard _l(mLock);
+    mDump = dump != nullptr ? dump : &mDummyDump;
 }
 
 }   // namespace android
diff --git a/services/audioflinger/afutils/AudioWatchdog.h b/services/audioflinger/afutils/AudioWatchdog.h
index 7b69fc6..1f5dad4 100644
--- a/services/audioflinger/afutils/AudioWatchdog.h
+++ b/services/audioflinger/afutils/AudioWatchdog.h
@@ -19,9 +19,9 @@
 //       as soon as possible when there appears to be a CPU shortage
 //   (b) monitor the other threads [not yet implemented]
 
-#ifndef AUDIO_WATCHDOG_H
-#define AUDIO_WATCHDOG_H
+#pragma once
 
+#include <mutex>
 #include <time.h>
 #include <utils/Thread.h>
 
@@ -30,59 +30,54 @@
 // Keeps a cache of AudioWatchdog statistics that can be logged by dumpsys.
 // The usual caveats about atomicity of information apply.
 struct AudioWatchdogDump {
-    AudioWatchdogDump() : mUnderruns(0), mLogs(0), mMostRecent(0) { }
-    /*virtual*/ ~AudioWatchdogDump() { }
-    uint32_t mUnderruns;    // total number of underruns
-    uint32_t mLogs;         // total number of log messages
-    time_t   mMostRecent;   // time of most recent log
+    uint32_t mUnderruns = 0;    // total number of underruns
+    uint32_t mLogs = 0;         // total number of log messages
+    time_t   mMostRecent = 0;   // time of most recent log
     void     dump(int fd);  // should only be called on a stable copy, not the original
 };
 
 class AudioWatchdog : public Thread {
 
 public:
-    explicit AudioWatchdog(unsigned periodMs = 50) : Thread(false /*canCallJava*/), mPaused(false),
-            mPeriodNs(periodMs * 1000000), mMaxCycleNs(mPeriodNs * 2),
-            // mOldTs
-            // mLogTs initialized below
-            mOldTsValid(false), mUnderruns(0), mLogs(0), mDump(&mDummyDump)
+    explicit AudioWatchdog(unsigned periodMs = 50) : Thread(false /*canCallJava*/),
+            mPeriodNs(periodMs * 1000000), mMaxCycleNs(mPeriodNs * 2)
         {
-#define MIN_TIME_BETWEEN_LOGS_SEC 60
             // force an immediate log on first underrun
             mLogTs.tv_sec = MIN_TIME_BETWEEN_LOGS_SEC;
             mLogTs.tv_nsec = 0;
         }
-    virtual         ~AudioWatchdog() { }
 
      // Do not call Thread::requestExitAndWait() without first calling requestExit().
     // Thread::requestExitAndWait() is not virtual, and the implementation doesn't do enough.
-    virtual void        requestExit();
+    void            requestExit() override;
 
     // FIXME merge API and implementation with AudioTrackThread
-    void            pause();        // suspend thread from execution at next loop boundary
-    void            resume();       // allow thread to execute, if not requested to exit
+    void            pause();   // suspend thread from execution at next loop boundary
+    void            resume();  // allow thread to execute, if not requested to exit
 
     // Where to store the dump, or NULL to not update
     void            setDump(AudioWatchdogDump* dump);
 
 private:
-    virtual bool    threadLoop();
+    bool            threadLoop() override;
 
-    Mutex           mMyLock;        // Thread::mLock is private
-    Condition       mMyCond;        // Thread::mThreadExitedCondition is private
-    bool            mPaused;        // whether thread is currently paused
+    static constexpr int32_t MIN_TIME_BETWEEN_LOGS_SEC = 60;
+    const uint32_t  mPeriodNs;       // nominal period
+    const uint32_t  mMaxCycleNs;     // maximum allowed time of one cycle before declaring underrun
 
-    uint32_t        mPeriodNs;      // nominal period
-    uint32_t        mMaxCycleNs;    // maximum allowed time of one cycle before declaring underrun
-    struct timespec mOldTs;         // monotonic time when threadLoop last ran
-    struct timespec mLogTs;         // time since last log
-    bool            mOldTsValid;    // whether mOldTs is valid
-    uint32_t        mUnderruns;     // total number of underruns
-    uint32_t        mLogs;          // total number of logs
-    AudioWatchdogDump*  mDump;      // where to store the dump, always non-NULL
+    mutable std::mutex mLock;      // Thread::mLock is private
+    std::condition_variable mCond; // Thread::mThreadExitedCondition is private
+    bool            mPaused GUARDED_BY(mLock) = false; // whether thread is currently paused
+    bool            mOldTsValid GUARDED_BY(mLock) = false;  // whether mOldTs is valid
+    struct timespec mOldTs GUARDED_BY(mLock);          // monotonic time when threadLoop last ran
+    struct timespec mLogTs GUARDED_BY(mLock);          // time since last log (ctor init).
+    uint32_t        mUnderruns GUARDED_BY(mLock) = 0;  // total number of underruns
+    uint32_t        mLogs GUARDED_BY(mLock) = 0;       // total number of logs
+
+    // where to store the dump, always non-NULL
+    AudioWatchdogDump*  mDump GUARDED_BY(mLock) = &mDummyDump;
     AudioWatchdogDump   mDummyDump; // default area for dump in case setDump() is not called
 };
 
 }   // namespace android
 
-#endif  // AUDIO_WATCHDOG_H
diff --git a/services/audioflinger/afutils/BufLog.cpp b/services/audioflinger/afutils/BufLog.cpp
index 5f6aca0..508022f 100644
--- a/services/audioflinger/afutils/BufLog.cpp
+++ b/services/audioflinger/afutils/BufLog.cpp
@@ -28,12 +28,14 @@
 
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
+namespace android {
+
 // ------------------------------
 // BufLogSingleton
 // ------------------------------
 pthread_once_t onceControl = PTHREAD_ONCE_INIT;
 
-BufLog *BufLogSingleton::mInstance = NULL;
+BufLog *BufLogSingleton::mInstance = nullptr;
 
 void BufLogSingleton::initOnce() {
     mInstance = new BufLog();
@@ -49,55 +51,39 @@
 }
 
 bool BufLogSingleton::instanceExists() {
-    return mInstance != NULL;
+    return mInstance != nullptr;
 }
 
 // ------------------------------
 // BufLog
 // ------------------------------
 
-BufLog::BufLog() {
-    memset(mStreams, 0, sizeof(mStreams));
-}
-
 BufLog::~BufLog() {
-    android::Mutex::Autolock autoLock(mLock);
-
-    for (unsigned int id = 0; id < BUFLOG_MAXSTREAMS; id++) {
-        BufLogStream *pBLStream = mStreams[id];
-        if (pBLStream != NULL) {
-            delete pBLStream ;
-            mStreams[id] = NULL;
-        }
-    }
+    reset();
 }
 
 size_t BufLog::write(int streamid, const char *tag, int format, int channels,
         int samplingRate, size_t maxBytes, const void *buf, size_t size) {
-    unsigned int id = streamid % BUFLOG_MAXSTREAMS;
-    android::Mutex::Autolock autoLock(mLock);
+    const unsigned int id = streamid % BUFLOG_MAXSTREAMS;
+    const std::lock_guard autoLock(mLock);
 
     BufLogStream *pBLStream = mStreams[id];
 
-    if (pBLStream == NULL) {
+    if (pBLStream == nullptr) {
         pBLStream = mStreams[id] = new BufLogStream(id, tag, format, channels,
                 samplingRate, maxBytes);
-        ALOG_ASSERT(pBLStream != NULL, "BufLogStream Failed to be created");
     }
 
     return pBLStream->write(buf, size);
 }
 
 void BufLog::reset() {
-    android::Mutex::Autolock autoLock(mLock);
-    ALOGV("Resetting all BufLogs");
+    const std::lock_guard autoLock(mLock);
     int count = 0;
-
-    for (unsigned int id = 0; id < BUFLOG_MAXSTREAMS; id++) {
-        BufLogStream *pBLStream = mStreams[id];
-        if (pBLStream != NULL) {
+    for (auto &pBLStream : mStreams) {
+        if (pBLStream != nullptr) {
             delete pBLStream;
-            mStreams[id] = NULL;
+            pBLStream = nullptr;
             count++;
         }
     }
@@ -115,9 +101,7 @@
         unsigned int samplingRate,
         size_t maxBytes = 0) : mId(id), mFormat(format), mChannels(channels),
                 mSamplingRate(samplingRate), mMaxBytes(maxBytes) {
-    mByteCount = 0;
-    mPaused = false;
-    if (tag != NULL) {
+    if (tag != nullptr) {
         (void)audio_utils_strlcpy(mTag, tag);
     } else {
         mTag[0] = 0;
@@ -129,7 +113,7 @@
     //timestamp
     char timeStr[16];   //size 16: format %Y%m%d%H%M%S 14 chars + string null terminator
     struct timeval tv;
-    gettimeofday(&tv, NULL);
+    gettimeofday(&tv, nullptr);
     struct tm tm;
     localtime_r(&tv.tv_sec, &tm);
     strftime(timeStr, sizeof(timeStr), "%Y%m%d%H%M%S", &tm);
@@ -139,7 +123,7 @@
     ALOGV("data output: %s", logPath);
 
     mFile = fopen(logPath, "wb");
-    if (mFile != NULL) {
+    if (mFile != nullptr) {
         ALOGV("Success creating file at: %p", mFile);
     } else {
         ALOGE("Error: could not create file BufLogStream %s", strerror(errno));
@@ -148,24 +132,24 @@
 
 void BufLogStream::closeStream_l() {
     ALOGV("Closing BufLogStream id:%d tag:%s", mId, mTag);
-    if (mFile != NULL) {
+    if (mFile != nullptr) {
         fclose(mFile);
-        mFile = NULL;
+        mFile = nullptr;
     }
 }
 
 BufLogStream::~BufLogStream() {
     ALOGV("Destroying BufLogStream id:%d tag:%s", mId, mTag);
-    android::Mutex::Autolock autoLock(mLock);
+    const std::lock_guard autoLock(mLock);
     closeStream_l();
 }
 
 size_t BufLogStream::write(const void *buf, size_t size) {
 
     size_t bytes = 0;
-    if (!mPaused && mFile != NULL) {
-        if (size > 0 && buf != NULL) {
-            android::Mutex::Autolock autoLock(mLock);
+    if (!mPaused && mFile != nullptr) {
+        if (size > 0 && buf != nullptr) {
+            const std::lock_guard autoLock(mLock);
             if (mMaxBytes > 0) {
                 size = MIN(size, mMaxBytes - mByteCount);
             }
@@ -185,12 +169,14 @@
 }
 
 bool BufLogStream::setPause(bool pause) {
-    bool old = mPaused;
+    const bool old = mPaused;
     mPaused = pause;
     return old;
 }
 
 void BufLogStream::finalize() {
-    android::Mutex::Autolock autoLock(mLock);
+    const std::lock_guard autoLock(mLock);
     closeStream_l();
 }
+
+} // namespace android
diff --git a/services/audioflinger/afutils/BufLog.h b/services/audioflinger/afutils/BufLog.h
index 1b402f4..a58d073 100644
--- a/services/audioflinger/afutils/BufLog.h
+++ b/services/audioflinger/afutils/BufLog.h
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_AUDIO_BUFLOG_H
-#define ANDROID_AUDIO_BUFLOG_H
+#pragma once
 
 /*
  * BUFLOG creates up to BUFLOG_MAXSTREAMS simultaneous streams [0:15] of audio buffer data
@@ -99,17 +98,18 @@
     BufLogSingleton::instance()->reset(); } } while (0)
 #endif
 
-
+#include <mutex>
 #include <stdint.h>
 #include <stdio.h>
 #include <sys/types.h>
-#include <utils/Mutex.h>
 
 //BufLog configuration
 #define BUFLOGSTREAM_MAX_TAGSIZE    32
 #define BUFLOG_BASE_PATH            "/data/misc/audioserver"
 #define BUFLOG_MAX_PATH_SIZE        300
 
+namespace android {
+
 class BufLogStream {
 public:
     BufLogStream(unsigned int id,
@@ -135,26 +135,24 @@
     void            finalize();
 
 private:
-    bool                mPaused;
     const unsigned int  mId;
-    char                mTag[BUFLOGSTREAM_MAX_TAGSIZE + 1];
     const unsigned int  mFormat;
     const unsigned int  mChannels;
     const unsigned int  mSamplingRate;
     const size_t        mMaxBytes;
-    size_t              mByteCount;
-    FILE                *mFile;
-    mutable android::Mutex mLock;
+    char                mTag[BUFLOGSTREAM_MAX_TAGSIZE + 1]; // const, set in ctor.
+
+    mutable std::mutex  mLock;
+    bool                mPaused = false;
+    size_t              mByteCount = 0;
+    FILE                *mFile; // set in ctor
 
     void            closeStream_l();
 };
 
-
 class BufLog {
 public:
-    BufLog();
     ~BufLog();
-    BufLog(BufLog const&) {};
 
     //  streamid:      int [0:BUFLOG_MAXSTREAMS-1]   buffer id.
     //                  If a buffer doesn't exist, it is created the first time is referenced
@@ -181,9 +179,9 @@
     void            reset();
 
 protected:
-    static const unsigned int BUFLOG_MAXSTREAMS = 16;
-    BufLogStream    *mStreams[BUFLOG_MAXSTREAMS];
-    mutable android::Mutex mLock;
+    static constexpr size_t BUFLOG_MAXSTREAMS = 16;
+    mutable std::mutex mLock;
+    BufLogStream *mStreams[BUFLOG_MAXSTREAMS]{};
 };
 
 class BufLogSingleton {
@@ -196,4 +194,4 @@
     static BufLog   *mInstance;
 };
 
-#endif //ANDROID_AUDIO_BUFLOG_H
+} // namespace android
diff --git a/services/audioflinger/afutils/NBAIO_Tee.cpp b/services/audioflinger/afutils/NBAIO_Tee.cpp
index 53083d5..49057ce 100644
--- a/services/audioflinger/afutils/NBAIO_Tee.cpp
+++ b/services/audioflinger/afutils/NBAIO_Tee.cpp
@@ -91,8 +91,8 @@
 
     /** returns filename of created audio file, else empty string on failure. */
     std::string create(
-            std::function<ssize_t /* frames_read */
-                        (void * /* buffer */, size_t /* size_in_frames */)> reader,
+            const std::function<ssize_t /* frames_read */
+                        (void * /* buffer */, size_t /* size_in_frames */)>& reader,
             uint32_t sampleRate,
             uint32_t channelCount,
             audio_format_t format,
@@ -109,8 +109,8 @@
 
     /** creates an audio file from a reader functor passed in. */
     status_t createInternal(
-            std::function<ssize_t /* frames_read */
-                        (void * /* buffer */, size_t /* size_in_frames */)> reader,
+            const std::function<ssize_t /* frames_read */
+                        (void * /* buffer */, size_t /* size_in_frames */)>& reader,
             uint32_t sampleRate,
             uint32_t channelCount,
             audio_format_t format,
@@ -123,7 +123,7 @@
     std::string generateFilename(const std::string &suffix) const {
         char fileTime[sizeof("YYYYmmdd_HHMMSS_\0")];
         struct timeval tv;
-        gettimeofday(&tv, NULL);
+        gettimeofday(&tv, nullptr /* struct timezone */);
         struct tm tm;
         localtime_r(&tv.tv_sec, &tm);
         LOG_ALWAYS_FATAL_IF(strftime(fileTime, sizeof(fileTime), "%Y%m%d_%H%M%S_", &tm) == 0,
@@ -159,30 +159,29 @@
     // yet another ThreadPool implementation.
     class ThreadPool {
     public:
-        ThreadPool(size_t size)
+        explicit ThreadPool(size_t size)
             : mThreadPoolSize(size)
         { }
 
         /** launches task "name" with associated function "func".
             if the threadpool is exhausted, it will launch on calling function */
-        status_t launch(const std::string &name, std::function<status_t()> func);
+        status_t launch(const std::string &name, const std::function<status_t()>& func);
 
     private:
+        const size_t mThreadPoolSize;
         std::mutex mLock;
         std::list<std::pair<
-                std::string, std::future<status_t>>> mFutures; // GUARDED_BY(mLock)
-
-        const size_t mThreadPoolSize;
+                std::string, std::future<status_t>>> mFutures; // GUARDED_BY(mLock);
     } mThreadPool;
 
-    const std::string mPrefix;
-    std::mutex mLock;
-    std::string mDirectory;         // GUARDED_BY(mLock)
-    std::deque<std::string> mFiles; // GUARDED_BY(mLock)  sorted list of files by creation time
-
     static constexpr size_t FRAMES_PER_READ = 1024;
     static constexpr size_t MAX_FILES_READ = 1024;
     static constexpr size_t MAX_FILES_KEEP = 32;
+
+    const std::string mPrefix;
+    std::mutex mLock;
+    std::string mDirectory;         // GUARDED_BY(mLock);
+    std::deque<std::string> mFiles; // GUARDED_BY(mLock); // sorted list of files by creation time
 };
 
 /* static */
@@ -200,7 +199,7 @@
 
     const NBAIO_Format format = source->format();
     bool firstRead = true;
-    std::string filename = audioFileHandler.create(
+    const std::string filename = audioFileHandler.create(
             // this functor must not hold references to stack
             [firstRead, sinkSource] (void *buffer, size_t frames) mutable {
                     auto &source = sinkSource.second;
@@ -230,14 +229,16 @@
         Pipe *pipe = new Pipe(frames, format);
         size_t numCounterOffers = 0;
         const NBAIO_Format offers[1] = {format};
-        ssize_t index = pipe->negotiate(offers, 1, NULL, numCounterOffers);
+        ssize_t index = pipe->negotiate(
+                offers, 1 /* numOffers */, nullptr /* counterOffers */, numCounterOffers);
         if (index != 0) {
             ALOGW("pipe failure to negotiate: %zd", index);
             goto exit;
         }
         PipeReader *pipeReader = new PipeReader(*pipe);
         numCounterOffers = 0;
-        index = pipeReader->negotiate(offers, 1, NULL, numCounterOffers);
+        index = pipeReader->negotiate(
+                offers, 1 /* numOffers */, nullptr /* counterOffers */, numCounterOffers);
         if (index != 0) {
             ALOGW("pipeReader failure to negotiate: %zd", index);
             goto exit;
@@ -251,14 +252,14 @@
 }
 
 std::string AudioFileHandler::create(
-        std::function<ssize_t /* frames_read */
-                    (void * /* buffer */, size_t /* size_in_frames */)> reader,
+        const std::function<ssize_t /* frames_read */
+                    (void * /* buffer */, size_t /* size_in_frames */)>& reader,
         uint32_t sampleRate,
         uint32_t channelCount,
         audio_format_t format,
         const std::string &suffix)
 {
-    const std::string filename = generateFilename(suffix);
+    std::string filename = generateFilename(suffix);
 
     if (mThreadPool.launch(std::string("create ") + filename,
             [=]() { return createInternal(reader, sampleRate, channelCount, format, filename); })
@@ -312,7 +313,7 @@
     std::sort(files.begin() + toRemove, files.end());
 
     {
-        std::lock_guard<std::mutex> _l(mLock);
+        const std::lock_guard<std::mutex> _l(mLock);
 
         mDirectory = directory;
         mFiles = std::move(files);
@@ -330,13 +331,13 @@
     std::vector<std::string> filesToRemove;
     std::string dir;
     {
-        std::lock_guard<std::mutex> _l(mLock);
+        const std::lock_guard<std::mutex> _l(mLock);
 
         if (!isDirectoryValid(mDirectory)) return NO_INIT;
 
         dir = mDirectory;
         if (mFiles.size() > MAX_FILES_KEEP) {
-            size_t toRemove = mFiles.size() - MAX_FILES_KEEP;
+            const size_t toRemove = mFiles.size() - MAX_FILES_KEEP;
 
             // use move and erase to efficiently transfer std::string
             std::move(mFiles.begin(),
@@ -346,7 +347,7 @@
         }
     }
 
-    std::string dirp = dir + "/";
+    const std::string dirp = dir + "/";
     // remove files outside of lock for better concurrency.
     for (const auto &file : filesToRemove) {
         (void)unlink((dirp + file).c_str());
@@ -360,14 +361,14 @@
 }
 
 status_t AudioFileHandler::ThreadPool::launch(
-        const std::string &name, std::function<status_t()> func)
+        const std::string &name, const std::function<status_t()>& func)
 {
     if (mThreadPoolSize > 1) {
-        std::lock_guard<std::mutex> _l(mLock);
+        const std::lock_guard<std::mutex> _l(mLock);
         if (mFutures.size() >= mThreadPoolSize) {
             for (auto it = mFutures.begin(); it != mFutures.end();) {
                 const std::string &filename = it->first;
-                std::future<status_t> &future = it->second;
+                const std::future<status_t> &future = it->second;
                 if (!future.valid() ||
                         future.wait_for(std::chrono::seconds(0)) == std::future_status::ready) {
                     ALOGV("%s: future %s ready", __func__, filename.c_str());
@@ -389,8 +390,8 @@
 }
 
 status_t AudioFileHandler::createInternal(
-        std::function<ssize_t /* frames_read */
-                    (void * /* buffer */, size_t /* size_in_frames */)> reader,
+        const std::function<ssize_t /* frames_read */
+                    (void * /* buffer */, size_t /* size_in_frames */)>& reader,
         uint32_t sampleRate,
         uint32_t channelCount,
         audio_format_t format,
@@ -429,9 +430,9 @@
     }
 
     std::string directory;
-    status_t status = clean(&directory);
+    const status_t status = clean(&directory);
     if (status != NO_ERROR) return status;
-    std::string dirPrefix = directory + "/";
+    const std::string dirPrefix = directory + "/";
 
     const std::string path = dirPrefix + filename;
 
@@ -503,7 +504,7 @@
 
     // Success: add our name to managed files.
     {
-        std::lock_guard<std::mutex> _l(mLock);
+        const std::lock_guard<std::mutex> _l(mLock);
         // weak synchronization - only update mFiles if the directory hasn't changed.
         if (mDirectory == directory) {
             mFiles.emplace_back(filename);  // add to the end to preserve sort.
diff --git a/services/audioflinger/afutils/NBAIO_Tee.h b/services/audioflinger/afutils/NBAIO_Tee.h
index fed8cc8..17b6175 100644
--- a/services/audioflinger/afutils/NBAIO_Tee.h
+++ b/services/audioflinger/afutils/NBAIO_Tee.h
@@ -15,8 +15,8 @@
  */
 
 // Enabled with TEE_SINK in Configuration.h
-#ifndef ANDROID_NBAIO_TEE_H
-#define ANDROID_NBAIO_TEE_H
+
+#pragma once
 
 #ifdef TEE_SINK
 
@@ -216,7 +216,7 @@
             // Note: as mentioned in NBAIO_Tee::set(), don't call set() while write() is
             // ongoing.
             if (enabled) {
-                std::lock_guard<std::mutex> _l(mLock);
+                const std::lock_guard<std::mutex> _l(mLock);
                 mFlags = flags;
                 mFormat = format; // could get this from the Sink.
                 mFrames = frames;
@@ -228,7 +228,7 @@
         }
 
         void setId(const std::string &id) {
-            std::lock_guard<std::mutex> _l(mLock);
+            const std::lock_guard<std::mutex> _l(mLock);
             mId = id;
         }
 
@@ -237,7 +237,7 @@
             std::string suffix;
             NBAIO_SinkSource sinkSource;
             {
-                std::lock_guard<std::mutex> _l(mLock);
+                const std::lock_guard<std::mutex> _l(mLock);
                 suffix = mId + reason;
                 sinkSource = mSinkSource;
             }
@@ -281,13 +281,13 @@
     class RunningTees {
     public:
         void add(const std::shared_ptr<NBAIO_TeeImpl> &tee) {
-            std::lock_guard<std::mutex> _l(mLock);
+            const std::lock_guard<std::mutex> _l(mLock);
             ALOGW_IF(!mTees.emplace(tee).second,
                     "%s: %p already exists in mTees", __func__, tee.get());
         }
 
         void remove(const std::shared_ptr<NBAIO_TeeImpl> &tee) {
-            std::lock_guard<std::mutex> _l(mLock);
+            const std::lock_guard<std::mutex> _l(mLock);
             ALOGW_IF(mTees.erase(tee) != 1,
                     "%s: %p doesn't exist in mTees", __func__, tee.get());
         }
@@ -295,7 +295,7 @@
         void dump(int fd, const std::string &reason) {
             std::vector<std::shared_ptr<NBAIO_TeeImpl>> tees; // safe snapshot of tees
             {
-                std::lock_guard<std::mutex> _l(mLock);
+                const std::lock_guard<std::mutex> _l(mLock);
                 tees.insert(tees.end(), mTees.begin(), mTees.end());
             }
             for (const auto &tee : tees) {
@@ -323,4 +323,3 @@
 } // namespace android
 
 #endif // TEE_SINK
-#endif // !ANDROID_NBAIO_TEE_H
diff --git a/services/audioflinger/afutils/TypedLogger.h b/services/audioflinger/afutils/TypedLogger.h
index f34a50c..8c2d239 100644
--- a/services/audioflinger/afutils/TypedLogger.h
+++ b/services/audioflinger/afutils/TypedLogger.h
@@ -15,8 +15,7 @@
  * limitations under the License.
  */
 
-#ifndef ANDROID_TYPED_LOGGER_H
-#define ANDROID_TYPED_LOGGER_H
+#pragma once
 
 // This is the client API for the typed logger.
 
@@ -136,6 +135,5 @@
 
 NBLog::Writer *getThreadWriter();
 void setThreadWriter(NBLog::Writer *writer);
-} // namespace android::aflog
 
-#endif // ANDROID_TYPED_LOGGER_H
+} // namespace android::aflog
diff --git a/services/audioflinger/fastpath/Android.bp b/services/audioflinger/fastpath/Android.bp
index 10f1af9..6c024e7 100644
--- a/services/audioflinger/fastpath/Android.bp
+++ b/services/audioflinger/fastpath/Android.bp
@@ -61,16 +61,7 @@
     "-bugprone-narrowing-conversions", // b/182410845
 
     // TODO(b/275642749) Reenable these warnings
-    "-bugprone-assignment-in-if-condition",
-    "-bugprone-forward-declaration-namespace",
-    "-bugprone-parent-virtual-call",
-    "-cert-dcl59-cpp",
-    "-cert-err34-c",
-    "-google-runtime-int",
     "-misc-non-private-member-variables-in-classes",
-    "-modernize-concat-nested-namespaces",
-    "-modernize-loop-convert",
-    "-modernize-use-default-member-init",
     "-performance-no-int-to-ptr",
 ]
 
diff --git a/services/audioflinger/fastpath/FastCapture.cpp b/services/audioflinger/fastpath/FastCapture.cpp
index 5c76649..288036d 100644
--- a/services/audioflinger/fastpath/FastCapture.cpp
+++ b/services/audioflinger/fastpath/FastCapture.cpp
@@ -30,17 +30,13 @@
 
 namespace android {
 
-/*static*/ const FastCaptureState FastCapture::sInitial;
+/*static*/ const FastCaptureState FastCapture::sInitial{};
 
-FastCapture::FastCapture() : FastThread("cycleC_ms", "loadC_us"),
-    mInputSource(nullptr), mInputSourceGen(0), mPipeSink(nullptr), mPipeSinkGen(0),
-    mReadBuffer(nullptr), mReadBufferState(-1), mFormat(Format_Invalid), mSampleRate(0),
-    // mDummyDumpState
-    mTotalNativeFramesRead(0)
+FastCapture::FastCapture() : FastThread("cycleC_ms", "loadC_us")
 {
+    // base class initialization
     mPrevious = &sInitial;
     mCurrent = &sInitial;
-
     mDummyDumpState = &mDummyFastCaptureDumpState;
 }
 
diff --git a/services/audioflinger/fastpath/FastCapture.h b/services/audioflinger/fastpath/FastCapture.h
index 657a324..b565216 100644
--- a/services/audioflinger/fastpath/FastCapture.h
+++ b/services/audioflinger/fastpath/FastCapture.h
@@ -48,17 +48,17 @@
 
     FastCaptureState    mPreIdle;   // copy of state before we went into idle
     // FIXME by renaming, could pull up many of these to FastThread
-    NBAIO_Source*       mInputSource;
-    int                 mInputSourceGen;
-    NBAIO_Sink*         mPipeSink;
-    int                 mPipeSinkGen;
-    void*               mReadBuffer;
-    ssize_t             mReadBufferState;   // number of initialized frames in readBuffer,
-                                            // or -1 to clear
-    NBAIO_Format        mFormat;
-    unsigned            mSampleRate;
+    NBAIO_Source*       mInputSource = nullptr;
+    int                 mInputSourceGen = 0;
+    NBAIO_Sink*         mPipeSink = nullptr;
+    int                 mPipeSinkGen = 0;
+    void*               mReadBuffer = nullptr;
+    ssize_t             mReadBufferState = -1;  // number of initialized frames in readBuffer,
+                                                // or -1 to clear
+    NBAIO_Format        mFormat = Format_Invalid;
+    unsigned            mSampleRate = 0;
     FastCaptureDumpState mDummyFastCaptureDumpState;
-    uint32_t            mTotalNativeFramesRead; // copied to dumpState->mFramesRead
+    uint32_t            mTotalNativeFramesRead = 0; // copied to dumpState->mFramesRead
 
 };  // class FastCapture
 
diff --git a/services/audioflinger/fastpath/FastCaptureDumpState.cpp b/services/audioflinger/fastpath/FastCaptureDumpState.cpp
index e0ac9cc..fe7ea16 100644
--- a/services/audioflinger/fastpath/FastCaptureDumpState.cpp
+++ b/services/audioflinger/fastpath/FastCaptureDumpState.cpp
@@ -24,11 +24,6 @@
 
 namespace android {
 
-FastCaptureDumpState::FastCaptureDumpState() : FastThreadDumpState(),
-    mReadSequence(0), mFramesRead(0), mReadErrors(0), mSampleRate(0), mFrameCount(0)
-{
-}
-
 void FastCaptureDumpState::dump(int fd) const
 {
     if (mCommand == FastCaptureState::INITIAL) {
diff --git a/services/audioflinger/fastpath/FastCaptureDumpState.h b/services/audioflinger/fastpath/FastCaptureDumpState.h
index e205518..3dc8a9b 100644
--- a/services/audioflinger/fastpath/FastCaptureDumpState.h
+++ b/services/audioflinger/fastpath/FastCaptureDumpState.h
@@ -24,16 +24,14 @@
 namespace android {
 
 struct FastCaptureDumpState : FastThreadDumpState {
-    FastCaptureDumpState();
-
     void dump(int fd) const;    // should only be called on a stable copy, not the original
 
     // FIXME by renaming, could pull up many of these to FastThreadDumpState
-    uint32_t mReadSequence;     // incremented before and after each read()
-    uint32_t mFramesRead;       // total number of frames read successfully
-    uint32_t mReadErrors;       // total number of read() errors
-    uint32_t mSampleRate;
-    size_t   mFrameCount;
+    uint32_t mReadSequence = 0;  // incremented before and after each read()
+    uint32_t mFramesRead = 0;    // total number of frames read successfully
+    uint32_t mReadErrors = 0;    // total number of read() errors
+    uint32_t mSampleRate = 0;
+    size_t   mFrameCount = 0;
     bool     mSilenced = false; // capture is silenced
 };
 
diff --git a/services/audioflinger/fastpath/FastCaptureState.cpp b/services/audioflinger/fastpath/FastCaptureState.cpp
index d2df62a..77c0c4c 100644
--- a/services/audioflinger/fastpath/FastCaptureState.cpp
+++ b/services/audioflinger/fastpath/FastCaptureState.cpp
@@ -18,11 +18,6 @@
 
 namespace android {
 
-FastCaptureState::FastCaptureState() : FastThreadState(),
-    mInputSource(nullptr), mInputSourceGen(0), mPipeSink(nullptr), mPipeSinkGen(0), mFrameCount(0)
-{
-}
-
 // static
 const char *FastCaptureState::commandToString(Command command)
 {
@@ -35,7 +30,7 @@
     case FastCaptureState::WRITE:       return "WRITE";
     case FastCaptureState::READ_WRITE:  return "READ_WRITE";
     }
-    LOG_ALWAYS_FATAL("%s", __func__);
+    LOG_ALWAYS_FATAL("%s: command %d invalid", __func__, (int) command);
 }
 
 }  // namespace android
diff --git a/services/audioflinger/fastpath/FastCaptureState.h b/services/audioflinger/fastpath/FastCaptureState.h
index 82ea0ed..0f4126e 100644
--- a/services/audioflinger/fastpath/FastCaptureState.h
+++ b/services/audioflinger/fastpath/FastCaptureState.h
@@ -26,15 +26,14 @@
 
 // Represent a single state of the fast capture
 struct FastCaptureState : FastThreadState {
-                FastCaptureState();
-
     // all pointer fields use raw pointers; objects are owned and ref-counted by RecordThread
-    NBAIO_Source*   mInputSource;       // HAL input device, must already be negotiated
+    NBAIO_Source*   mInputSource = nullptr; // HAL input device, must already be negotiated
     // FIXME by renaming, could pull up these fields to FastThreadState
-    int             mInputSourceGen;    // increment when mInputSource is assigned
-    NBAIO_Sink*     mPipeSink;          // after reading from input source, write to this pipe sink
-    int             mPipeSinkGen;       // increment when mPipeSink is assigned
-    size_t          mFrameCount;        // number of frames per fast capture buffer
+    int             mInputSourceGen = 0;    // increment when mInputSource is assigned
+    NBAIO_Sink*     mPipeSink = nullptr;    // after reading from input source,
+                                            // write to this pipe sink
+    int             mPipeSinkGen = 0;       // increment when mPipeSink is assigned
+    size_t          mFrameCount = 0;        // number of frames per fast capture buffer
     audio_track_cblk_t* mCblk;          // control block for the single fast client, or NULL
 
     audio_format_t  mFastPatchRecordFormat = AUDIO_FORMAT_INVALID;
diff --git a/services/audioflinger/fastpath/FastMixer.cpp b/services/audioflinger/fastpath/FastMixer.cpp
index e13adab..e0a15c1 100644
--- a/services/audioflinger/fastpath/FastMixer.cpp
+++ b/services/audioflinger/fastpath/FastMixer.cpp
@@ -61,38 +61,19 @@
     : FastThread("cycle_ms", "load_us"),
     // mFastTrackNames
     // mGenerations
-    mOutputSink(nullptr),
-    mOutputSinkGen(0),
-    mMixer(nullptr),
-    mSinkBuffer(nullptr),
-    mSinkBufferSize(0),
-    mSinkChannelCount(FCC_2),
-    mMixerBuffer(nullptr),
-    mMixerBufferSize(0),
-    mMixerBufferState(UNDEFINED),
-    mFormat(Format_Invalid),
-    mSampleRate(0),
-    mFastTracksGen(0),
-    mTotalNativeFramesWritten(0),
     // timestamp
-    mNativeFramesWrittenButNotPresented(0),   // the = 0 is to silence the compiler
-    mMasterMono(false),
     mThreadIoHandle(parentIoHandle)
 {
     // FIXME pass sInitial as parameter to base class constructor, and make it static local
     mPrevious = &sInitial;
     mCurrent = &sInitial;
-
     mDummyDumpState = &mDummyFastMixerDumpState;
+
     // TODO: Add channel mask to NBAIO_Format.
     // We assume that the channel mask must be a valid positional channel mask.
     mSinkChannelMask = getChannelMaskFromCount(mSinkChannelCount);
     mBalance.setChannelMask(mSinkChannelMask);
 
-    unsigned i;
-    for (i = 0; i < FastMixerState::sMaxFastTracks; ++i) {
-        mGenerations[i] = 0;
-    }
 #ifdef FAST_THREAD_STATISTICS
     mOldLoad.tv_sec = 0;
     mOldLoad.tv_nsec = 0;
diff --git a/services/audioflinger/fastpath/FastMixer.h b/services/audioflinger/fastpath/FastMixer.h
index ab7bfe1..48b94a3 100644
--- a/services/audioflinger/fastpath/FastMixer.h
+++ b/services/audioflinger/fastpath/FastMixer.h
@@ -69,39 +69,39 @@
     static const FastMixerState sInitial;
 
     FastMixerState  mPreIdle;   // copy of state before we went into idle
-    int             mGenerations[FastMixerState::kMaxFastTracks];
+    int             mGenerations[FastMixerState::kMaxFastTracks]{};
                                 // last observed mFastTracks[i].mGeneration
-    NBAIO_Sink*     mOutputSink;
-    int             mOutputSinkGen;
-    AudioMixer*     mMixer;
+    NBAIO_Sink*     mOutputSink = nullptr;
+    int             mOutputSinkGen = 0;
+    AudioMixer*     mMixer = nullptr;
 
     // mSinkBuffer audio format is stored in format.mFormat.
-    void*           mSinkBuffer;        // used for mixer output format translation
+    void*           mSinkBuffer = nullptr; // used for mixer output format translation
                                         // if sink format is different than mixer output.
-    size_t          mSinkBufferSize;
-    uint32_t        mSinkChannelCount;
+    size_t          mSinkBufferSize = 0;
+    uint32_t        mSinkChannelCount = FCC_2;
     audio_channel_mask_t mSinkChannelMask;
-    void*           mMixerBuffer;       // mixer output buffer.
-    size_t          mMixerBufferSize;
+    void*           mMixerBuffer = nullptr;       // mixer output buffer.
+    size_t          mMixerBufferSize = 0;
     static constexpr audio_format_t mMixerBufferFormat = AUDIO_FORMAT_PCM_FLOAT;
 
     uint32_t        mAudioChannelCount; // audio channel count, excludes haptic channels.
 
-    enum {UNDEFINED, MIXED, ZEROED} mMixerBufferState;
-    NBAIO_Format    mFormat;
-    unsigned        mSampleRate;
-    int             mFastTracksGen;
+    enum {UNDEFINED, MIXED, ZEROED} mMixerBufferState = UNDEFINED;
+    NBAIO_Format    mFormat{Format_Invalid};
+    unsigned        mSampleRate = 0;
+    int             mFastTracksGen = 0;
     FastMixerDumpState mDummyFastMixerDumpState;
-    int64_t         mTotalNativeFramesWritten;  // copied to dumpState->mFramesWritten
+    int64_t         mTotalNativeFramesWritten = 0;  // copied to dumpState->mFramesWritten
 
     // next 2 fields are valid only when timestampStatus == NO_ERROR
     ExtendedTimestamp mTimestamp;
-    int64_t         mNativeFramesWrittenButNotPresented;
+    int64_t         mNativeFramesWrittenButNotPresented = 0;
 
     audio_utils::Balance mBalance;
 
     // accessed without lock between multiple threads.
-    std::atomic_bool mMasterMono;
+    std::atomic_bool mMasterMono{};
     std::atomic<float> mMasterBalance{};
     std::atomic_int_fast64_t mBoottimeOffset;
 
diff --git a/services/audioflinger/fastpath/FastMixerDumpState.cpp b/services/audioflinger/fastpath/FastMixerDumpState.cpp
index f48f539..4f79dd6 100644
--- a/services/audioflinger/fastpath/FastMixerDumpState.cpp
+++ b/services/audioflinger/fastpath/FastMixerDumpState.cpp
@@ -29,14 +29,6 @@
 
 namespace android {
 
-FastMixerDumpState::FastMixerDumpState() : FastThreadDumpState(),
-    mWriteSequence(0), mFramesWritten(0),
-    mNumTracks(0), mWriteErrors(0),
-    mSampleRate(0), mFrameCount(0),
-    mTrackMask(0)
-{
-}
-
 // helper function called by qsort()
 static int compare_uint32_t(const void *pa, const void *pb)
 {
diff --git a/services/audioflinger/fastpath/FastMixerDumpState.h b/services/audioflinger/fastpath/FastMixerDumpState.h
index 91d85b1..1b0e029 100644
--- a/services/audioflinger/fastpath/FastMixerDumpState.h
+++ b/services/audioflinger/fastpath/FastMixerDumpState.h
@@ -54,9 +54,8 @@
 
 // Represents the dump state of a fast track
 struct FastTrackDump {
-    FastTrackDump() : mFramesReady(0) { }
     FastTrackUnderruns  mUnderruns;
-    size_t              mFramesReady;        // most recent value only; no long-term statistics kept
+    size_t              mFramesReady = 0;    // most recent value only; no long-term statistics kept
     int64_t             mFramesWritten;      // last value from track
 };
 
@@ -64,18 +63,16 @@
 static_assert(!std::is_polymorphic_v<FastTrackDump>);
 
 struct FastMixerDumpState : FastThreadDumpState {
-    FastMixerDumpState();
-
     void dump(int fd) const;    // should only be called on a stable copy, not the original
 
-    double   mLatencyMs = 0.;   // measured latency, default of 0 if no valid timestamp read.
-    uint32_t mWriteSequence;    // incremented before and after each write()
-    uint32_t mFramesWritten;    // total number of frames written successfully
-    uint32_t mNumTracks;        // total number of active fast tracks
-    uint32_t mWriteErrors;      // total number of write() errors
-    uint32_t mSampleRate;
-    size_t   mFrameCount;
-    uint32_t mTrackMask;        // mask of active tracks
+    double   mLatencyMs = 0.;     // measured latency, default of 0 if no valid timestamp read.
+    uint32_t mWriteSequence = 0;  // incremented before and after each write()
+    uint32_t mFramesWritten = 0;  // total number of frames written successfully
+    uint32_t mNumTracks = 0;      // total number of active fast tracks
+    uint32_t mWriteErrors = 0;    // total number of write() errors
+    uint32_t mSampleRate = 0;
+    size_t   mFrameCount = 0;
+    uint32_t mTrackMask = 0;      // mask of active tracks
     FastTrackDump   mTracks[FastMixerState::kMaxFastTracks];
 
     // For timestamp statistics.
diff --git a/services/audioflinger/fastpath/FastMixerState.cpp b/services/audioflinger/fastpath/FastMixerState.cpp
index dbccb10..4fe2d86 100644
--- a/services/audioflinger/fastpath/FastMixerState.cpp
+++ b/services/audioflinger/fastpath/FastMixerState.cpp
@@ -22,16 +22,7 @@
 
 namespace android {
 
-FastTrack::FastTrack() :
-    mBufferProvider(nullptr), mVolumeProvider(nullptr),
-    mChannelMask(AUDIO_CHANNEL_OUT_STEREO), mFormat(AUDIO_FORMAT_INVALID), mGeneration(0)
-{
-}
-
-FastMixerState::FastMixerState() : FastThreadState(),
-    // mFastTracks
-    mFastTracksGen(0), mTrackMask(0), mOutputSink(nullptr), mOutputSinkGen(0),
-    mFrameCount(0)
+FastMixerState::FastMixerState() : FastThreadState()
 {
     const int ok = pthread_once(&sMaxFastTracksOnce, sMaxFastTracksInit);
     if (ok != 0) {
@@ -66,7 +57,7 @@
     char value[PROPERTY_VALUE_MAX];
     if (property_get("ro.audio.max_fast_tracks", value, nullptr /* default_value */) > 0) {
         char *endptr;
-        const unsigned long ul = strtoul(value, &endptr, 0);
+        const auto ul = strtoul(value, &endptr, 0);
         if (*endptr == '\0' && kMinFastTracks <= ul && ul <= kMaxFastTracks) {
             sMaxFastTracks = (unsigned) ul;
         }
diff --git a/services/audioflinger/fastpath/FastMixerState.h b/services/audioflinger/fastpath/FastMixerState.h
index f40f612..fdf3eaa 100644
--- a/services/audioflinger/fastpath/FastMixerState.h
+++ b/services/audioflinger/fastpath/FastMixerState.h
@@ -43,13 +43,16 @@
 
 // Represents the state of a fast track
 struct FastTrack {
-    FastTrack();
+    // must be nullptr if inactive, or non-nullptr if active
+    ExtendedAudioBufferProvider* mBufferProvider = nullptr;
 
-    ExtendedAudioBufferProvider* mBufferProvider; // must be NULL if inactive, or non-NULL if active
-    VolumeProvider*         mVolumeProvider; // optional; if NULL then full-scale
-    audio_channel_mask_t    mChannelMask;    // AUDIO_CHANNEL_OUT_MONO or AUDIO_CHANNEL_OUT_STEREO
-    audio_format_t          mFormat;         // track format
-    int                     mGeneration;     // increment when any field is assigned
+    // optional: if nullptr then full-scale
+    VolumeProvider*         mVolumeProvider = nullptr;
+
+    // AUDIO_CHANNEL_OUT_MONO or AUDIO_CHANNEL_OUT_STEREO
+    audio_channel_mask_t    mChannelMask = AUDIO_CHANNEL_OUT_STEREO;
+    audio_format_t          mFormat = AUDIO_FORMAT_INVALID;         // track format
+    int                     mGeneration = 0;     // increment when any field is assigned
     bool                    mHapticPlaybackEnabled = false; // haptic playback is enabled or not
     os::HapticScale         mHapticIntensity = os::HapticScale::MUTE; // intensity of haptic data
     float                   mHapticMaxAmplitude = NAN; // max amplitude allowed for haptic data
@@ -72,11 +75,12 @@
 
     // all pointer fields use raw pointers; objects are owned and ref-counted by the normal mixer
     FastTrack   mFastTracks[kMaxFastTracks];
-    int         mFastTracksGen; // increment when any mFastTracks[i].mGeneration is incremented
-    unsigned    mTrackMask;     // bit i is set if and only if mFastTracks[i] is active
-    NBAIO_Sink* mOutputSink;    // HAL output device, must already be negotiated
-    int         mOutputSinkGen; // increment when mOutputSink is assigned
-    size_t      mFrameCount;    // number of frames per fast mix buffer
+    int         mFastTracksGen = 0; // increment when any
+                                    // mFastTracks[i].mGeneration is incremented
+    unsigned    mTrackMask = 0;     // bit i is set if and only if mFastTracks[i] is active
+    NBAIO_Sink* mOutputSink = nullptr; // HAL output device, must already be negotiated
+    int         mOutputSinkGen = 0; // increment when mOutputSink is assigned
+    size_t      mFrameCount = 0;    // number of frames per fast mix buffer
     audio_channel_mask_t mSinkChannelMask; // If not AUDIO_CHANNEL_NONE, specifies sink channel
                                            // mask when it cannot be directly calculated from
                                            // channel count
diff --git a/services/audioflinger/fastpath/FastThread.cpp b/services/audioflinger/fastpath/FastThread.cpp
index 2ebdbc1..d054d71 100644
--- a/services/audioflinger/fastpath/FastThread.cpp
+++ b/services/audioflinger/fastpath/FastThread.cpp
@@ -38,48 +38,8 @@
 
 namespace android {
 
-FastThread::FastThread(const char *cycleMs, const char *loadUs) : Thread(false /*canCallJava*/),
-    // re-initialized to &sInitial by subclass constructor
-    mPrevious(nullptr), mCurrent(nullptr),
-    /* mOldTs({0, 0}), */
-    mOldTsValid(false),
-    mSleepNs(-1),
-    mPeriodNs(0),
-    mUnderrunNs(0),
-    mOverrunNs(0),
-    mForceNs(0),
-    mWarmupNsMin(0),
-    mWarmupNsMax(LONG_MAX),
-    // re-initialized to &mDummySubclassDumpState by subclass constructor
-    mDummyDumpState(nullptr),
-    mDumpState(nullptr),
-    mIgnoreNextOverrun(true),
-#ifdef FAST_THREAD_STATISTICS
-    // mOldLoad
-    mOldLoadValid(false),
-    mBounds(0),
-    mFull(false),
-    // mTcu
-#endif
-    mColdGen(0),
-    mIsWarm(false),
-    /* mMeasuredWarmupTs({0, 0}), */
-    mWarmupCycles(0),
-    mWarmupConsecutiveInRangeCycles(0),
-    mTimestampStatus(INVALID_OPERATION),
-
-    mCommand(FastThreadState::INITIAL),
-#if 0
-    frameCount(0),
-#endif
-    mAttemptedWrite(false)
-    // mCycleMs(cycleMs)
-    // mLoadUs(loadUs)
+FastThread::FastThread(const char *cycleMs, const char *loadUs) : Thread(false /*canCallJava*/)
 {
-    mOldTs.tv_sec = 0;
-    mOldTs.tv_nsec = 0;
-    mMeasuredWarmupTs.tv_sec = 0;
-    mMeasuredWarmupTs.tv_nsec = 0;
     strlcpy(mCycleMs, cycleMs, sizeof(mCycleMs));
     strlcpy(mLoadUs, loadUs, sizeof(mLoadUs));
 }
@@ -95,7 +55,10 @@
         if (mSleepNs >= 0) {
             if (mSleepNs > 0) {
                 ALOG_ASSERT(mSleepNs < 1000000000);
-                const struct timespec req = {0, mSleepNs};
+                const struct timespec req = {
+                    0, // tv_sec
+                    static_cast<long>(mSleepNs) // NOLINT(google-runtime-int)
+                };
                 nanosleep(&req, nullptr);
             } else {
                 sched_yield();
@@ -221,7 +184,7 @@
         if (rc == 0) {
             if (mOldTsValid) {
                 time_t sec = newTs.tv_sec - mOldTs.tv_sec;
-                long nsec = newTs.tv_nsec - mOldTs.tv_nsec;
+                auto nsec = newTs.tv_nsec - mOldTs.tv_nsec;
                 ALOGE_IF(sec < 0 || (sec == 0 && nsec < 0),
                         "clock_gettime(CLOCK_MONOTONIC) failed: was %ld.%09ld but now %ld.%09ld",
                         mOldTs.tv_sec, mOldTs.tv_nsec, newTs.tv_sec, newTs.tv_nsec);
diff --git a/services/audioflinger/fastpath/FastThread.h b/services/audioflinger/fastpath/FastThread.h
index 84dc4d2..1f46b29 100644
--- a/services/audioflinger/fastpath/FastThread.h
+++ b/services/audioflinger/fastpath/FastThread.h
@@ -47,44 +47,47 @@
     virtual void onWork() = 0;
 
     // FIXME these former local variables need comments
-    const FastThreadState*  mPrevious;
-    const FastThreadState*  mCurrent;
-    struct timespec mOldTs;
-    bool            mOldTsValid;
-    long            mSleepNs;       // -1: busy wait, 0: sched_yield, > 0: nanosleep
-    long            mPeriodNs;      // expected period; the time required to render one mix buffer
-    long            mUnderrunNs;    // underrun likely when write cycle is greater than this value
-    long            mOverrunNs;     // overrun likely when write cycle is less than this value
-    long            mForceNs;       // if overrun detected,
-                                    // force the write cycle to take this much time
-    long            mWarmupNsMin;   // warmup complete when write cycle is greater than or equal to
-                                    // this value
-    long            mWarmupNsMax;   // and less than or equal to this value
-    FastThreadDumpState* mDummyDumpState;
-    FastThreadDumpState* mDumpState;
-    bool            mIgnoreNextOverrun;     // used to ignore initial overrun and first after an
-                                            // underrun
+    const FastThreadState*  mPrevious = nullptr;
+    const FastThreadState*  mCurrent = nullptr;
+    struct timespec mOldTs{};
+    bool            mOldTsValid = false;
+    int64_t         mSleepNs = -1;     // -1: busy wait, 0: sched_yield, > 0: nanosleep
+    int64_t         mPeriodNs = 0;     // expected period; the time required to
+                                       // render one mix buffer
+    int64_t         mUnderrunNs = 0;   // underrun likely when write cycle
+                                       // is greater than this value
+    int64_t         mOverrunNs = 0;    // overrun likely when write cycle is less than this value
+    int64_t         mForceNs = 0;      // if overrun detected,
+                                       // force the write cycle to take this much time
+    int64_t         mWarmupNsMin = 0;  // warmup complete when write cycle is greater
+                                       //  than or equal to this value
+    int64_t         mWarmupNsMax = INT64_MAX;  // and less than or equal to this value
+    FastThreadDumpState* mDummyDumpState = nullptr;
+    FastThreadDumpState* mDumpState = nullptr;
+    bool            mIgnoreNextOverrun = true; // used to ignore initial overrun
+                                               //  and first after an underrun
 #ifdef FAST_THREAD_STATISTICS
     struct timespec mOldLoad;       // previous value of clock_gettime(CLOCK_THREAD_CPUTIME_ID)
-    bool            mOldLoadValid;  // whether oldLoad is valid
-    uint32_t        mBounds;
-    bool            mFull;          // whether we have collected at least mSamplingN samples
+    bool            mOldLoadValid = false;  // whether oldLoad is valid
+    uint32_t        mBounds = 0;
+    bool            mFull = false;        // whether we have collected at least mSamplingN samples
 #ifdef CPU_FREQUENCY_STATISTICS
     ThreadCpuUsage  mTcu;           // for reading the current CPU clock frequency in kHz
 #endif
 #endif
-    unsigned        mColdGen;       // last observed mColdGen
-    bool            mIsWarm;        // true means ready to mix,
+    unsigned        mColdGen = 0;       // last observed mColdGen
+    bool            mIsWarm = false;        // true means ready to mix,
                                     // false means wait for warmup before mixing
-    struct timespec   mMeasuredWarmupTs;  // how long did it take for warmup to complete
-    uint32_t          mWarmupCycles;  // counter of number of loop cycles during warmup phase
-    uint32_t          mWarmupConsecutiveInRangeCycles;    // number of consecutive cycles in range
+    struct timespec   mMeasuredWarmupTs{};  // how long did it take for warmup to complete
+    uint32_t          mWarmupCycles = 0;  // counter of number of loop cycles during warmup phase
+    uint32_t          mWarmupConsecutiveInRangeCycles = 0; // number of consecutive cycles in range
     const sp<NBLog::Writer> mDummyNBLogWriter{new NBLog::Writer()};
-    status_t          mTimestampStatus;
+    status_t          mTimestampStatus = INVALID_OPERATION;
 
-    FastThreadState::Command mCommand;
-    bool            mAttemptedWrite;
+    FastThreadState::Command mCommand = FastThreadState::INITIAL;
+    bool            mAttemptedWrite = false;
 
+    // init in constructor
     char            mCycleMs[16];   // cycle_ms + suffix
     char            mLoadUs[16];    // load_us + suffix
 
diff --git a/services/audioflinger/fastpath/FastThreadDumpState.cpp b/services/audioflinger/fastpath/FastThreadDumpState.cpp
index 09d4744..747cb9e 100644
--- a/services/audioflinger/fastpath/FastThreadDumpState.cpp
+++ b/services/audioflinger/fastpath/FastThreadDumpState.cpp
@@ -19,16 +19,8 @@
 
 namespace android {
 
-FastThreadDumpState::FastThreadDumpState() :
-    mCommand(FastThreadState::INITIAL), mUnderruns(0), mOverruns(0),
-    /* mMeasuredWarmupTs({0, 0}), */
-    mWarmupCycles(0)
-#ifdef FAST_THREAD_STATISTICS
-    , mSamplingN(0), mBounds(0)
-#endif
+FastThreadDumpState::FastThreadDumpState()
 {
-    mMeasuredWarmupTs.tv_sec = 0;
-    mMeasuredWarmupTs.tv_nsec = 0;
 #ifdef FAST_THREAD_STATISTICS
     increaseSamplingN(1);
 #endif
diff --git a/services/audioflinger/fastpath/FastThreadDumpState.h b/services/audioflinger/fastpath/FastThreadDumpState.h
index 63e81d3..b7bc404 100644
--- a/services/audioflinger/fastpath/FastThreadDumpState.h
+++ b/services/audioflinger/fastpath/FastThreadDumpState.h
@@ -32,11 +32,11 @@
 struct FastThreadDumpState {
     FastThreadDumpState();
 
-    FastThreadState::Command mCommand;   // current command
-    uint32_t mUnderruns;        // total number of underruns
-    uint32_t mOverruns;         // total number of overruns
-    struct timespec mMeasuredWarmupTs;  // measured warmup time
-    uint32_t mWarmupCycles;     // number of loop cycles required to warmup
+    FastThreadState::Command mCommand = FastThreadState::INITIAL;  // current command
+    uint32_t mUnderruns = 0;        // total number of underruns
+    uint32_t mOverruns = 0;         // total number of overruns
+    struct timespec mMeasuredWarmupTs{};  // measured warmup time
+    uint32_t mWarmupCycles = 0;     // number of loop cycles required to warmup
 
 #ifdef FAST_THREAD_STATISTICS
     // Recently collected samples of per-cycle monotonic time, thread CPU time, and CPU frequency.
@@ -48,12 +48,12 @@
     // This value was chosen such that each array uses 1 small page (4 Kbytes).
     static const uint32_t kSamplingNforLowRamDevice = 0x400;
     // Corresponding runtime maximum size of sample arrays, must be a power of 2 <= kSamplingN.
-    uint32_t mSamplingN;
+    uint32_t mSamplingN = 0;
     // The bounds define the interval of valid samples, and are represented as follows:
     //      newest open (excluded) endpoint   = lower 16 bits of bounds, modulo N
     //      oldest closed (included) endpoint = upper 16 bits of bounds, modulo N
     // Number of valid samples is newest - oldest.
-    uint32_t mBounds;                   // bounds for mMonotonicNs, mThreadCpuNs, and mCpukHz
+    uint32_t mBounds = 0;               // bounds for mMonotonicNs, mThreadCpuNs, and mCpukHz
     // The elements in the *Ns arrays are in units of nanoseconds <= 3999999999.
     uint32_t mMonotonicNs[kSamplingN];  // delta monotonic (wall clock) time
     uint32_t mLoadNs[kSamplingN];       // delta CPU load in time
diff --git a/services/audioflinger/fastpath/FastThreadState.cpp b/services/audioflinger/fastpath/FastThreadState.cpp
index e6cb353..dfe8e65 100644
--- a/services/audioflinger/fastpath/FastThreadState.cpp
+++ b/services/audioflinger/fastpath/FastThreadState.cpp
@@ -19,12 +19,6 @@
 
 namespace android {
 
-FastThreadState::FastThreadState() :
-    mCommand(INITIAL), mColdFutexAddr(nullptr), mColdGen(0), mDumpState(nullptr)
-    , mNBLogWriter(nullptr)
-{
-}
-
 // static
 const char *FastThreadState::commandToString(FastThreadState::Command command)
 {
diff --git a/services/audioflinger/fastpath/FastThreadState.h b/services/audioflinger/fastpath/FastThreadState.h
index 2b8b079..8e5bedd 100644
--- a/services/audioflinger/fastpath/FastThreadState.h
+++ b/services/audioflinger/fastpath/FastThreadState.h
@@ -27,8 +27,6 @@
 
 // Represents a single state of a FastThread
 struct FastThreadState {
-                FastThreadState();
-
     using Command = uint32_t;
     static const Command
         INITIAL = 0,            // used only for the initial state
@@ -37,13 +35,14 @@
         IDLE = 3,               // either HOT_IDLE or COLD_IDLE
         EXIT = 4;               // exit from thread
         // additional values defined per subclass
-    Command     mCommand;       // current command
-    int32_t*    mColdFutexAddr; // for COLD_IDLE only, pointer to the associated futex
-    unsigned    mColdGen;       // increment when COLD_IDLE is requested so it's only performed once
+    Command     mCommand = INITIAL;       // current command
+    int32_t*    mColdFutexAddr = nullptr; // for COLD_IDLE only, pointer to the associated futex
+    unsigned    mColdGen = 0;             // increment when COLD_IDLE is requested
+                                          // so it's only performed once
 
     // This might be a one-time configuration rather than per-state
-    FastThreadDumpState* mDumpState; // if non-NULL, then update dump state periodically
-    NBLog::Writer* mNBLogWriter; // non-blocking logger
+    FastThreadDumpState* mDumpState = nullptr; // if non-NULL, then update dump state periodically
+    NBLog::Writer* mNBLogWriter = nullptr; // non-blocking logger
 
     // returns NULL if command belongs to a subclass
     static const char *commandToString(Command command);
diff --git a/services/audioflinger/fastpath/StateQueue.cpp b/services/audioflinger/fastpath/StateQueue.cpp
index 62c00be..e896d29 100644
--- a/services/audioflinger/fastpath/StateQueue.cpp
+++ b/services/audioflinger/fastpath/StateQueue.cpp
@@ -38,19 +38,6 @@
 }
 #endif
 
-// Constructor and destructor
-
-template<typename T> StateQueue<T>::StateQueue() :
-    mAck(nullptr), mCurrent(nullptr),
-    mMutating(&mStates[0]), mExpecting(nullptr),
-    mInMutation(false), mIsDirty(false), mIsInitialized(false)
-#ifdef STATE_QUEUE_DUMP
-    , mObserverDump(&mObserverDummyDump), mMutatorDump(&mMutatorDummyDump)
-#endif
-{
-    atomic_init(&mNext, static_cast<uintptr_t>(0));
-}
-
 // Observer APIs
 
 template<typename T> const T* StateQueue<T>::poll()
diff --git a/services/audioflinger/fastpath/StateQueue.h b/services/audioflinger/fastpath/StateQueue.h
index dff8f3f..29d1809 100644
--- a/services/audioflinger/fastpath/StateQueue.h
+++ b/services/audioflinger/fastpath/StateQueue.h
@@ -126,7 +126,6 @@
 template<typename T> class StateQueue {
 
 public:
-            StateQueue();
     virtual ~StateQueue() = default;  // why is this virtual?
 
     // Observer APIs
@@ -187,24 +186,27 @@
     T                 mStates[kN];      // written by mutator, read by observer
 
     // "volatile" is meaningless with SMP, but here it indicates that we're using atomic ops
-    atomic_uintptr_t  mNext; // written by mutator to advance next, read by observer
-    volatile const T* mAck;  // written by observer to acknowledge advance of next, read by mutator
+    atomic_uintptr_t  mNext{}; // written by mutator to advance next, read by observer
+    volatile const T* mAck = nullptr;  // written by observer to acknowledge advance of next,
+                                       // read by mutator
 
     // only used by observer
-    const T*          mCurrent;         // most recent value returned by poll()
+    const T*    mCurrent = nullptr;     // most recent value returned by poll()
 
     // only used by mutator
-    T*                mMutating;        // where updates by mutator are done in place
-    const T*          mExpecting;       // what the mutator expects mAck to be set to
-    bool              mInMutation;      // whether we're currently in the middle of a mutation
-    bool              mIsDirty;         // whether mutating state has been modified since last push
-    bool              mIsInitialized;   // whether mutating state has been initialized yet
+    T*          mMutating{&mStates[0]}; // where updates by mutator are done in place
+    const T*    mExpecting = nullptr;   // what the mutator expects mAck to be set to
+    bool        mInMutation = false;    // whether we're currently in the middle of a mutation
+    bool        mIsDirty = false;       // whether mutating state has been modified since last push
+    bool        mIsInitialized = false; // whether mutating state has been initialized yet
 
 #ifdef STATE_QUEUE_DUMP
     StateQueueObserverDump  mObserverDummyDump; // default area for observer dump if not set
-    StateQueueObserverDump* mObserverDump;      // pointer to active observer dump, always non-NULL
+    // pointer to active observer dump, always non-nullptr
+    StateQueueObserverDump* mObserverDump{&mObserverDummyDump};
     StateQueueMutatorDump   mMutatorDummyDump;  // default area for mutator dump if not set
-    StateQueueMutatorDump*  mMutatorDump;       // pointer to active mutator dump, always non-NULL
+    // pointer to active mutator dump, always non-nullptr
+    StateQueueMutatorDump*  mMutatorDump{&mMutatorDummyDump};
 #endif
 
 };  // class StateQueue