Implement audio devices and streams HAL delegating to legacy HAL

Changes made to the .hal definition:

  - introduce Effect ID returned by the IEffectsFactory that
    needs to be passed to IStream.{add|remove}Effect; otherwise
    it's impossible to retrieve the underlying HAL effect handle;

  - change "bus address" in DeviceAddress to "string" type;

  - fix signature of some methods w.r.t. returning Result;

  - remove unused "struct AudioPatch".

Bug: 30222631
Test: make
Change-Id: Icb51729ef57bb2a5b0b78609735e7481bc04f95c
diff --git a/audio/effect/2.0/default/EffectsFactory.cpp b/audio/effect/2.0/default/EffectsFactory.cpp
index f7c5d62..30fcb26 100644
--- a/audio/effect/2.0/default/EffectsFactory.cpp
+++ b/audio/effect/2.0/default/EffectsFactory.cpp
@@ -36,6 +36,7 @@
 #include "EffectsFactory.h"
 #include "DownmixEffect.h"
 #include "Effect.h"
+#include "EffectMap.h"
 #include "EnvironmentalReverbEffect.h"
 #include "EqualizerEffect.h"
 #include "LoudnessEnhancerEffect.h"
@@ -157,12 +158,16 @@
     Result retval(Result::OK);
     status_t status = EffectCreate(&halUuid, session, ioHandle, &handle);
     sp<IEffect> effect;
+    uint64_t effectId = EffectMap::INVALID_ID;
     if (status == OK) {
         effect_descriptor_t halDescriptor;
         memset(&halDescriptor, 0, sizeof(effect_descriptor_t));
         status = (*handle)->get_descriptor(handle, &halDescriptor);
         if (status == OK) {
             effect = dispatchEffectInstanceCreation(halDescriptor, handle);
+            effectId = EffectMap::getInstance().add(handle);
+        } else {
+            EffectRelease(handle);
         }
     }
     if (status != OK) {
@@ -173,7 +178,7 @@
             retval = Result::NOT_INITIALIZED;
         }
     }
-    _hidl_cb(retval, effect);
+    _hidl_cb(retval, effect, effectId);
     return Void();
 }