summaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2021-03-15 19:01:51 -0700
committerAndy Hung <hunga@google.com>2021-03-17 10:45:07 -0700
commitdaa60c22d6666980ef563aeac454dd32b9034f8f (patch)
tree1bdae63fcce9f39d969f3089da2a33df7a511ba7 /media
parentc4b72cd7efb0ea7a5454c80b2e303ccb8ebba053 (diff)
SoundPool: Avoid busy waiting during stream restart
A stream on the restart queue can cause the StreamManager to busy-wait. This was introduced by a fix commit ba04dbe7732bc2d016bf81c81bd349d931de63f2. Test: Verbose log on StreamManager.cpp, run SoundPool CTS tests. Bug: 182923919 Merged-In: Iae794bc957869426a4e1e27cd3c088aa9dd83208 Change-Id: Iae794bc957869426a4e1e27cd3c088aa9dd83208
Diffstat (limited to 'media')
-rw-r--r--media/jni/soundpool/StreamManager.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/media/jni/soundpool/StreamManager.cpp b/media/jni/soundpool/StreamManager.cpp
index 49c2b39f8904..309d71cfd062 100644
--- a/media/jni/soundpool/StreamManager.cpp
+++ b/media/jni/soundpool/StreamManager.cpp
@@ -358,14 +358,14 @@ void StreamManager::addToActiveQueue_l(Stream *stream) {
void StreamManager::run(int32_t id)
{
ALOGV("%s(%d) entering", __func__, id);
- int64_t waitTimeNs = kWaitTimeBeforeCloseNs;
+ int64_t waitTimeNs = 0; // on thread start, mRestartStreams can be non-empty.
std::unique_lock lock(mStreamManagerLock);
while (!mQuit) {
- if (mRestartStreams.empty()) { // on thread start, mRestartStreams can be non-empty.
+ if (waitTimeNs > 0) {
mStreamManagerCondition.wait_for(
lock, std::chrono::duration<int64_t, std::nano>(waitTimeNs));
}
- ALOGV("%s(%d) awake", __func__, id);
+ ALOGV("%s(%d) awake lock waitTimeNs:%lld", __func__, id, (long long)waitTimeNs);
sanityCheckQueue_l();