libaudiohal@aidl: Enforce thread safety for DeviceHalAidl

Since methods of DeviceHalAidl can be called by the framework
from multiple threads, access to inner data structures must
be serialized. To implement this, encapsulate all internal
data structures into a new class 'Hal2AidlMapper', and guard
access to its instance with a mutex.

This split also helps to make the size of DeviceHalAidl
more manageable, and narrow its function to translation
between lecacy and AIDL data structures and then calling
into 'Hal2AidlMapper'.

Thanks to removal of extra code from DeviceHalAidl it has
become easier to unify the code of its entry points.

Bug: 302132812
Bug: 303742495
Test: atest CtsMediaAudioTestCases
Change-Id: I4d14177445005fd5138e297eddd218e98ad2acd3
diff --git a/media/libaudiohal/impl/StreamHalAidl.cpp b/media/libaudiohal/impl/StreamHalAidl.cpp
index e74fc16..378d919 100644
--- a/media/libaudiohal/impl/StreamHalAidl.cpp
+++ b/media/libaudiohal/impl/StreamHalAidl.cpp
@@ -83,6 +83,7 @@
           mContext(std::move(context)),
           mStream(stream),
           mVendorExt(vext) {
+    ALOGD("%p %s::%s", this, getClassName().c_str(), __func__);
     {
         std::lock_guard l(mLock);
         mLastReply.latencyMs = nominalLatency;
@@ -97,6 +98,7 @@
 }
 
 StreamHalAidl::~StreamHalAidl() {
+    ALOGD("%p %s::%s", this, getClassName().c_str(), __func__);
     if (mStream != nullptr) {
         ndk::ScopedAStatus status = mStream->close();
         ALOGE_IF(!status.isOk(), "%s: status %s", __func__, status.getDescription().c_str());