Audio HAL: fixes for issues discovered after client conversion

Several issues addressed:

  -- added IDevice.supportsAudioPatches to query whether
     create/removeAudioPatch is actually supported by HAL;

  -- IStreamOutCallback proxy needs to be owned by IStreamOut
     implementation. In order for the client to reset the reference,
     added method IStreamOut.clearCallback;

  -- IDevice.open{Input|Output}Stream need to return a "suggested" audio
     config from HAL;

  -- code for converting between system/audio.h and HIDL
     data structures has been moved to
     android.hardware.audio.common@2.0-util library for reuse;

  -- added a workaround for the issue with QC effects HAL trying to write
     into the input parameters buffer, which is r/o by Binder design.

Bug: 30222631
Change-Id: I64af24d79c12d6ac3b0f87d085a821913e29237b
Test: tried using with WIP HIDL client on N5X
diff --git a/audio/2.0/IDevice.hal b/audio/2.0/IDevice.hal
index 38bfe21..630a32c 100644
--- a/audio/2.0/IDevice.hal
+++ b/audio/2.0/IDevice.hal
@@ -102,6 +102,8 @@
 
     /*
      * This method creates and opens the audio hardware output stream.
+     * If the stream can not be opened with the proposed audio config,
+     * HAL must provide suggested values for the audio config.
      *
      * @param ioHandle handle assigned by AudioFlinger.
      * @param device device type and (if needed) address.
@@ -109,15 +111,21 @@
      * @param flags additional flags.
      * @return retval operation completion status.
      * @return outStream created output stream.
+     * @return suggestedConfig in case of invalid parameters, suggested config.
      */
     openOutputStream(
             AudioIoHandle ioHandle,
             DeviceAddress device,
             AudioConfig config,
-            AudioOutputFlag flags) generates (Result retval, IStreamOut outStream);
+            AudioOutputFlag flags) generates (
+                    Result retval,
+                    IStreamOut outStream,
+                    AudioConfig suggestedConfig);
 
     /*
      * This method creates and opens the audio hardware input stream.
+     * If the stream can not be opened with the proposed audio config,
+     * HAL must provide suggested values for the audio config.
      *
      * @param ioHandle handle assigned by AudioFlinger.
      * @param device device type and (if needed) address.
@@ -125,14 +133,25 @@
      * @param flags additional flags.
      * @param source source specification.
      * @return retval operation completion status.
-     * @return inStream created input stream.
+     * @return inStream in case of success, created input stream.
+     * @return suggestedConfig in case of invalid parameters, suggested config.
      */
     openInputStream(
             AudioIoHandle ioHandle,
             DeviceAddress device,
             AudioConfig config,
             AudioInputFlag flags,
-            AudioSource source) generates (Result retval, IStreamIn inStream);
+            AudioSource source) generates (
+                    Result retval,
+                    IStreamIn inStream,
+                    AudioConfig suggestedConfig);
+
+    /*
+     * Returns whether HAL supports audio patches.
+     *
+     * @return supports true if audio patches are supported.
+     */
+    supportsAudioPatches() generates (bool supports);
 
     /*
      * Creates an audio patch between several source and sink ports.  The handle