aaudio: fix intermittent hang and position error
Fix hang caused by recursive mutex.
Fix disconnect caused by getPosition() failing, which was
just because the stream wasn't ready yet.
Bug: 63775537
Bug: 63709749
Test: run "aaudio_loopback -pl -Pl -c2 -n6 -te -m" many times
Change-Id: Ic1d54360b55cfc8ecc1809584c262bc0976c58bb
diff --git a/services/oboeservice/AAudioServiceEndpoint.h b/services/oboeservice/AAudioServiceEndpoint.h
index ed995e5..e40a670 100644
--- a/services/oboeservice/AAudioServiceEndpoint.h
+++ b/services/oboeservice/AAudioServiceEndpoint.h
@@ -73,13 +73,13 @@
virtual AudioStreamInternal *getStreamInternal() = 0;
- std::atomic<bool> mCallbackEnabled;
+ std::atomic<bool> mCallbackEnabled{false};
mutable std::mutex mLockStreams;
std::vector<android::sp<AAudioServiceStreamShared>> mRegisteredStreams;
- size_t mRunningStreams = 0;
+ std::atomic<int> mRunningStreams{0};
private:
aaudio_result_t startSharingThread_l();