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

Commit a53ffa67 authored by Phil Burk's avatar Phil Burk
Browse files

aaudio: rename timestamp variables

There were several different timestamp variables with slightly
different meaning but with the same name.
That made it hard to debug the code.

Test: atest CtsNativeMediaAAudioTestCases
Change-Id: Iebf438676925c698377abe02c81f3d559829318a
parent 9f81192d
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ AudioStreamInternal::AudioStreamInternal(AAudioServiceInterface &serviceInterfa
        , mServiceStreamHandle(AAUDIO_HANDLE_INVALID)
        , mInService(inService)
        , mServiceInterface(serviceInterface)
        , mAtomicTimestamp()
        , mAtomicInternalTimestamp()
        , mWakeupDelayNanos(AAudioProperty_getWakeupDelayMicros() * AAUDIO_NANOS_PER_MICROSECOND)
        , mMinimumSleepNanos(AAudioProperty_getMinimumSleepMicros() * AAUDIO_NANOS_PER_MICROSECOND)
        {
@@ -363,7 +363,7 @@ aaudio_result_t AudioStreamInternal::requestStop() {

    mClockModel.stop(AudioClock::getNanoseconds());
    setState(AAUDIO_STREAM_STATE_STOPPING);
    mAtomicTimestamp.clear();
    mAtomicInternalTimestamp.clear();

    return mServiceInterface.stopStream(mServiceStreamHandle);
}
@@ -412,8 +412,8 @@ aaudio_result_t AudioStreamInternal::getTimestamp(clockid_t clockId,
                           int64_t *framePosition,
                           int64_t *timeNanoseconds) {
    // Generated in server and passed to client. Return latest.
    if (mAtomicTimestamp.isValid()) {
        Timestamp timestamp = mAtomicTimestamp.read();
    if (mAtomicInternalTimestamp.isValid()) {
        Timestamp timestamp = mAtomicInternalTimestamp.read();
        int64_t position = timestamp.getPosition() + mFramesOffsetFromService;
        if (position >= 0) {
            *framePosition = position;
@@ -460,7 +460,7 @@ aaudio_result_t AudioStreamInternal::onTimestampService(AAudioServiceMessage *me

aaudio_result_t AudioStreamInternal::onTimestampHardware(AAudioServiceMessage *message) {
    Timestamp timestamp(message->timestamp.position, message->timestamp.timestamp);
    mAtomicTimestamp.write(timestamp);
    mAtomicInternalTimestamp.write(timestamp);
    return AAUDIO_OK;
}

+1 −1
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ protected:

    AAudioServiceInterface  &mServiceInterface;   // abstract interface to the service

    SimpleDoubleBuffer<Timestamp>  mAtomicTimestamp;
    SimpleDoubleBuffer<Timestamp>  mAtomicInternalTimestamp;

    AtomicRequestor          mNeedCatchUp;   // Ask read() or write() to sync on first timestamp.

+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ aaudio_result_t AudioStreamInternalPlay::requestPause()

    mClockModel.stop(AudioClock::getNanoseconds());
    setState(AAUDIO_STREAM_STATE_PAUSING);
    mAtomicTimestamp.clear();
    mAtomicInternalTimestamp.clear();
    return mServiceInterface.pauseStream(mServiceStreamHandle);
}

+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ protected:
    mutable std::mutex       mLockStreams;
    std::vector<android::sp<AAudioServiceStreamBase>> mRegisteredStreams;

    SimpleDoubleBuffer<Timestamp>  mAtomicTimestamp;
    SimpleDoubleBuffer<Timestamp>  mAtomicEndpointTimestamp;

    android::AudioClient     mMmapClient;   // set in open, used in open and startStream

+2 −2
Original line number Diff line number Diff line
@@ -181,8 +181,8 @@ aaudio_result_t AAudioServiceEndpointShared::stopStream(sp<AAudioServiceStreamBa
// Get timestamp that was written by the real-time service thread, eg. mixer.
aaudio_result_t AAudioServiceEndpointShared::getFreeRunningPosition(int64_t *positionFrames,
                                                                  int64_t *timeNanos) {
    if (mAtomicTimestamp.isValid()) {
        Timestamp timestamp = mAtomicTimestamp.read();
    if (mAtomicEndpointTimestamp.isValid()) {
        Timestamp timestamp = mAtomicEndpointTimestamp.read();
        *positionFrames = timestamp.getPosition();
        *timeNanos = timestamp.getNanoseconds();
        return AAUDIO_OK;
Loading