summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-14 00:59:07 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-14 00:59:07 +0000
commitfa34315231b6fa66593a9d2165bcc14751c2b5d2 (patch)
tree0b7f31129ab3cbef683431324b24a9ab8130f955
parente5fca2f4863f5554f43b31c811547c0dc2d55b96 (diff)
parentcc2165840d524bb9553f9d73d1904633d20100a2 (diff)
Merge cherrypicks of [15567411, 15567547, 15567447, 15567095, 15567367, 15566999, 15567396, 15567397, 15567412, 15567413, 15567096, 15567448, 15567449, 15567097, 15567098, 15567450, 15567099, 15567398, 15567100, 15567621, 15567622, 15567468, 15567000] into rvc-qpr3-release
Change-Id: I6db9d7b6aa517253316793f5798147c29a19af02
-rw-r--r--services/oboeservice/AAudioServiceStreamBase.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/services/oboeservice/AAudioServiceStreamBase.cpp b/services/oboeservice/AAudioServiceStreamBase.cpp
index 663dae29cc..30deb5df9c 100644
--- a/services/oboeservice/AAudioServiceStreamBase.cpp
+++ b/services/oboeservice/AAudioServiceStreamBase.cpp
@@ -293,10 +293,6 @@ aaudio_result_t AAudioServiceStreamBase::pause_l() {
.set(AMEDIAMETRICS_PROP_STATUS, (int32_t)result)
.record(); });
- // Send it now because the timestamp gets rounded up when stopStream() is called below.
- // Also we don't need the timestamps while we are shutting down.
- sendCurrentTimestamp();
-
result = stopTimestampThread();
if (result != AAUDIO_OK) {
disconnect_l();
@@ -342,10 +338,12 @@ aaudio_result_t AAudioServiceStreamBase::stop_l() {
setState(AAUDIO_STREAM_STATE_STOPPING);
- // Send it now because the timestamp gets rounded up when stopStream() is called below.
- // Also we don't need the timestamps while we are shutting down.
- sendCurrentTimestamp(); // warning - this calls a virtual function
+ // Temporarily unlock because we are joining the timestamp thread and it may try
+ // to acquire mLock.
+ mLock.unlock();
result = stopTimestampThread();
+ mLock.lock();
+
if (result != AAUDIO_OK) {
disconnect_l();
return result;
@@ -410,10 +408,11 @@ void AAudioServiceStreamBase::run() {
timestampScheduler.start(AudioClock::getNanoseconds());
int64_t nextTime = timestampScheduler.nextAbsoluteTime();
int32_t loopCount = 0;
+ aaudio_result_t result = AAUDIO_OK;
while(mThreadEnabled.load()) {
loopCount++;
if (AudioClock::getNanoseconds() >= nextTime) {
- aaudio_result_t result = sendCurrentTimestamp();
+ result = sendCurrentTimestamp();
if (result != AAUDIO_OK) {
ALOGE("%s() timestamp thread got result = %d", __func__, result);
break;
@@ -425,6 +424,11 @@ void AAudioServiceStreamBase::run() {
AudioClock::sleepUntilNanoTime(nextTime);
}
}
+ // This was moved from the calls in stop_l() and pause_l(), which could cause a deadlock
+ // if it resulted in a call to disconnect.
+ if (result == AAUDIO_OK) {
+ (void) sendCurrentTimestamp();
+ }
ALOGD("%s() %s exiting after %d loops <<<<<<<<<<<<<< TIMESTAMPS",
__func__, getTypeText(), loopCount);
}