AudioFlinger: flush stream when switching tracks

For direct threads, when recycling a stream, perform a flush so
that the frame position is reset.

Bug: 21145353
Change-Id: I08611cd64bb249a9659c44f9e4c47e7455f4838f
Signed-off-by: Phil Burk <philburk@google.com>
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 7b4fb14..4ebe615 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -941,6 +941,8 @@
     virtual     void        threadLoop_exit();
     virtual     bool        shouldStandby_l();
 
+    virtual     void        onAddNewTrack_l();
+
     // volumes last sent to audio HAL with stream->set_volume()
     float mLeftVolFloat;
     float mRightVolFloat;
@@ -952,6 +954,9 @@
 
     // prepareTracks_l() tells threadLoop_mix() the name of the single active track
     sp<Track>               mActiveTrack;
+
+    wp<Track>               mPreviousTrack;         // used to detect track switch
+
 public:
     virtual     bool        hasFastMixer() const { return false; }
 };
@@ -971,12 +976,10 @@
 
     virtual     bool        waitingAsyncCallback();
     virtual     bool        waitingAsyncCallback_l();
-    virtual     void        onAddNewTrack_l();
 
 private:
     size_t      mPausedWriteLength;     // length in bytes of write interrupted by pause
     size_t      mPausedBytesRemaining;  // bytes still waiting in mixbuffer after resume
-    wp<Track>   mPreviousTrack;         // used to detect track switch
 };
 
 class AsyncCallbackThread : public Thread {