PassthruPatchRecord: fix null timeOut case in obtainBuffer
Properly handle 'timeOut == nullptr' case in
PassthruPatchRecord::obtainBuffer.
Bug: 117564323
Test: make
Merged-In: Id352e47682c0992b817f26b3b594ec5913e663be
Change-Id: Id352e47682c0992b817f26b3b594ec5913e663be
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 932c32b..7c53ca0 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -2414,7 +2414,6 @@
if (!stream) return NO_INIT; // If there is no stream, RecordThread is not reading.
status_t result = NO_ERROR;
- struct timespec newTimeOut = *timeOut;
size_t bytesRead = 0;
{
ATRACE_NAME("read");
@@ -2437,15 +2436,16 @@
ALOGW_IF(buffer->mFrameCount < bytesRead / mFrameSize,
"Lost %zu frames obtained from HAL", bytesRead / mFrameSize - buffer->mFrameCount);
mUnconsumedFrames = buffer->mFrameCount;
- // Correct newTimeOut by elapsed time.
+ struct timespec newTimeOut;
if (startTimeNs) {
- nsecs_t newTimeOutNs =
- audio_utils_ns_from_timespec(&newTimeOut) - (systemTime() - startTimeNs);
+ // Correct the timeout by elapsed time.
+ nsecs_t newTimeOutNs = audio_utils_ns_from_timespec(timeOut) - (systemTime() - startTimeNs);
if (newTimeOutNs < 0) newTimeOutNs = 0;
newTimeOut.tv_sec = newTimeOutNs / NANOS_PER_SECOND;
newTimeOut.tv_nsec = newTimeOutNs - newTimeOut.tv_sec * NANOS_PER_SECOND;
+ timeOut = &newTimeOut;
}
- return PatchRecord::obtainBuffer(buffer, &newTimeOut);
+ return PatchRecord::obtainBuffer(buffer, timeOut);
stream_error:
stream->standby();