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

Commit 818e7a32 authored by Andy Hung's avatar Andy Hung
Browse files

Implement server side playback timestamps with 64 bit accuracy

Provide server timestamps if the HAL doesn't provide it.
Provide monotonic - boottime translation.
Integrate record timestamps and playback timestamps together.

Bug: 17472992
Bug: 22871200
Bug: 26400089
Bug: 26682703
Change-Id: If1974f94232fcce7ba0bbcdf63d9e54ed51918ff
parent 6ae5843c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -27,11 +27,11 @@ public:
    virtual size_t  framesReady() const = 0;  // see description at AudioFlinger.h

    // Return the total number of frames that have been obtained and released
    virtual size_t  framesReleased() const { return 0; }
    virtual int64_t  framesReleased() const { return 0; }

    // Invoked by buffer consumer when a new timestamp is available.
    // Default implementation ignores the timestamp.
    virtual void    onTimestamp(const AudioTimestamp& timestamp) { }
    virtual void    onTimestamp(const ExtendedTimestamp& timestamp) { }
};

}   // namespace android
+4 −4
Original line number Diff line number Diff line
@@ -38,8 +38,8 @@ public:
    // NBAIO_Sink interface

    //virtual size_t framesRead() const;
    virtual size_t framesOverrun();
    virtual size_t overruns() { (void) framesOverrun(); return mOverruns; }
    virtual int64_t framesOverrun();
    virtual int64_t overruns() { (void) framesOverrun(); return mOverruns; }

    // This is an over-estimate, and could dupe the caller into making a blocking read()
    // FIXME Use an audio HAL API to query the buffer filling status when it's available.
@@ -56,8 +56,8 @@ public:
private:
    audio_stream_in * const mStream;
    size_t              mStreamBufferSizeBytes; // as reported by get_buffer_size()
    size_t              mFramesOverrun;
    size_t              mOverruns;
    int64_t             mFramesOverrun;
    int64_t             mOverruns;
};

}   // namespace android
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public:

    virtual ssize_t write(const void *buffer, size_t count);

    virtual status_t getTimestamp(AudioTimestamp& timestamp);
    virtual status_t getTimestamp(ExtendedTimestamp &timestamp);

    // NBAIO_Sink end

+8 −8
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@

namespace android {

typedef SingleStateQueue<AudioTimestamp> AudioTimestampSingleStateQueue;
typedef SingleStateQueue<ExtendedTimestamp> ExtendedTimestampSingleStateQueue;

// MonoPipe is similar to Pipe except:
//  - supports only a single reader, called MonoPipeReader
@@ -51,9 +51,9 @@ public:

    // NBAIO_Sink interface

    //virtual size_t framesWritten() const;
    //virtual size_t framesUnderrun() const;
    //virtual size_t underruns() const;
    //virtual int64_t framesWritten() const;
    //virtual int64_t framesUnderrun() const;
    //virtual int64_t underruns() const;

    virtual ssize_t availableToWrite() const;
    virtual ssize_t write(const void *buffer, size_t count);
@@ -77,7 +77,7 @@ public:
            bool    isShutdown();

            // Return NO_ERROR if there is a timestamp available
            status_t getTimestamp(AudioTimestamp& timestamp);
            status_t getTimestamp(ExtendedTimestamp &timestamp);

private:
    const size_t    mReqFrames;     // as requested in constructor, unrounded
@@ -97,9 +97,9 @@ private:

    bool            mIsShutdown;    // whether shutdown(true) was called, no barriers are needed

    AudioTimestampSingleStateQueue::Shared      mTimestampShared;
    AudioTimestampSingleStateQueue::Mutator     mTimestampMutator;
    AudioTimestampSingleStateQueue::Observer    mTimestampObserver;
    ExtendedTimestampSingleStateQueue::Shared      mTimestampShared;
    ExtendedTimestampSingleStateQueue::Mutator     mTimestampMutator;
    ExtendedTimestampSingleStateQueue::Observer    mTimestampObserver;
};

}   // namespace android
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public:

    virtual ssize_t read(void *buffer, size_t count);

    virtual void    onTimestamp(const AudioTimestamp& timestamp);
    virtual void    onTimestamp(const ExtendedTimestamp &timestamp);

    // NBAIO_Source end

Loading