force command flush after releasing a reference to shared memory

After releasing a reference to a shared memory interface,
IPCThreadState::self()->flushCommands() must be called to ensure
that the corresponding reference is also cleared immediately in the
remote process. Otherwise the binder implementaiton will not
push the clear systematically causing the memory region not to be freed.

See issues 10711502 and 2801375.

Bug: 14057166.
Change-Id: If55f36f00d452d6cf00cf83bd2fba1c8f3abcb57
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 4e8a058..1e906ad 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -223,6 +223,8 @@
         // relying on the automatic clear() at end of scope.
         mClient.clear();
     }
+    // flush the binder command buffer
+    IPCThreadState::self()->flushCommands();
 }
 
 // AudioBufferProvider interface
@@ -432,8 +434,6 @@
     // This prevents that leak.
     if (mSharedBuffer != 0) {
         mSharedBuffer.clear();
-        // flush the binder command buffer
-        IPCThreadState::self()->flushCommands();
     }
 }