audioflinger: fix duplicating track start with a2dp output suspended
When the output stream is suspended, we must not wait for the HAL
to exist standby or the kernel position to start moving as this never
happens.
Bug: 281952473
Bug: 218803475
Test: repro steps in bug
Change-Id: I6c4f5d6b4c6a598d21f49e43468dc174571b960a
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 293117f..84b70c6 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -4110,8 +4110,9 @@
// signal actual start of output stream when the render position reported by the kernel
// starts moving.
- if (!mStandby && !mHalStarted && mKernelPositionOnStandby !=
- mTimestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL]) {
+ if (!mHalStarted && ((isSuspended() && (mBytesWritten != 0)) || (!mStandby
+ && (mKernelPositionOnStandby
+ != mTimestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL])))) {
mHalStarted = true;
mWaitHalStartCV.broadcast();
}