Loading media/codec2/sfplugin/CCodecBufferChannel.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <utils/Log.h> #include <algorithm> #include <atomic> #include <list> #include <numeric> Loading Loading @@ -155,6 +156,7 @@ CCodecBufferChannel::CCodecBufferChannel( input->pipelineDelay = 0u; input->numSlots = kSmoothnessFactor; input->numExtraSlots = 0u; input->lastFlushIndex = 0u; } { Mutexed<Output>::Locked output(mOutput); Loading Loading @@ -1122,6 +1124,7 @@ status_t CCodecBufferChannel::start( input->numSlots = numInputSlots; input->extraBuffers.flush(); input->numExtraSlots = 0u; input->lastFlushIndex = mFrameIndex.load(std::memory_order_relaxed); if (audioEncoder && encoderFrameSize && sampleRate && channelCount) { input->frameReassembler.init( pool, Loading Loading @@ -1535,6 +1538,7 @@ void CCodecBufferChannel::flush(const std::list<std::unique_ptr<C2Work>> &flushe ALOGV("[%s] flush", mName); std::vector<uint64_t> indices; std::list<std::unique_ptr<C2Work>> configs; mInput.lock()->lastFlushIndex = mFrameIndex.load(std::memory_order_relaxed); for (const std::unique_ptr<C2Work> &work : flushedWork) { indices.push_back(work->input.ordinal.frameIndex.peeku()); if (!(work->input.flags & C2FrameData::FLAG_CODEC_CONFIG)) { Loading Loading @@ -1601,14 +1605,20 @@ void CCodecBufferChannel::onInputBufferDone( } std::shared_ptr<C2Buffer> buffer = mPipelineWatcher.lock()->onInputBufferReleased(frameIndex, arrayIndex); bool newInputSlotAvailable; bool newInputSlotAvailable = false; { Mutexed<Input>::Locked input(mInput); if (input->lastFlushIndex >= frameIndex) { ALOGD("[%s] Ignoring stale input buffer done callback: " "last flush index = %lld, frameIndex = %lld", mName, input->lastFlushIndex.peekll(), (long long)frameIndex); } else { newInputSlotAvailable = input->buffers->expireComponentBuffer(buffer); if (!newInputSlotAvailable) { (void)input->extraBuffers.expireComponentBuffer(buffer); } } } if (newInputSlotAvailable) { feedInputBufferIfAvailable(); } Loading media/codec2/sfplugin/CCodecBufferChannel.h +1 −0 Original line number Diff line number Diff line Loading @@ -273,6 +273,7 @@ private: size_t numExtraSlots; uint32_t inputDelay; uint32_t pipelineDelay; c2_cntr64_t lastFlushIndex; FrameReassembler frameReassembler; }; Loading Loading
media/codec2/sfplugin/CCodecBufferChannel.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <utils/Log.h> #include <algorithm> #include <atomic> #include <list> #include <numeric> Loading Loading @@ -155,6 +156,7 @@ CCodecBufferChannel::CCodecBufferChannel( input->pipelineDelay = 0u; input->numSlots = kSmoothnessFactor; input->numExtraSlots = 0u; input->lastFlushIndex = 0u; } { Mutexed<Output>::Locked output(mOutput); Loading Loading @@ -1122,6 +1124,7 @@ status_t CCodecBufferChannel::start( input->numSlots = numInputSlots; input->extraBuffers.flush(); input->numExtraSlots = 0u; input->lastFlushIndex = mFrameIndex.load(std::memory_order_relaxed); if (audioEncoder && encoderFrameSize && sampleRate && channelCount) { input->frameReassembler.init( pool, Loading Loading @@ -1535,6 +1538,7 @@ void CCodecBufferChannel::flush(const std::list<std::unique_ptr<C2Work>> &flushe ALOGV("[%s] flush", mName); std::vector<uint64_t> indices; std::list<std::unique_ptr<C2Work>> configs; mInput.lock()->lastFlushIndex = mFrameIndex.load(std::memory_order_relaxed); for (const std::unique_ptr<C2Work> &work : flushedWork) { indices.push_back(work->input.ordinal.frameIndex.peeku()); if (!(work->input.flags & C2FrameData::FLAG_CODEC_CONFIG)) { Loading Loading @@ -1601,14 +1605,20 @@ void CCodecBufferChannel::onInputBufferDone( } std::shared_ptr<C2Buffer> buffer = mPipelineWatcher.lock()->onInputBufferReleased(frameIndex, arrayIndex); bool newInputSlotAvailable; bool newInputSlotAvailable = false; { Mutexed<Input>::Locked input(mInput); if (input->lastFlushIndex >= frameIndex) { ALOGD("[%s] Ignoring stale input buffer done callback: " "last flush index = %lld, frameIndex = %lld", mName, input->lastFlushIndex.peekll(), (long long)frameIndex); } else { newInputSlotAvailable = input->buffers->expireComponentBuffer(buffer); if (!newInputSlotAvailable) { (void)input->extraBuffers.expireComponentBuffer(buffer); } } } if (newInputSlotAvailable) { feedInputBufferIfAvailable(); } Loading
media/codec2/sfplugin/CCodecBufferChannel.h +1 −0 Original line number Diff line number Diff line Loading @@ -273,6 +273,7 @@ private: size_t numExtraSlots; uint32_t inputDelay; uint32_t pipelineDelay; c2_cntr64_t lastFlushIndex; FrameReassembler frameReassembler; }; Loading