Skip to content

Commit 1fbe7a8

Browse files
Eric LaurentAndroid (Google) Code Review
authored andcommitted
Merge "Issue 4345021: Audio routed to multiple devices..."
2 parents 18b4311 + 5f37be3 commit 1fbe7a8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

services/audioflinger/AudioFlinger.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ static const nsecs_t kWarningThrottle = seconds(5);
8787
// RecordThread loop sleep time upon application overrun or audio HAL read error
8888
static const int kRecordThreadSleepUs = 5000;
8989

90+
static const nsecs_t kSetParametersTimeout = seconds(2);
91+
9092
// ----------------------------------------------------------------------------
9193

9294
static bool recordingAllowed() {
@@ -1032,7 +1034,7 @@ status_t AudioFlinger::ThreadBase::setParameters(const String8& keyValuePairs)
10321034
mWaitWorkCV.signal();
10331035
// wait condition with timeout in case the thread loop has exited
10341036
// before the request could be processed
1035-
if (mParamCond.waitRelative(mLock, seconds(2)) == NO_ERROR) {
1037+
if (mParamCond.waitRelative(mLock, kSetParametersTimeout) == NO_ERROR) {
10361038
status = mParamStatus;
10371039
mWaitWorkCV.signal();
10381040
} else {
@@ -2349,7 +2351,9 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l()
23492351

23502352
mParamStatus = status;
23512353
mParamCond.signal();
2352-
mWaitWorkCV.wait(mLock);
2354+
// wait for condition with time out in case the thread calling ThreadBase::setParameters()
2355+
// already timed out waiting for the status and will never signal the condition.
2356+
mWaitWorkCV.waitRelative(mLock, kSetParametersTimeout);
23532357
}
23542358
return reconfig;
23552359
}
@@ -2828,7 +2832,9 @@ bool AudioFlinger::DirectOutputThread::checkForNewParameters_l()
28282832

28292833
mParamStatus = status;
28302834
mParamCond.signal();
2831-
mWaitWorkCV.wait(mLock);
2835+
// wait for condition with time out in case the thread calling ThreadBase::setParameters()
2836+
// already timed out waiting for the status and will never signal the condition.
2837+
mWaitWorkCV.waitRelative(mLock, kSetParametersTimeout);
28322838
}
28332839
return reconfig;
28342840
}
@@ -4669,7 +4675,9 @@ bool AudioFlinger::RecordThread::checkForNewParameters_l()
46694675

46704676
mParamStatus = status;
46714677
mParamCond.signal();
4672-
mWaitWorkCV.wait(mLock);
4678+
// wait for condition with time out in case the thread calling ThreadBase::setParameters()
4679+
// already timed out waiting for the status and will never signal the condition.
4680+
mWaitWorkCV.waitRelative(mLock, kSetParametersTimeout);
46734681
}
46744682
return reconfig;
46754683
}

0 commit comments

Comments
 (0)