audioflinger: forward flush to direct output streams

Track flush should be forwarded to the audio HAL when playing
on a direct output stream.

Bug: 17704953.
Change-Id: Iafc94327fe9aebf1d4eaa97b76c6767b7ac5babe
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 818bb05..faca7ab 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -4040,6 +4040,9 @@
                         track->mState = TrackBase::STOPPED;
                     }
                     if (track->isStopped()) {
+                        if (track->mState == TrackBase::FLUSHED) {
+                            flushHw_l();
+                        }
                         track->reset();
                     }
                     tracksToRemove->add(track);
@@ -4212,6 +4215,12 @@
     }
 }
 
+void AudioFlinger::DirectOutputThread::flushHw_l()
+{
+    if (mOutput->stream->flush != NULL)
+        mOutput->stream->flush(mOutput->stream);
+}
+
 // ----------------------------------------------------------------------------
 
 AudioFlinger::AsyncCallbackThread::AsyncCallbackThread(
@@ -4579,7 +4588,7 @@
 
 void AudioFlinger::OffloadThread::flushHw_l()
 {
-    mOutput->stream->flush(mOutput->stream);
+    DirectOutputThread::flushHw_l();
     // Flush anything still waiting in the mixbuffer
     mCurrentWriteLength = 0;
     mBytesRemaining = 0;