Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98731a2c authored by Andy Hung's avatar Andy Hung
Browse files

AudioTimestamp: Use current time when data pipeline is empty

Handles change in Q, where we do not return an invalid kernel time
in the extended timestamp when there is a reported error from the HAL.

Test: Photos, File playback, AudioTrackSurroundTest#testPlaySineSweepBytes
Bug: 113294730
Bug: 118506063
Bug: 119895849
Bug: 120631792
Change-Id: I90f2c7c314baa474c3dd3a24042f1d4b8bc0a12b
parent 0e5a1b3b
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -2603,6 +2603,20 @@ status_t AudioTrack::getTimestamp_l(AudioTimestamp& timestamp)
                    ALOGV_IF(mPreviousLocation == ExtendedTimestamp::LOCATION_SERVER,
                            "%s(%d): location moved from server to kernel",
                            __func__, mPortId);

                    if (ets.mPosition[ExtendedTimestamp::LOCATION_SERVER] ==
                            ets.mPosition[ExtendedTimestamp::LOCATION_KERNEL]) {
                        // In Q, we don't return errors as an invalid time
                        // but instead we leave the last kernel good timestamp alone.
                        //
                        // If server is identical to kernel, the device data pipeline is idle.
                        // A better start time is now.  The retrograde check ensures
                        // timestamp monotonicity.
                        const int64_t nowNs = systemTime();
                        ALOGD("%s(%d) device stall, using current time %lld",
                                __func__, mPortId, (long long)nowNs);
                        timestamp.mTime = convertNsToTimespec(nowNs);
                    }
                }

                // We update the timestamp time even when paused.