Loading include/media/stagefright/ACodec.h +4 −1 Original line number Diff line number Diff line Loading @@ -68,15 +68,17 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase { size_t countBuffers(); IOMX::buffer_id bufferIDAt(size_t index) const; sp<ABuffer> bufferAt(size_t index) const; sp<RefBase> memRefAt(size_t index) const; private: friend struct ACodec; Vector<IOMX::buffer_id> mBufferIDs; Vector<sp<ABuffer> > mBuffers; Vector<sp<RefBase> > mMemRefs; PortDescription(); void addBuffer(IOMX::buffer_id id, const sp<ABuffer> &buffer); void addBuffer(IOMX::buffer_id id, const sp<ABuffer> &buffer, const sp<RefBase> &memRef); DISALLOW_EVIL_CONSTRUCTORS(PortDescription); }; Loading Loading @@ -170,6 +172,7 @@ private: unsigned mDequeuedAt; sp<ABuffer> mData; sp<RefBase> mMemRef; sp<GraphicBuffer> mGraphicBuffer; int mFenceFd; FrameRenderTracker::Info *mRenderInfo; Loading include/media/stagefright/CodecBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ struct CodecBase : public AHandler { virtual size_t countBuffers() = 0; virtual IOMX::buffer_id bufferIDAt(size_t index) const = 0; virtual sp<ABuffer> bufferAt(size_t index) const = 0; virtual sp<RefBase> memRefAt(size_t index) const { return NULL; } protected: PortDescription(); Loading include/media/stagefright/MediaCodec.h +3 −2 Original line number Diff line number Diff line Loading @@ -248,6 +248,7 @@ private: struct BufferInfo { uint32_t mBufferID; sp<ABuffer> mData; sp<RefBase> mMemRef; sp<ABuffer> mEncryptedData; sp<IMemory> mSharedEncryptedBuffer; sp<AMessage> mNotify; Loading Loading @@ -348,8 +349,8 @@ private: status_t init(const AString &name, bool nameIsType, bool encoder); void setState(State newState); void returnBuffersToCodec(); void returnBuffersToCodecOnPort(int32_t portIndex); void returnBuffersToCodec(bool isReclaim = false); void returnBuffersToCodecOnPort(int32_t portIndex, bool isReclaim = false); size_t updateBuffers(int32_t portIndex, const sp<AMessage> &msg); status_t onQueueInputBuffer(const sp<AMessage> &msg); status_t onReleaseOutputBuffer(const sp<AMessage> &msg); Loading media/libstagefright/ACodec.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -853,6 +853,7 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { if (type == kMetadataBufferTypeANWBuffer) { ((VideoNativeMetadata *)mem->pointer())->nFenceFd = -1; } info.mMemRef = mem; } mBuffers[portIndex].push(info); Loading @@ -873,8 +874,7 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { for (size_t i = 0; i < mBuffers[portIndex].size(); ++i) { const BufferInfo &info = mBuffers[portIndex][i]; desc->addBuffer(info.mBufferID, info.mData); desc->addBuffer(info.mBufferID, info.mData, info.mMemRef); } notify->setObject("portDesc", desc); Loading Loading @@ -1134,7 +1134,7 @@ status_t ACodec::allocateOutputMetadataBuffers() { // we use useBuffer for metadata regardless of quirks err = mOMX->useBuffer( mNode, kPortIndexOutput, mem, &info.mBufferID, mem->size()); info.mMemRef = mem; mBuffers[kPortIndexOutput].push(info); ALOGV("[%s] allocated meta buffer with ID %u (pointer = %p)", Loading Loading @@ -4504,9 +4504,10 @@ status_t ACodec::requestIDRFrame() { } void ACodec::PortDescription::addBuffer( IOMX::buffer_id id, const sp<ABuffer> &buffer) { IOMX::buffer_id id, const sp<ABuffer> &buffer, const sp<RefBase> &memRef) { mBufferIDs.push_back(id); mBuffers.push_back(buffer); mMemRefs.push_back(memRef); } size_t ACodec::PortDescription::countBuffers() { Loading @@ -4521,6 +4522,10 @@ sp<ABuffer> ACodec::PortDescription::bufferAt(size_t index) const { return mBuffers.itemAt(index); } sp<RefBase> ACodec::PortDescription::memRefAt(size_t index) const { return mMemRefs.itemAt(index); } //////////////////////////////////////////////////////////////////////////////// ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState) Loading media/libstagefright/MediaCodec.cpp +13 −6 Original line number Diff line number Diff line Loading @@ -1334,6 +1334,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { info.mBufferID = portDesc->bufferIDAt(i); info.mOwnedByClient = false; info.mData = portDesc->bufferAt(i); info.mMemRef = portDesc->memRefAt(i); if (portIndex == kPortIndexInput && mCrypto != NULL) { sp<IMemory> mem = mDealer->allocate(info.mData->capacity()); Loading Loading @@ -1906,7 +1907,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { mCodec->initiateShutdown( msg->what() == kWhatStop /* keepComponentAllocated */); returnBuffersToCodec(); returnBuffersToCodec(reclaimed); if (mSoftRenderer != NULL && (mFlags & kFlagPushBlankBuffersOnShutdown)) { pushBlankBuffersToNativeWindow(mSurface.get()); Loading Loading @@ -2309,12 +2310,12 @@ void MediaCodec::setState(State newState) { updateBatteryStat(); } void MediaCodec::returnBuffersToCodec() { returnBuffersToCodecOnPort(kPortIndexInput); returnBuffersToCodecOnPort(kPortIndexOutput); void MediaCodec::returnBuffersToCodec(bool isReclaim) { returnBuffersToCodecOnPort(kPortIndexInput, isReclaim); returnBuffersToCodecOnPort(kPortIndexOutput, isReclaim); } void MediaCodec::returnBuffersToCodecOnPort(int32_t portIndex) { void MediaCodec::returnBuffersToCodecOnPort(int32_t portIndex, bool isReclaim) { CHECK(portIndex == kPortIndexInput || portIndex == kPortIndexOutput); Mutex::Autolock al(mBufferLock); Loading @@ -2326,7 +2327,13 @@ void MediaCodec::returnBuffersToCodecOnPort(int32_t portIndex) { if (info->mNotify != NULL) { sp<AMessage> msg = info->mNotify; info->mNotify = NULL; if (isReclaim && info->mOwnedByClient) { ALOGD("port %d buffer %zu still owned by client when codec is reclaimed", portIndex, i); } else { info->mMemRef = NULL; info->mOwnedByClient = false; } if (portIndex == kPortIndexInput) { /* no error, just returning buffers */ Loading Loading
include/media/stagefright/ACodec.h +4 −1 Original line number Diff line number Diff line Loading @@ -68,15 +68,17 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase { size_t countBuffers(); IOMX::buffer_id bufferIDAt(size_t index) const; sp<ABuffer> bufferAt(size_t index) const; sp<RefBase> memRefAt(size_t index) const; private: friend struct ACodec; Vector<IOMX::buffer_id> mBufferIDs; Vector<sp<ABuffer> > mBuffers; Vector<sp<RefBase> > mMemRefs; PortDescription(); void addBuffer(IOMX::buffer_id id, const sp<ABuffer> &buffer); void addBuffer(IOMX::buffer_id id, const sp<ABuffer> &buffer, const sp<RefBase> &memRef); DISALLOW_EVIL_CONSTRUCTORS(PortDescription); }; Loading Loading @@ -170,6 +172,7 @@ private: unsigned mDequeuedAt; sp<ABuffer> mData; sp<RefBase> mMemRef; sp<GraphicBuffer> mGraphicBuffer; int mFenceFd; FrameRenderTracker::Info *mRenderInfo; Loading
include/media/stagefright/CodecBase.h +1 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ struct CodecBase : public AHandler { virtual size_t countBuffers() = 0; virtual IOMX::buffer_id bufferIDAt(size_t index) const = 0; virtual sp<ABuffer> bufferAt(size_t index) const = 0; virtual sp<RefBase> memRefAt(size_t index) const { return NULL; } protected: PortDescription(); Loading
include/media/stagefright/MediaCodec.h +3 −2 Original line number Diff line number Diff line Loading @@ -248,6 +248,7 @@ private: struct BufferInfo { uint32_t mBufferID; sp<ABuffer> mData; sp<RefBase> mMemRef; sp<ABuffer> mEncryptedData; sp<IMemory> mSharedEncryptedBuffer; sp<AMessage> mNotify; Loading Loading @@ -348,8 +349,8 @@ private: status_t init(const AString &name, bool nameIsType, bool encoder); void setState(State newState); void returnBuffersToCodec(); void returnBuffersToCodecOnPort(int32_t portIndex); void returnBuffersToCodec(bool isReclaim = false); void returnBuffersToCodecOnPort(int32_t portIndex, bool isReclaim = false); size_t updateBuffers(int32_t portIndex, const sp<AMessage> &msg); status_t onQueueInputBuffer(const sp<AMessage> &msg); status_t onReleaseOutputBuffer(const sp<AMessage> &msg); Loading
media/libstagefright/ACodec.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -853,6 +853,7 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { if (type == kMetadataBufferTypeANWBuffer) { ((VideoNativeMetadata *)mem->pointer())->nFenceFd = -1; } info.mMemRef = mem; } mBuffers[portIndex].push(info); Loading @@ -873,8 +874,7 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { for (size_t i = 0; i < mBuffers[portIndex].size(); ++i) { const BufferInfo &info = mBuffers[portIndex][i]; desc->addBuffer(info.mBufferID, info.mData); desc->addBuffer(info.mBufferID, info.mData, info.mMemRef); } notify->setObject("portDesc", desc); Loading Loading @@ -1134,7 +1134,7 @@ status_t ACodec::allocateOutputMetadataBuffers() { // we use useBuffer for metadata regardless of quirks err = mOMX->useBuffer( mNode, kPortIndexOutput, mem, &info.mBufferID, mem->size()); info.mMemRef = mem; mBuffers[kPortIndexOutput].push(info); ALOGV("[%s] allocated meta buffer with ID %u (pointer = %p)", Loading Loading @@ -4504,9 +4504,10 @@ status_t ACodec::requestIDRFrame() { } void ACodec::PortDescription::addBuffer( IOMX::buffer_id id, const sp<ABuffer> &buffer) { IOMX::buffer_id id, const sp<ABuffer> &buffer, const sp<RefBase> &memRef) { mBufferIDs.push_back(id); mBuffers.push_back(buffer); mMemRefs.push_back(memRef); } size_t ACodec::PortDescription::countBuffers() { Loading @@ -4521,6 +4522,10 @@ sp<ABuffer> ACodec::PortDescription::bufferAt(size_t index) const { return mBuffers.itemAt(index); } sp<RefBase> ACodec::PortDescription::memRefAt(size_t index) const { return mMemRefs.itemAt(index); } //////////////////////////////////////////////////////////////////////////////// ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState) Loading
media/libstagefright/MediaCodec.cpp +13 −6 Original line number Diff line number Diff line Loading @@ -1334,6 +1334,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { info.mBufferID = portDesc->bufferIDAt(i); info.mOwnedByClient = false; info.mData = portDesc->bufferAt(i); info.mMemRef = portDesc->memRefAt(i); if (portIndex == kPortIndexInput && mCrypto != NULL) { sp<IMemory> mem = mDealer->allocate(info.mData->capacity()); Loading Loading @@ -1906,7 +1907,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { mCodec->initiateShutdown( msg->what() == kWhatStop /* keepComponentAllocated */); returnBuffersToCodec(); returnBuffersToCodec(reclaimed); if (mSoftRenderer != NULL && (mFlags & kFlagPushBlankBuffersOnShutdown)) { pushBlankBuffersToNativeWindow(mSurface.get()); Loading Loading @@ -2309,12 +2310,12 @@ void MediaCodec::setState(State newState) { updateBatteryStat(); } void MediaCodec::returnBuffersToCodec() { returnBuffersToCodecOnPort(kPortIndexInput); returnBuffersToCodecOnPort(kPortIndexOutput); void MediaCodec::returnBuffersToCodec(bool isReclaim) { returnBuffersToCodecOnPort(kPortIndexInput, isReclaim); returnBuffersToCodecOnPort(kPortIndexOutput, isReclaim); } void MediaCodec::returnBuffersToCodecOnPort(int32_t portIndex) { void MediaCodec::returnBuffersToCodecOnPort(int32_t portIndex, bool isReclaim) { CHECK(portIndex == kPortIndexInput || portIndex == kPortIndexOutput); Mutex::Autolock al(mBufferLock); Loading @@ -2326,7 +2327,13 @@ void MediaCodec::returnBuffersToCodecOnPort(int32_t portIndex) { if (info->mNotify != NULL) { sp<AMessage> msg = info->mNotify; info->mNotify = NULL; if (isReclaim && info->mOwnedByClient) { ALOGD("port %d buffer %zu still owned by client when codec is reclaimed", portIndex, i); } else { info->mMemRef = NULL; info->mOwnedByClient = false; } if (portIndex == kPortIndexInput) { /* no error, just returning buffers */ Loading