Audio V4: Add metadata update to legacy API

The metadata API was not present in the legacy HAL API
which lots of developer still use.

Test: Check the method is correctly called on each track change
Bug: 38184704
Bug: 69623109
Change-Id: I46a9db5a67baef52844ed85296a529402e00f4cb
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 9ad0f8b..10a8789 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -212,13 +212,24 @@
                                    give time for gapless track switch */
 } audio_drain_type_t;
 
+typedef struct source_metadata {
+    size_t track_count;
+    /** Array of metadata of each track connected to this source. */
+    struct playback_track_metadata* tracks;
+} source_metadata_t;
+
+typedef struct sink_metadata {
+    size_t track_count;
+    /** Array of metadata of each track connected to this sink. */
+    struct record_track_metadata* tracks;
+} sink_metadata_t;
+
 /**
  * audio_stream_out is the abstraction interface for the audio output hardware.
  *
  * It provides information about various properties of the audio output
  * hardware driver.
  */
-
 struct audio_stream_out {
     /**
      * Common methods of the audio stream out.  This *must* be the first member of audio_stream_out
@@ -403,6 +414,13 @@
      */
     int (*get_mmap_position)(const struct audio_stream_out *stream,
                              struct audio_mmap_position *position);
+
+    /**
+     * Called when the metadata of the stream's source has been changed.
+     * @param source_metadata Description of the audio that is played by the clients.
+     */
+    void (*update_source_metadata)(struct audio_stream_out *stream,
+                                   const struct source_metadata* source_metadata);
 };
 typedef struct audio_stream_out audio_stream_out_t;
 
@@ -530,6 +548,13 @@
     int (*get_active_microphones)(const struct audio_stream_in *stream,
                                   struct audio_microphone_characteristic_t *mic_array,
                                   size_t *mic_count);
+
+    /**
+     * 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.
+     */
+    void (*update_sink_metadata)(struct audio_stream_in *stream,
+                                 const struct sink_metadata* sink_metadata);
 };
 typedef struct audio_stream_in audio_stream_in_t;