Merge "AudioRecord: Fix capture timestamp after standby" into main am: 0c5d37c0fd
Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/2975756
Change-Id: Ie7f5c9f349f8279016308a3ac63b9d6333f6cb0a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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;
}