audiohal: Fix volume changes handling
Some legacy implementations of the effects HAL use the condition
of the reply buffer being NULL as an indication that they shouldn't
apply attenuation to the input audio data. Therefore, separate
methods are needed to distinguish the use cases of delegating the
volume control to the effect, and just informing the effect of the
volume changes.
A new method added to IEffect: volumeChangeNotification that implements
the second use case. The contract of setAndGetVolume method has been
updated to indicate that it is only called in the first use case.
Also updated the wrapper for a generic IEffect commands to pass NULL
pointers to the command and reply buffers in case when the size
of the input or output data is 0, to preserve compatibility with
direct calls from the framework.
Bug: 34368451
Test: volume control works when both Bass Boost and Equalizer are
enabled in the NXP implementation of the effects
Change-Id: I3c9a5bbdff561802bc94080c51703385a8903282
diff --git a/audio/effect/2.0/IEffect.hal b/audio/effect/2.0/IEffect.hal
index 9027c68..9e10117 100644
--- a/audio/effect/2.0/IEffect.hal
+++ b/audio/effect/2.0/IEffect.hal
@@ -83,20 +83,17 @@
/*
* Set and get volume. Used by audio framework to delegate volume control to
- * effect engine. The effect implementation must set EFFECT_FLAG_VOLUME_IND
- * or EFFECT_FLAG_VOLUME_CTRL flag in its descriptor to receive this command
- * before every call to 'process' function If EFFECT_FLAG_VOLUME_CTRL flag
- * is set in the effect descriptor, the effect engine must return the volume
- * that should be applied before the effect is processed. The overall volume
- * (the volume actually applied by the effect engine multiplied by the
- * returned value) should match the value indicated in the command.
+ * effect engine. The effect implementation must set EFFECT_FLAG_VOLUME_CTRL
+ * flag in its descriptor to receive this command. The effect engine must
+ * return the volume that should be applied before the effect is
+ * processed. The overall volume (the volume actually applied by the effect
+ * engine multiplied by the returned value) should match the value indicated
+ * in the command.
*
* @param volumes vector containing volume for each channel defined in
* EffectConfig for output buffer expressed in 8.24 fixed
* point format.
- * @return result updated volume values. It is OK to receive an empty vector
- * as a result in which case the effect framework has
- * delegated volume control to another effect.
+ * @return result updated volume values.
* @return retval operation completion status.
*/
@callflow(next={"*"})
@@ -104,6 +101,19 @@
generates (Result retval, vec<uint32_t> result);
/*
+ * Notify the effect of the volume change. The effect implementation must
+ * set EFFECT_FLAG_VOLUME_IND flag in its descriptor to receive this
+ * command.
+ *
+ * @param volumes vector containing volume for each channel defined in
+ * EffectConfig for output buffer expressed in 8.24 fixed
+ * point format.
+ * @return retval operation completion status.
+ */
+ volumeChangeNotification(vec<uint32_t> volumes)
+ generates (Result retval);
+
+ /*
* Set the audio mode. The effect implementation must set
* EFFECT_FLAG_AUDIO_MODE_IND flag in its descriptor to receive this command
* when the audio mode changes.