From c1cd92cf9ec76c843460b7697028d0e9495b22d4 Mon Sep 17 00:00:00 2001 From: Shunkai Yao Date: Tue, 22 Aug 2023 20:46:34 +0000 Subject: [PATCH] r_submix: keep the signed value for offset calculation in AIDL implementation otherwise a negative offset will result in long sleep Bug: 295055755 Test: atest android.media.audio.cts.AudioPlaybackCaptureTest Change-Id: Ie941cc2525e3ea42b53106ae3a65242794b1dd1b Merged-In: Ie941cc2525e3ea42b53106ae3a65242794b1dd1b --- audio/aidl/default/r_submix/StreamRemoteSubmix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp b/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp index 11838f8d95..3134b86841 100644 --- a/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp +++ b/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp @@ -348,9 +348,9 @@ size_t StreamRemoteSubmix::getStreamPipeSizeInFrames() { // recording (including this call): it's converted to usec and compared to how long we've been // recording for, which gives us how long we must wait to sync the projected recording time, and // the observed recording time. - const size_t projectedVsObservedOffsetUs = static_cast( + const int projectedVsObservedOffsetUs = std::roundf((readCounterFrames * MICROS_PER_SECOND / mStreamConfig.sampleRate) - - recordDurationUs.count())); + recordDurationUs.count()); LOG(VERBOSE) << __func__ << ": record duration " << recordDurationUs.count() << " microseconds, will wait: " << projectedVsObservedOffsetUs << " microseconds";