diff options
| author | Lajos Molnar <lajos@google.com> | 2015-07-20 16:24:31 -0700 | 
|---|---|---|
| committer | Lajos Molnar <lajos@google.com> | 2015-07-20 16:49:26 -0700 | 
| commit | 82a633b602a7ffe1efd9886744393f52a093a2f3 (patch) | |
| tree | 94b8f5d5f3729c73371ea8a82a6358ea6aa9d6ff | |
| parent | 84e4987ffc8d4bb6731bcb28d69a7ff37a0e9921 (diff) | |
| download | frameworks_av-82a633b602a7ffe1efd9886744393f52a093a2f3.zip frameworks_av-82a633b602a7ffe1efd9886744393f52a093a2f3.tar.gz frameworks_av-82a633b602a7ffe1efd9886744393f52a093a2f3.tar.bz2  | |
stagefright: remove workaround for BQ not reporting dropped frames
Bug: 22234976
Related-bug: 22552826
Change-Id: Ic29b8d8533a4df8c15bcf3a9dab924aa24428304
| -rw-r--r-- | include/media/stagefright/MediaSync.h | 8 | ||||
| -rw-r--r-- | media/libstagefright/MediaSync.cpp | 71 | 
2 files changed, 29 insertions, 50 deletions
diff --git a/include/media/stagefright/MediaSync.h b/include/media/stagefright/MediaSync.h index 4b5cd05..ef8cb23 100644 --- a/include/media/stagefright/MediaSync.h +++ b/include/media/stagefright/MediaSync.h @@ -135,8 +135,7 @@ protected:  private:      enum { -        kWhatDrainVideo          = 'dVid', -        kWhatCheckFrameAvailable = 'cFrA', +        kWhatDrainVideo = 'dVid',      };      // This is a thin wrapper class that lets us listen to @@ -248,9 +247,8 @@ private:      // onBufferReleasedByOutput releases a buffer back to the input.      void onFrameAvailableFromInput(); -    // Send |bufferItem| to the output for rendering. If this is not the only -    // buffer sent for rendering, check for any dropped frames in |checkInUs| us. -    void renderOneBufferItem_l(const BufferItem &bufferItem, int64_t checkInUs); +    // Send |bufferItem| to the output for rendering. +    void renderOneBufferItem_l(const BufferItem &bufferItem);      // This implements the onBufferReleased callback from IProducerListener.      // It gets called from an OutputListener. diff --git a/media/libstagefright/MediaSync.cpp b/media/libstagefright/MediaSync.cpp index 0df3ec9..3a45e25 100644 --- a/media/libstagefright/MediaSync.cpp +++ b/media/libstagefright/MediaSync.cpp @@ -558,8 +558,7 @@ void MediaSync::onDrainVideo_l() {          // adjust video frame PTS based on vsync          itemRealUs = mFrameScheduler->schedule(itemRealUs * 1000) / 1000; -        int64_t oneVsyncUs = (mFrameScheduler->getVsyncPeriod() / 1000); -        int64_t twoVsyncsUs = oneVsyncUs * 2; +        int64_t twoVsyncsUs = 2 * (mFrameScheduler->getVsyncPeriod() / 1000);          // post 2 display refreshes before rendering is due          if (itemRealUs <= nowUs + twoVsyncsUs) { @@ -570,7 +569,7 @@ void MediaSync::onDrainVideo_l() {              if (mHasAudio) {                  if (nowUs - itemRealUs <= kMaxAllowedVideoLateTimeUs) { -                    renderOneBufferItem_l(*bufferItem, nowUs + oneVsyncUs - itemRealUs); +                    renderOneBufferItem_l(*bufferItem);                  } else {                      // too late.                      returnBufferToInput_l( @@ -579,7 +578,7 @@ void MediaSync::onDrainVideo_l() {                  }              } else {                  // always render video buffer in video-only mode. -                renderOneBufferItem_l(*bufferItem, nowUs + oneVsyncUs - itemRealUs); +                renderOneBufferItem_l(*bufferItem);                  // smooth out videos >= 10fps                  mMediaClock->updateAnchor( @@ -613,7 +612,7 @@ void MediaSync::onFrameAvailableFromInput() {      while (mNumOutstandingBuffers > mMaxAcquiredBufferCount              && !mIsAbandoned && !mReturnPendingInputFrame) {          if (mReleaseCondition.waitRelative(mMutex, kAcquireWaitTimeout) != OK) { -            ALOGI("still waiting to release a buffer before acquire"); +            ALOGI_IF(mPlaybackRate != 0.f, "still waiting to release a buffer before acquire");          }          // If the sync is abandoned while we are waiting, the release @@ -670,7 +669,7 @@ void MediaSync::onFrameAvailableFromInput() {      }  } -void MediaSync::renderOneBufferItem_l(const BufferItem &bufferItem, int64_t checkInUs) { +void MediaSync::renderOneBufferItem_l(const BufferItem &bufferItem) {      IGraphicBufferProducer::QueueBufferInput queueInput(              bufferItem.mTimestamp,              bufferItem.mIsAutoTimestamp, @@ -710,12 +709,6 @@ void MediaSync::renderOneBufferItem_l(const BufferItem &bufferItem, int64_t chec      mBuffersSentToOutput.add(bufferItem.mGraphicBuffer->getId(), bufferItem.mGraphicBuffer);      ALOGV("queued buffer %#llx to output", (long long)bufferItem.mGraphicBuffer->getId()); - -    // If we have already queued more than one buffer, check for any free buffers in case -    // one of them were dropped - as BQ does not signal onBufferReleased in that case. -    if (mBuffersSentToOutput.size() > 1) { -        (new AMessage(kWhatCheckFrameAvailable, this))->post(checkInUs); -    }  }  void MediaSync::onBufferReleasedByOutput(sp<IGraphicBufferProducer> &output) { @@ -727,38 +720,32 @@ void MediaSync::onBufferReleasedByOutput(sp<IGraphicBufferProducer> &output) {      sp<GraphicBuffer> buffer;      sp<Fence> fence; -    status_t status; -    // NOTE: This is a workaround for a BufferQueue bug where onBufferReleased is -    // called only for released buffers, but not for buffers that were dropped during -    // acquire. Dropped buffers can still be detached as they are on the free list. -    // TODO: remove if released callback happens also for dropped buffers -    while ((status = mOutput->detachNextBuffer(&buffer, &fence)) != NO_MEMORY) { -        ALOGE_IF(status != NO_ERROR, "detaching buffer from output failed (%d)", status); - -        if (status == NO_INIT) { -            // If the output has been abandoned, we can't do anything else, -            // since buffer is invalid. -            onAbandoned_l(false /* isInput */); -            return; -        } +    status_t status = mOutput->detachNextBuffer(&buffer, &fence); +    ALOGE_IF(status != NO_ERROR, "detaching buffer from output failed (%d)", status); -        ALOGV("detached buffer %#llx from output", (long long)buffer->getId()); +    if (status == NO_INIT) { +        // If the output has been abandoned, we can't do anything else, +        // since buffer is invalid. +        onAbandoned_l(false /* isInput */); +        return; +    } -        // If we've been abandoned, we can't return the buffer to the input, so just -        // move on. -        if (mIsAbandoned) { -            return; -        } +    ALOGV("detached buffer %#llx from output", (long long)buffer->getId()); -        ssize_t ix = mBuffersSentToOutput.indexOfKey(buffer->getId()); -        if (ix < 0) { -            // The buffer is unknown, maybe leftover, ignore. -            return; -        } -        mBuffersSentToOutput.removeItemsAt(ix); +    // If we've been abandoned, we can't return the buffer to the input, so just +    // move on. +    if (mIsAbandoned) { +        return; +    } -        returnBufferToInput_l(buffer, fence); +    ssize_t ix = mBuffersSentToOutput.indexOfKey(buffer->getId()); +    if (ix < 0) { +        // The buffer is unknown, maybe leftover, ignore. +        return;      } +    mBuffersSentToOutput.removeItemsAt(ix); + +    returnBufferToInput_l(buffer, fence);  }  void MediaSync::returnBufferToInput_l( @@ -829,12 +816,6 @@ void MediaSync::onMessageReceived(const sp<AMessage> &msg) {              break;          } -        case kWhatCheckFrameAvailable: -        { -            onBufferReleasedByOutput(mOutput); -            break; -        } -          default:              TRESPASS();              break;  | 
