summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2024-02-20 10:56:37 -0800
committerAndy Hung <hunga@google.com>2024-02-23 19:44:22 -0800
commit8d1b41f8a1c1896890527b6c2bb8bcb3a610ac28 (patch)
treea5c2e989aa99eb79582d163e455eb737bc5901d4
parent177886c9fe9efc27fb9d84eda3f505b377644d79 (diff)
downloadav-8d1b41f8a1c1896890527b6c2bb8bcb3a610ac28.tar.gz
AudioRecord: Fix capture timestamp after standby
Fix AudioStreamIn getCapturePosition handling since it is also used for linear PCM. Test: atest AudioRecordTest Bug: 308526758 Merged-In: Ia07e1ef0b15e7dace1dca882e7ab75df09706c9c Change-Id: Ia07e1ef0b15e7dace1dca882e7ab75df09706c9c
-rw-r--r--services/audioflinger/datapath/AudioStreamIn.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/services/audioflinger/datapath/AudioStreamIn.cpp b/services/audioflinger/datapath/AudioStreamIn.cpp
index 24f3bb9671..76618f44b9 100644
--- a/services/audioflinger/datapath/AudioStreamIn.cpp
+++ b/services/audioflinger/datapath/AudioStreamIn.cpp
@@ -56,15 +56,15 @@ status_t AudioStreamIn::getCapturePosition(int64_t* frames, int64_t* time)
return status;
}
- // Adjust for standby using HAL rate frames.
- // Only apply this correction if the HAL is getting PCM frames.
- if (mHalFormatHasProportionalFrames) {
+ if (mHalFormatHasProportionalFrames &&
+ (flags & AUDIO_INPUT_FLAG_DIRECT) == AUDIO_INPUT_FLAG_DIRECT) {
+ // For DirectRecord reset timestamp to 0 on standby.
const uint64_t adjustedPosition = (halPosition <= mFramesReadAtStandby) ?
0 : (halPosition - mFramesReadAtStandby);
// Scale from HAL sample rate to application rate.
*frames = adjustedPosition / mRateMultiplier;
} else {
- // For compressed formats.
+ // For compressed formats and linear PCM.
*frames = halPosition;
}