audio policy: add support for custom mixes

Add support for custom mixes in AudioPolicyManager.

Two methods are added to register or unregister a list of custom mixes
with their attributes and format.

getOutputForAttr() and getInputForAttr() first look for a match in
registered mixes before defaulting to normal output/input selection

Remote submix device connection disconnection now takes address into
account to identify the correspnoding custom mix.

Bug: 16009464.

Change-Id: I3f1c2a485a0fb71b1f984ed0adc9b68aa971e408
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index e4c3c08..d9c3177 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -851,6 +851,10 @@
         // due to hardware latency. We leave this behavior for now.
         *position = dspFrames;
     } else {
+        if (mCblk->mFlags & CBLK_INVALID) {
+            restoreTrack_l("getPosition");
+        }
+
         // IAudioTrack::stop() isn't synchronous; we don't know when presentation completes
         *position = (mState == STATE_STOPPED || mState == STATE_FLUSHED) ?
                 0 : updateAndGetPosition_l();
@@ -1946,6 +1950,10 @@
         break;
     }
 
+    if (mCblk->mFlags & CBLK_INVALID) {
+        restoreTrack_l("getTimestamp");
+    }
+
     // The presented frame count must always lag behind the consumed frame count.
     // To avoid a race, read the presented frames first.  This ensures that presented <= consumed.
     status_t status = mAudioTrack->getTimestamp(timestamp);