Audio V4: More fixes of the audio 2.0 API

Remove unnecessary Result typedef.
Make bufferSizeFrames and burstSizeFrames unsigned
as they should not be negative.
Remove legacy AudioInterleave.
Remove implicit callflow annotation.
Make EffectConfigParameters a bitfield.

Bug: 38184704
Test: hardware/interfaces/update-makefiles.py
Change-Id: I33e6f7869d20ca0cad4123f32347754e5a514caa
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/audio/4.0/IDevice.hal b/audio/4.0/IDevice.hal
index 8af4ee1..bb58568 100644
--- a/audio/4.0/IDevice.hal
+++ b/audio/4.0/IDevice.hal
@@ -21,8 +21,6 @@
 import IStreamOut;
 
 interface IDevice {
-    typedef android.hardware.audio@4.0::Result Result;
-
     /**
      * Returns whether the audio hardware interface has been initialized.
      *
diff --git a/audio/4.0/IDevicesFactory.hal b/audio/4.0/IDevicesFactory.hal
index b884c6b..c552c6d 100644
--- a/audio/4.0/IDevicesFactory.hal
+++ b/audio/4.0/IDevicesFactory.hal
@@ -20,8 +20,6 @@
 import IDevice;
 
 interface IDevicesFactory {
-    typedef android.hardware.audio@4.0::Result Result;
-
     /** Allows a HAL implementation to be split in multiple independent
      *  devices (called module in the pre-treble API).
      *  Note that this division is arbitrary and implementation are free
diff --git a/audio/4.0/IPrimaryDevice.hal b/audio/4.0/IPrimaryDevice.hal
index 4eafdbb..f3d904c 100644
--- a/audio/4.0/IPrimaryDevice.hal
+++ b/audio/4.0/IPrimaryDevice.hal
@@ -20,8 +20,6 @@
 import IDevice;
 
 interface IPrimaryDevice extends IDevice {
-    typedef android.hardware.audio@4.0::Result Result;
-
     /**
      * Sets the audio volume of a voice call.
      *
diff --git a/audio/4.0/IStream.hal b/audio/4.0/IStream.hal
index 34e7a14..f05d7b0 100644
--- a/audio/4.0/IStream.hal
+++ b/audio/4.0/IStream.hal
@@ -20,8 +20,6 @@
 import android.hardware.audio.effect@4.0::IEffect;
 
 interface IStream {
-    typedef android.hardware.audio@4.0::Result Result;
-
     /**
      * Return the frame size (number of bytes per sample).
      *
diff --git a/audio/4.0/IStreamIn.hal b/audio/4.0/IStreamIn.hal
index 3b2dc25..247e826 100644
--- a/audio/4.0/IStreamIn.hal
+++ b/audio/4.0/IStreamIn.hal
@@ -20,8 +20,6 @@
 import IStream;
 
 interface IStreamIn extends IStream {
-    typedef android.hardware.audio@4.0::Result Result;
-
     /**
      * Returns the source descriptor of the input stream. Calling this method is
      * equivalent to getting AUDIO_PARAMETER_STREAM_INPUT_SOURCE on the legacy
diff --git a/audio/4.0/IStreamOut.hal b/audio/4.0/IStreamOut.hal
index 585bffe..3aa93fc 100644
--- a/audio/4.0/IStreamOut.hal
+++ b/audio/4.0/IStreamOut.hal
@@ -21,8 +21,6 @@
 import IStreamOutCallback;
 
 interface IStreamOut extends IStream {
-    typedef android.hardware.audio@4.0::Result Result;
-
     /**
      * Return the audio hardware driver estimated latency in milliseconds.
      *
diff --git a/audio/4.0/types.hal b/audio/4.0/types.hal
index 50ebc57..7853f3c 100644
--- a/audio/4.0/types.hal
+++ b/audio/4.0/types.hal
@@ -93,9 +93,9 @@
     /** Mmap memory buffer */
     memory  sharedMemory;
     /** Total buffer size in frames */
-    int32_t bufferSizeFrames;
+    uint32_t bufferSizeFrames;
     /** Transfer size granularity in frames */
-    int32_t burstSizeFrames;
+    uint32_t burstSizeFrames;
     /** Attributes describing the buffer. */
     bitfield<MmapBufferFlag> flags;
 };
diff --git a/audio/common/4.0/types.hal b/audio/common/4.0/types.hal
index 2c6e0a3..d4c6efe 100644
--- a/audio/common/4.0/types.hal
+++ b/audio/common/4.0/types.hal
@@ -470,23 +470,6 @@
     INDEX_MASK_8 = INDEX_HDR | ((1 << 8) - 1)
 };
 
-
-/**
- * Expresses the convention when stereo audio samples are stored interleaved
- * in an array.  This should improve readability by allowing code to use
- * symbolic indices instead of hard-coded [0] and [1].
- *
- * For multi-channel beyond stereo, the platform convention is that channels
- * are interleaved in order from least significant channel mask bit to most
- * significant channel mask bit, with unused bits skipped.  Any exceptions
- * to this convention will be noted at the appropriate API.
- */
-@export(name="", value_prefix="AUDIO_INTERLEAVE_")
-enum AudioInterleave : int32_t {
-    LEFT   = 0,
-    RIGHT  = 1,
-};
-
 /**
  * Major modes for a mobile device. The current mode setting affects audio
  * routing.
@@ -495,7 +478,9 @@
 enum AudioMode : int32_t {
     NORMAL           = 0,
     RINGTONE         = 1,
+    /** Calls handled by the telephony stack (Eg: PSTN). */
     IN_CALL          = 2,
+    /** Calls handled by apps (Eg: Hangout). */
     IN_COMMUNICATION = 3,
 };
 
@@ -854,6 +839,7 @@
 struct AudioPortDeviceExt {
     AudioModuleHandle hwModule;    // module the device is attached to
     AudioDevice type;
+    /** 32 byte string identifying the port. */
     uint8_t[32] address;
 };
 
@@ -864,7 +850,7 @@
 enum AudioMixLatencyClass : int32_t {
     LOW,
     NORMAL
-} ;
+};
 
 struct AudioPortMixExt {
     AudioModuleHandle hwModule;     // module the stream is attached to
diff --git a/audio/effect/4.0/IEffect.hal b/audio/effect/4.0/IEffect.hal
index afc0237..d1d9496 100644
--- a/audio/effect/4.0/IEffect.hal
+++ b/audio/effect/4.0/IEffect.hal
@@ -26,7 +26,6 @@
      * @return retval operation completion status.
      */
     @entry
-    @callflow(next={"*"})
     init() generates (Result retval);
 
     /**
@@ -39,7 +38,6 @@
      * @param outputBufferProvider optional buffer provider reference.
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     setConfig(EffectConfig config,
             IEffectBufferProviderCallback inputBufferProvider,
             IEffectBufferProviderCallback outputBufferProvider)
@@ -51,7 +49,6 @@
      *
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     reset() generates (Result retval);
 
     /**
@@ -81,7 +78,6 @@
      * @param device output device specification.
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     setDevice(bitfield<AudioDevice> device) generates (Result retval);
 
     /**
@@ -99,7 +95,6 @@
      * @return result updated volume values.
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     setAndGetVolume(vec<uint32_t> volumes)
             generates (Result retval, vec<uint32_t> result);
 
@@ -124,7 +119,6 @@
      * @param mode desired audio mode.
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     setAudioMode(AudioMode mode) generates (Result retval);
 
     /**
@@ -137,7 +131,6 @@
      * @param outputBufferProvider optional buffer provider reference.
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     setConfigReverse(EffectConfig config,
             IEffectBufferProviderCallback inputBufferProvider,
             IEffectBufferProviderCallback outputBufferProvider)
@@ -154,7 +147,6 @@
      * @param device input device specification.
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     setInputDevice(bitfield<AudioDevice> device) generates (Result retval);
 
     /**
@@ -163,7 +155,6 @@
      * @return retval operation completion status.
      * @return config configuration descriptor.
      */
-    @callflow(next={"*"})
     getConfig() generates (Result retval, EffectConfig config);
 
     /**
@@ -173,7 +164,6 @@
      * @return retval operation completion status.
      * @return config configuration descriptor.
      */
-    @callflow(next={"*"})
     getConfigReverse() generates (Result retval, EffectConfig config);
 
     /**
@@ -186,7 +176,6 @@
      *                the number of supported combinations exceeds 'maxConfigs'.
      * @return result list of configuration descriptors.
      */
-    @callflow(next={"*"})
     getSupportedAuxChannelsConfigs(uint32_t maxConfigs)
             generates (Result retval, vec<EffectAuxChannelsConfig> result);
 
@@ -197,7 +186,6 @@
      *                NOT_SUPPORTED code.
      * @return result configuration descriptor.
      */
-    @callflow(next={"*"})
     getAuxChannelsConfig()
             generates (Result retval, EffectAuxChannelsConfig result);
 
@@ -207,7 +195,6 @@
      * @return retval operation completion status; absence of the feature
      *                support is indicated using NOT_SUPPORTED code.
      */
-    @callflow(next={"*"})
     setAuxChannelsConfig(EffectAuxChannelsConfig config)
             generates (Result retval);
 
@@ -221,7 +208,6 @@
      * @param source source descriptor.
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     setAudioSource(AudioSource source) generates (Result retval);
 
     /**
@@ -232,7 +218,6 @@
      * @param param effect offload descriptor.
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     offload(EffectOffloadParameter param) generates (Result retval);
 
     /**
@@ -241,7 +226,6 @@
      * @return retval operation completion status.
      * @return descriptor effect descriptor.
      */
-    @callflow(next={"*"})
     getDescriptor() generates (Result retval, EffectDescriptor descriptor);
 
     /**
@@ -285,9 +269,8 @@
      *                INVALID_ARGUMENTS if there was a problem with mapping
      *                                  any of the buffers.
      */
-    @callflow(next={"*"})
-    setProcessBuffers(AudioBuffer inBuffer, AudioBuffer outBuffer) generates (
-            Result retval);
+    setProcessBuffers(AudioBuffer inBuffer, AudioBuffer outBuffer)
+            generates (Result retval);
 
     /**
      * Execute a vendor specific command on the effect. The command code
@@ -327,7 +310,6 @@
      * @param value the value of the parameter.
      * @return retval operation completion status.
      */
-    @callflow(next={"*"})
     setParameter(vec<uint8_t> parameter, vec<uint8_t> value)
             generates (Result retval);
 
@@ -349,7 +331,6 @@
      * @return retval operation completion status.
      * @return result the value of the parameter.
      */
-    @callflow(next={"*"})
     getParameter(vec<uint8_t> parameter, uint32_t valueMaxSize)
             generates (Result retval, vec<uint8_t> value);
 
@@ -375,7 +356,6 @@
      * @return configsCount number of configs returned.
      * @return configsData data for all the configs returned.
      */
-    @callflow(next={"*"})
     getSupportedConfigsForFeature(
             uint32_t featureId,
             uint32_t maxConfigs,
@@ -402,7 +382,6 @@
      * @return retval operation completion status.
      * @return configData config data.
      */
-    @callflow(next={"*"})
     getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize)
             generates (Result retval, vec<uint8_t> configData);
 
diff --git a/audio/effect/4.0/types.hal b/audio/effect/4.0/types.hal
index 57f96e3..0f76601 100644
--- a/audio/effect/4.0/types.hal
+++ b/audio/effect/4.0/types.hal
@@ -245,7 +245,7 @@
     CHANNELS = 0x0004,  // channels
     FORMAT = 0x0008,    // format
     ACC_MODE = 0x0010,  // accessMode
-    ALL = BUFFER | SMP_RATE | CHANNELS | FORMAT | ACC_MODE
+    // Note that the 2.0 ALL have been moved to an helper function
 };
 
 /**
@@ -258,7 +258,7 @@
     bitfield<AudioChannelMask> channels;
     AudioFormat format;
     EffectBufferAccess accessMode;
-    EffectConfigParameters mask;
+    bitfield<EffectConfigParameters> mask;
 };
 
 struct EffectConfig {