diff options
author | David Staessens <dstaessens@google.com> | 2021-05-12 05:54:30 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-12 05:54:30 +0000 |
commit | be945a9cefc463f6e1b50df46d527ea6dc118799 (patch) | |
tree | 09f2c6d7404da6aba7ff4206c68919b2a451ac16 | |
parent | 1ef9d180df9f9e4fe076f2039af7f282b1a35c0d (diff) | |
parent | c4a50a41eb3ae12d6af955d6760292578a154358 (diff) | |
download | v4l2_codec2-be945a9cefc463f6e1b50df46d527ea6dc118799.tar.gz |
v4l2_codec2: use std::find_if when locating EOS buffers. am: c4a50a41eb
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/v4l2_codec2/+/14501949
Change-Id: Ibb2b188636111725f1f066b58981e1130e4d86c9
-rw-r--r-- | components/V4L2EncodeComponent.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/components/V4L2EncodeComponent.cpp b/components/V4L2EncodeComponent.cpp index 4aaf6e8..2b7721d 100644 --- a/components/V4L2EncodeComponent.cpp +++ b/components/V4L2EncodeComponent.cpp @@ -558,20 +558,18 @@ void V4L2EncodeComponent::onDrainDone(bool success) { // Find the first work item marked as EOS. This might not be the first item in the queue, as // previous buffers in the queue might still be waiting for their associated input buffers. - C2Work* eosWork = nullptr; - for (auto it = mWorkQueue.cbegin(); it != mWorkQueue.cend(); ++it) { - if ((it->get()->input.flags & C2FrameData::FLAG_END_OF_STREAM) && - !(it->get()->worklets.back()->output.flags & C2FrameData::FLAG_END_OF_STREAM)) { - eosWork = it->get(); - break; - } - } - if (!eosWork) { + auto it = std::find_if( + mWorkQueue.cbegin(), mWorkQueue.cend(), [](const std::unique_ptr<C2Work>& work) { + return ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) && + !(work->worklets.back()->output.flags & C2FrameData::FLAG_END_OF_STREAM)); + }); + if (it == mWorkQueue.end()) { ALOGW("No EOS work item found in queue"); return; } // Mark the item in the output work queue as EOS done. + C2Work* eosWork = it->get(); eosWork->worklets.back()->output.flags = C2FrameData::FLAG_END_OF_STREAM; // Draining is done which means all buffers on the device output queue have been returned, but |