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/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index 2106256..4ee4961 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -191,23 +191,27 @@
     return mStreamCommon->analyzeStatus("set_callback", result);
 }
 
+Return<Result> StreamOut::clearCallback()  {
+    if (mStream->set_callback == NULL) return Result::NOT_SUPPORTED;
+    mCallback.clear();
+    return Result::OK;
+}
+
 // static
 int StreamOut::asyncCallback(stream_callback_event_t event, void*, void *cookie) {
     wp<StreamOut> weakSelf(reinterpret_cast<StreamOut*>(cookie));
     sp<StreamOut> self = weakSelf.promote();
-    if (self == 0) return 0;
-    sp<IStreamOutCallback> callback = self->mCallback.promote();
-    if (callback == 0) return 0;
+    if (self == nullptr || self->mCallback == nullptr) return 0;
     ALOGV("asyncCallback() event %d", event);
     switch (event) {
         case STREAM_CBK_EVENT_WRITE_READY:
-            callback->onWriteReady();
+            self->mCallback->onWriteReady();
             break;
         case STREAM_CBK_EVENT_DRAIN_READY:
-            callback->onDrainReady();
+            self->mCallback->onDrainReady();
             break;
         case STREAM_CBK_EVENT_ERROR:
-            callback->onError();
+            self->mCallback->onError();
             break;
         default:
             ALOGW("asyncCallback() unknown event %d", event);