OSDN Git Service

Fix flush() followed by start()
authorGlenn Kasten <gkasten@google.com>
Thu, 17 Oct 2013 18:32:39 +0000 (11:32 -0700)
committerGlenn Kasten <gkasten@google.com>
Thu, 17 Oct 2013 18:33:31 +0000 (11:33 -0700)
Bug: 11259166
Change-Id: I72526cdfd4e3ff4b06e6a317e577f57cc285205d

services/audioflinger/Tracks.cpp

index 9c6e724..e93833f 100644 (file)
@@ -600,6 +600,15 @@ status_t AudioFlinger::PlaybackThread::Track::start(AudioSystem::sync_event_t ev
         // track was already in the active list, not a problem
         if (status == ALREADY_EXISTS) {
             status = NO_ERROR;
+        } else {
+            // Acknowledge any pending flush(), so that subsequent new data isn't discarded.
+            // It is usually unsafe to access the server proxy from a binder thread.
+            // But in this case we know the mixer thread (whether normal mixer or fast mixer)
+            // isn't looking at this track yet:  we still hold the normal mixer thread lock,
+            // and for fast tracks the track is not yet in the fast mixer thread's active set.
+            ServerProxy::Buffer buffer;
+            buffer.mFrameCount = 1;
+            (void) mAudioTrackServerProxy->obtainBuffer(&buffer);
         }
     } else {
         status = BAD_VALUE;