Loading include/media/stagefright/MediaSync.h +8 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <media/stagefright/foundation/AHandler.h> #include <utils/Condition.h> #include <utils/KeyedVector.h> #include <utils/Mutex.h> namespace android { Loading Loading @@ -190,6 +191,13 @@ private: int64_t mNextBufferItemMediaUs; List<BufferItem> mBufferItems; // Keep track of buffers received from |mInput|. This is needed because // it's possible the consumer of |mOutput| could return a different // GraphicBuffer::handle (e.g., due to passing buffers through IPC), // and that could cause problem if the producer of |mInput| only // supports pre-registered buffers. KeyedVector<uint64_t, sp<GraphicBuffer> > mBuffersFromInput; sp<ALooper> mLooper; float mPlaybackRate; Loading media/libstagefright/MediaSync.cpp +21 −2 Original line number Diff line number Diff line Loading @@ -430,7 +430,16 @@ void MediaSync::onFrameAvailableFromInput() { return; } if (mBuffersFromInput.indexOfKey(bufferItem.mGraphicBuffer->getId()) >= 0) { // Something is wrong since this buffer should be at our hands, bail. mInput->consumerDisconnect(); onAbandoned_l(true /* isInput */); return; } mBuffersFromInput.add(bufferItem.mGraphicBuffer->getId(), bufferItem.mGraphicBuffer); mBufferItems.push_back(bufferItem); if (mBufferItems.size() == 1) { onDrainVideo_l(); } Loading Loading @@ -497,9 +506,19 @@ void MediaSync::onBufferReleasedByOutput() { void MediaSync::returnBufferToInput_l( const sp<GraphicBuffer> &buffer, const sp<Fence> &fence) { ssize_t ix = mBuffersFromInput.indexOfKey(buffer->getId()); if (ix < 0) { // The buffer is unknown, something is wrong, bail. mOutput->disconnect(NATIVE_WINDOW_API_MEDIA); onAbandoned_l(false /* isInput */); return; } sp<GraphicBuffer> oldBuffer = mBuffersFromInput.valueAt(ix); mBuffersFromInput.removeItemsAt(ix); // Attach and release the buffer back to the input. int consumerSlot; status_t status = mInput->attachBuffer(&consumerSlot, buffer); status_t status = mInput->attachBuffer(&consumerSlot, oldBuffer); ALOGE_IF(status != NO_ERROR, "attaching buffer to input failed (%d)", status); if (status == NO_ERROR) { status = mInput->releaseBuffer(consumerSlot, 0 /* frameNumber */, Loading @@ -512,7 +531,7 @@ void MediaSync::returnBufferToInput_l( return; } ALOGV("released buffer %#llx to input", (long long)buffer->getId()); ALOGV("released buffer %#llx to input", (long long)oldBuffer->getId()); // Notify any waiting onFrameAvailable calls. --mNumOutstandingBuffers; Loading Loading
include/media/stagefright/MediaSync.h +8 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <media/stagefright/foundation/AHandler.h> #include <utils/Condition.h> #include <utils/KeyedVector.h> #include <utils/Mutex.h> namespace android { Loading Loading @@ -190,6 +191,13 @@ private: int64_t mNextBufferItemMediaUs; List<BufferItem> mBufferItems; // Keep track of buffers received from |mInput|. This is needed because // it's possible the consumer of |mOutput| could return a different // GraphicBuffer::handle (e.g., due to passing buffers through IPC), // and that could cause problem if the producer of |mInput| only // supports pre-registered buffers. KeyedVector<uint64_t, sp<GraphicBuffer> > mBuffersFromInput; sp<ALooper> mLooper; float mPlaybackRate; Loading
media/libstagefright/MediaSync.cpp +21 −2 Original line number Diff line number Diff line Loading @@ -430,7 +430,16 @@ void MediaSync::onFrameAvailableFromInput() { return; } if (mBuffersFromInput.indexOfKey(bufferItem.mGraphicBuffer->getId()) >= 0) { // Something is wrong since this buffer should be at our hands, bail. mInput->consumerDisconnect(); onAbandoned_l(true /* isInput */); return; } mBuffersFromInput.add(bufferItem.mGraphicBuffer->getId(), bufferItem.mGraphicBuffer); mBufferItems.push_back(bufferItem); if (mBufferItems.size() == 1) { onDrainVideo_l(); } Loading Loading @@ -497,9 +506,19 @@ void MediaSync::onBufferReleasedByOutput() { void MediaSync::returnBufferToInput_l( const sp<GraphicBuffer> &buffer, const sp<Fence> &fence) { ssize_t ix = mBuffersFromInput.indexOfKey(buffer->getId()); if (ix < 0) { // The buffer is unknown, something is wrong, bail. mOutput->disconnect(NATIVE_WINDOW_API_MEDIA); onAbandoned_l(false /* isInput */); return; } sp<GraphicBuffer> oldBuffer = mBuffersFromInput.valueAt(ix); mBuffersFromInput.removeItemsAt(ix); // Attach and release the buffer back to the input. int consumerSlot; status_t status = mInput->attachBuffer(&consumerSlot, buffer); status_t status = mInput->attachBuffer(&consumerSlot, oldBuffer); ALOGE_IF(status != NO_ERROR, "attaching buffer to input failed (%d)", status); if (status == NO_ERROR) { status = mInput->releaseBuffer(consumerSlot, 0 /* frameNumber */, Loading @@ -512,7 +531,7 @@ void MediaSync::returnBufferToInput_l( return; } ALOGV("released buffer %#llx to input", (long long)buffer->getId()); ALOGV("released buffer %#llx to input", (long long)oldBuffer->getId()); // Notify any waiting onFrameAvailable calls. --mNumOutstandingBuffers; Loading