Loading include/media/stagefright/MediaSync.h +3 −5 Original line number Diff line number Diff line Loading @@ -136,7 +136,6 @@ protected: private: enum { kWhatDrainVideo = 'dVid', kWhatCheckFrameAvailable = 'cFrA', }; // This is a thin wrapper class that lets us listen to Loading Loading @@ -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. Loading media/libstagefright/MediaSync.cpp +26 −45 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -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( Loading @@ -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( Loading Loading @@ -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 Loading Loading @@ -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, Loading Loading @@ -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) { Loading @@ -727,12 +720,7 @@ 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) { status_t status = mOutput->detachNextBuffer(&buffer, &fence); ALOGE_IF(status != NO_ERROR, "detaching buffer from output failed (%d)", status); if (status == NO_INIT) { Loading @@ -759,7 +747,6 @@ void MediaSync::onBufferReleasedByOutput(sp<IGraphicBufferProducer> &output) { returnBufferToInput_l(buffer, fence); } } void MediaSync::returnBufferToInput_l( const sp<GraphicBuffer> &buffer, const sp<Fence> &fence) { Loading Loading @@ -829,12 +816,6 @@ void MediaSync::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatCheckFrameAvailable: { onBufferReleasedByOutput(mOutput); break; } default: TRESPASS(); break; Loading Loading
include/media/stagefright/MediaSync.h +3 −5 Original line number Diff line number Diff line Loading @@ -136,7 +136,6 @@ protected: private: enum { kWhatDrainVideo = 'dVid', kWhatCheckFrameAvailable = 'cFrA', }; // This is a thin wrapper class that lets us listen to Loading Loading @@ -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. Loading
media/libstagefright/MediaSync.cpp +26 −45 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -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( Loading @@ -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( Loading Loading @@ -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 Loading Loading @@ -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, Loading Loading @@ -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) { Loading @@ -727,12 +720,7 @@ 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) { status_t status = mOutput->detachNextBuffer(&buffer, &fence); ALOGE_IF(status != NO_ERROR, "detaching buffer from output failed (%d)", status); if (status == NO_INIT) { Loading @@ -759,7 +747,6 @@ void MediaSync::onBufferReleasedByOutput(sp<IGraphicBufferProducer> &output) { returnBufferToInput_l(buffer, fence); } } void MediaSync::returnBufferToInput_l( const sp<GraphicBuffer> &buffer, const sp<Fence> &fence) { Loading Loading @@ -829,12 +816,6 @@ void MediaSync::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatCheckFrameAvailable: { onBufferReleasedByOutput(mOutput); break; } default: TRESPASS(); break; Loading