audioflinger: fix lost offload thread resume event
It was possible that a resume request signaled by addTrack_l()
while waiting for an async write callback is lost. This is because
mSignalPending was not set and waitingAsyncCallback_l() would pause the
thread loop before executing prepareTracks_l().
The fix consists in using signal_l() method to wake the thread
loop o that mSignalPending is set.
Also make sure that sleepTime is reset to 0 when resuming to make sure
that we write any remaining bytes to the HAL.
Bug: 10810347.
Change-Id: If9a3b22cc3b9e6eb384a56c48c40e6258d0896ad
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 3fe470c..b3d88e3 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -526,7 +526,7 @@
status_t addTrack_l(const sp<Track>& track);
bool destroyTrack_l(const sp<Track>& track);
void removeTrack_l(const sp<Track>& track);
- void signal_l();
+ void broadcast_l();
void readOutputParameters();
@@ -590,6 +590,8 @@
// Bit 0 is reset by the async callback thread calling resetDraining(). Out of sequence
// callbacks are ignored.
uint32_t mDrainSequence;
+ // A condition that must be evaluated by prepareTrack_l() has changed and we must not wait
+ // for async write callback in the thread loop before evaluating it
bool mSignalPending;
sp<AsyncCallbackThread> mCallbackThread;