Audio HAL: Add optional Destination to SinkMetadata

Currently this is used to indicate the output device
when the input stream is from an intermediate processing
module like MSD.

Bug: 120859615
Test: make
Change-Id: I60bac5c24a263ab0b8965e9dbf9514445e88c270
diff --git a/audio/common/5.0/Android.bp b/audio/common/5.0/Android.bp
index 663f847..86d9354 100644
--- a/audio/common/5.0/Android.bp
+++ b/audio/common/5.0/Android.bp
@@ -9,6 +9,9 @@
     srcs: [
         "types.hal",
     ],
+    interfaces: [
+        "android.hidl.safe_union@1.0",
+    ],
     types: [
         "AudioChannelMask",
         "AudioConfig",
@@ -38,7 +41,12 @@
         "AudioSource",
         "AudioStreamType",
         "AudioUsage",
+        "DeviceAddress",
         "FixedChannelCount",
+        "PlaybackTrackMetadata",
+        "RecordTrackMetadata",
+        "SinkMetadata",
+        "SourceMetadata",
         "ThreadInfo",
         "Uuid",
     ],
diff --git a/audio/common/5.0/types.hal b/audio/common/5.0/types.hal
index e5919cb..dab7464 100644
--- a/audio/common/5.0/types.hal
+++ b/audio/common/5.0/types.hal
@@ -16,6 +16,8 @@
 
 package android.hardware.audio.common@5.0;
 
+import android.hidl.safe_union@1.0;
+
 /*
  *
  *  IDs and Handles
@@ -602,6 +604,29 @@
 };
 
 /**
+ * IEEE 802 MAC address.
+ */
+typedef uint8_t[6] MacAddress;
+
+/**
+ * Specifies a device address in case when several devices of the same type
+ * can be connected (e.g. BT A2DP, USB).
+ */
+struct DeviceAddress {
+    AudioDevice device;  // discriminator
+    union Address {
+        MacAddress mac;     // used for BLUETOOTH_A2DP_*
+        uint8_t[4] ipv4;    // used for IP
+        struct Alsa {
+            int32_t card;
+            int32_t device;
+        } alsa;             // used for USB_*
+    } address;
+    string busAddress;      // used for BUS
+    string rSubmixAddress;  // used for REMOTE_SUBMIX
+};
+
+/**
  * The audio output flags serve two purposes:
  *
  *  - when an AudioTrack is created they indicate a "wish" to be connected to an
@@ -748,9 +773,17 @@
      * Must not be negative.
      */
     float gain;
+    /**
+     * Indicates the destination of an input stream, can be left unspecified.
+     */
+    safe_union Destination {
+        Monostate unspecified;
+        DeviceAddress device;
+    };
+    Destination destination;
 };
 
-/** Metadatas of the source of a StreamIn. */
+/** Metadatas of the sink of a StreamIn. */
 struct SinkMetadata {
     vec<RecordTrackMetadata> tracks;
 };