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
diff --git a/services/audioflinger/datapath/AudioStreamIn.cpp b/services/audioflinger/datapath/AudioStreamIn.cpp
index 24f3bb9..76618f4 100644
--- a/services/audioflinger/datapath/AudioStreamIn.cpp
+++ b/services/audioflinger/datapath/AudioStreamIn.cpp
@@ -56,15 +56,15 @@
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;
}