Adding Audio HAL V5: Direction API

Bug: 119137468
Test: Tesbed App

Change-Id: I0dfc773344654f61f2ad9f5e8ed22a96e6b26ad5
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 10a8789..feebd23 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -550,6 +550,36 @@
                                   size_t *mic_count);
 
     /**
+     * Called by the framework to instruct the HAL to optimize the capture stream in the
+     * specified direction.
+     *
+     * \param[in] stream    the stream object.
+     * \param[in] direction The direction constant (from audio-base.h)
+     *   MIC_DIRECTION_UNSPECIFIED  Don't do any directionality processing of the
+     *      activated microphone(s).
+     *   MIC_DIRECTION_FRONT        Optimize capture for audio coming from the screen-side
+     *      of the device.
+     *   MIC_DIRECTION_BACK         Optimize capture for audio coming from the side of the
+     *      device opposite the screen.
+     *   MIC_DIRECTION_EXTERNAL     Optimize capture for audio coming from an off-device
+     *      microphone.
+     * \return OK if the call is successful, an error code otherwise.
+     */
+    int (*set_microphone_direction)(const struct audio_stream_in *stream,
+                                    audio_microphone_direction_t direction);
+
+    /**
+     * Called by the framework to specify to the HAL the desired zoom factor for the selected
+     * microphone(s).
+     *
+     * \param[in] stream    the stream object.
+     * \param[in] zoom      the zoom factor.
+     * \return OK if the call is successful, an error code otherwise.
+     */
+    int (*set_microphone_field_dimension)(const struct audio_stream_in *stream,
+                                          float zoom);
+
+    /**
      * Called when the metadata of the stream's sink has been changed.
      * @param sink_metadata Description of the audio that is recorded by the clients.
      */
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c
index cddcc14..f0ea015 100644
--- a/modules/usbaudio/audio_hal.c
+++ b/modules/usbaudio/audio_hal.c
@@ -918,6 +918,30 @@
     return ret;
 }
 
+static int in_get_active_microphones(const struct audio_stream_in *stream,
+                                     struct audio_microphone_characteristic_t *mic_array,
+                                     size_t *mic_count) {
+    (void)stream;
+    (void)mic_array;
+    (void)mic_count;
+
+    return -ENOSYS;
+}
+
+static int in_set_microphone_direction(const struct audio_stream_in *stream,
+                                           audio_microphone_direction_t dir) {
+    (void)stream;
+    (void)dir;
+    ALOGV("---- in_set_microphone_direction()");
+    return -ENOSYS;
+}
+
+static int in_set_microphone_field_dimension(const struct audio_stream_in *stream, float zoom) {
+    (void)zoom;
+    ALOGV("---- in_set_microphone_field_dimension()");
+    return -ENOSYS;
+}
+
 static int adev_open_input_stream(struct audio_hw_device *hw_dev,
                                   audio_io_handle_t handle,
                                   audio_devices_t devicesSpec __unused,
@@ -963,6 +987,10 @@
     in->stream.get_input_frames_lost = in_get_input_frames_lost;
     in->stream.get_capture_position = in_get_capture_position;
 
+    in->stream.get_active_microphones = in_get_active_microphones;
+    in->stream.set_microphone_direction = in_set_microphone_direction;
+    in->stream.set_microphone_field_dimension = in_set_microphone_field_dimension;
+
     stream_lock_init(&in->lock);
 
     in->adev = (struct audio_device *)hw_dev;