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

Commit b99be946 authored by Andy Hung's avatar Andy Hung Committed by android-build-merger
Browse files

Merge "AudioTimestamp: Use current time when data pipeline is empty" into qt-dev

am: d9626301

Change-Id: I384bb424ff1af793250a6250baf64b6c644c8336
parents 756195ce d9626301
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.