Initialize volume as 0 for volume control effect.

If a effect is going to be the effect that controls volume, initialize
the volume as 0 for safe ramping. The actual volume is always set when
preparing the tracks. However, the effect can still be enabled after
that and before the next tracks preparation. In that case, initialize
the volume as 0 can help avoid sound blast out when the effect is
enabled.

Bug: 328598362
Test: atest AudioEffectTest
Test: repo steps in the bug
Change-Id: I24eb3c7f21dee8dd4bf9337010b05c09f8f00873
Merged-In: I24eb3c7f21dee8dd4bf9337010b05c09f8f00873
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index d2a4cb4..f837ab8 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -25,6 +25,8 @@
 #include <private/media/AudioEffectShared.h>
 
 #include <map>  // avoid transitive dependency
+#include <optional>
+#include <vector>
 
 namespace android {
 
@@ -215,7 +217,7 @@
     }
     status_t setDevices(const AudioDeviceTypeAddrVector& devices) final EXCLUDES_EffectBase_Mutex;
     status_t setInputDevice(const AudioDeviceTypeAddr& device) final EXCLUDES_EffectBase_Mutex;
-    status_t setVolume(uint32_t *left, uint32_t *right, bool controller) final;
+    status_t setVolume(uint32_t *left, uint32_t *right, bool controller, bool force) final;
     status_t setMode(audio_mode_t mode) final EXCLUDES_EffectBase_Mutex;
     status_t setAudioSource(audio_source_t source) final EXCLUDES_EffectBase_Mutex;
     status_t start_l() final REQUIRES(audio_utils::EffectChain_Mutex) EXCLUDES_EffectBase_Mutex;
@@ -304,6 +306,8 @@
     static constexpr pid_t INVALID_PID = (pid_t)-1;
     // this tid is allowed to call setVolume() without acquiring the mutex.
     pid_t mSetVolumeReentrantTid = INVALID_PID;
+
+    std::optional<std::vector<uint32_t>> mVolume;
 };
 
 // The EffectHandle class implements the IEffect interface. It provides resources