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

Commit 1a0d1670 authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "Optionally have SurfaceMediaSource return absolute timestamps" into jb-mr1-dev

parents 0cb47712 0868deae
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -116,6 +116,9 @@ public:
    // To be called before start()
    // To be called before start()
    status_t setMaxAcquiredBufferCount(size_t count);
    status_t setMaxAcquiredBufferCount(size_t count);


    // To be called before start()
    status_t setUseAbsoluteTimestamps();

protected:
protected:


    // Implementation of the BufferQueue::ConsumerListener interface.  These
    // Implementation of the BufferQueue::ConsumerListener interface.  These
@@ -212,6 +215,8 @@ private:


    size_t mMaxAcquiredBufferCount;
    size_t mMaxAcquiredBufferCount;


    bool mUseAbsoluteTimestamps;

    // mFrameAvailableCondition condition used to indicate whether there
    // mFrameAvailableCondition condition used to indicate whether there
    // is a frame available for dequeuing
    // is a frame available for dequeuing
    Condition mFrameAvailableCondition;
    Condition mFrameAvailableCondition;
+10 −3
Original line number Original line Diff line number Diff line
@@ -46,8 +46,8 @@ SurfaceMediaSource::SurfaceMediaSource(uint32_t bufferWidth, uint32_t bufferHeig
    mNumFramesReceived(0),
    mNumFramesReceived(0),
    mNumFramesEncoded(0),
    mNumFramesEncoded(0),
    mFirstFrameTimestamp(0),
    mFirstFrameTimestamp(0),
    mMaxAcquiredBufferCount(4)  // XXX double-check the default
    mMaxAcquiredBufferCount(4),  // XXX double-check the default
{
    mUseAbsoluteTimestamps(false) {
    ALOGV("SurfaceMediaSource");
    ALOGV("SurfaceMediaSource");


    if (bufferWidth == 0 || bufferHeight == 0) {
    if (bufferWidth == 0 || bufferHeight == 0) {
@@ -188,6 +188,13 @@ status_t SurfaceMediaSource::setMaxAcquiredBufferCount(size_t count) {
    return OK;
    return OK;
}
}


status_t SurfaceMediaSource::setUseAbsoluteTimestamps() {
    ALOGV("setUseAbsoluteTimestamps");
    Mutex::Autolock lock(mMutex);
    mUseAbsoluteTimestamps = true;

    return OK;
}


status_t SurfaceMediaSource::stop()
status_t SurfaceMediaSource::stop()
{
{
@@ -298,7 +305,7 @@ status_t SurfaceMediaSource::read( MediaBuffer **buffer,
            }
            }


            // check for the timing of this buffer
            // check for the timing of this buffer
            if (mNumFramesReceived == 0) {
            if (mNumFramesReceived == 0 && !mUseAbsoluteTimestamps) {
                mFirstFrameTimestamp = item.mTimestamp;
                mFirstFrameTimestamp = item.mTimestamp;
                // Initial delay
                // Initial delay
                if (mStartTimeNs > 0) {
                if (mStartTimeNs > 0) {