xref: /aosp_15_r20/frameworks/av/media/codec2/hal/client/output.cpp (revision ec779b8e0859a360c3d303172224686826e6e0e1)
1 /*
2  * Copyright 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 //#define LOG_NDEBUG 0
18 #define LOG_TAG "Codec2-OutputBufferQueue"
19 #define ATRACE_TAG  ATRACE_TAG_VIDEO
20 #include <android-base/logging.h>
21 #include <utils/Trace.h>
22 
23 #include <android/hardware/graphics/bufferqueue/2.0/IGraphicBufferProducer.h>
24 #include <codec2/hidl/output.h>
25 #include <cutils/ashmem.h>
26 #include <gui/bufferqueue/2.0/B2HGraphicBufferProducer.h>
27 #include <sys/mman.h>
28 
29 #include <C2AllocatorGralloc.h>
30 #include <C2BlockInternal.h>
31 #include <C2Buffer.h>
32 #include <C2PlatformSupport.h>
33 #include <C2SurfaceSyncObj.h>
34 
35 #include <iomanip>
36 
37 namespace android {
38 namespace hardware {
39 namespace media {
40 namespace c2 {
41 
42 using HGraphicBufferProducer = ::android::hardware::graphics::bufferqueue::
43         V2_0::IGraphicBufferProducer;
44 using B2HGraphicBufferProducer = ::android::hardware::graphics::bufferqueue::
45         V2_0::utils::B2HGraphicBufferProducer;
46 
47 namespace /* unnamed */ {
48 
49 // Create a GraphicBuffer object from a graphic block.
createGraphicBuffer(const C2ConstGraphicBlock & block)50 sp<GraphicBuffer> createGraphicBuffer(const C2ConstGraphicBlock& block) {
51     uint32_t width;
52     uint32_t height;
53     uint32_t format;
54     uint64_t usage;
55     uint32_t stride;
56     uint32_t generation;
57     uint64_t bqId;
58     int32_t bqSlot;
59     _UnwrapNativeCodec2GrallocMetadata(
60             block.handle(), &width, &height, &format, &usage,
61             &stride, &generation, &bqId, reinterpret_cast<uint32_t*>(&bqSlot));
62     native_handle_t *grallocHandle =
63             UnwrapNativeCodec2GrallocHandle(block.handle());
64     sp<GraphicBuffer> graphicBuffer =
65             new GraphicBuffer(grallocHandle,
66                               GraphicBuffer::CLONE_HANDLE,
67                               width, height, format,
68                               1, usage, stride);
69     native_handle_delete(grallocHandle);
70     return graphicBuffer;
71 }
72 
73 template <typename BlockProcessor>
forEachBlock(C2FrameData & frameData,BlockProcessor process)74 void forEachBlock(C2FrameData& frameData,
75                   BlockProcessor process) {
76     for (const std::shared_ptr<C2Buffer>& buffer : frameData.buffers) {
77         if (buffer) {
78             for (const C2ConstGraphicBlock& block :
79                     buffer->data().graphicBlocks()) {
80                 process(block);
81             }
82         }
83     }
84 }
85 
86 template <typename BlockProcessor>
forEachBlock(const std::list<std::unique_ptr<C2Work>> & workList,BlockProcessor process)87 void forEachBlock(const std::list<std::unique_ptr<C2Work>>& workList,
88                   BlockProcessor process) {
89     for (const std::unique_ptr<C2Work>& work : workList) {
90         if (!work) {
91             continue;
92         }
93         for (const std::unique_ptr<C2Worklet>& worklet : work->worklets) {
94             if (worklet) {
95                 forEachBlock(worklet->output, process);
96             }
97         }
98     }
99 }
100 
getHgbp(const sp<IGraphicBufferProducer> & igbp)101 sp<HGraphicBufferProducer> getHgbp(const sp<IGraphicBufferProducer>& igbp) {
102     sp<HGraphicBufferProducer> hgbp =
103             igbp->getHalInterface<HGraphicBufferProducer>();
104     return hgbp ? hgbp :
105             new B2HGraphicBufferProducer(igbp);
106 }
107 
attachToBufferQueue(const C2ConstGraphicBlock & block,const sp<IGraphicBufferProducer> & igbp,uint32_t generation,int32_t * bqSlot,std::shared_ptr<C2SurfaceSyncMemory> syncMem)108 status_t attachToBufferQueue(const C2ConstGraphicBlock& block,
109                              const sp<IGraphicBufferProducer>& igbp,
110                              uint32_t generation,
111                              int32_t* bqSlot,
112                              std::shared_ptr<C2SurfaceSyncMemory> syncMem) {
113     if (!igbp) {
114         LOG(WARNING) << "attachToBufferQueue -- null producer.";
115         return NO_INIT;
116     }
117 
118     sp<GraphicBuffer> graphicBuffer = createGraphicBuffer(block);
119     graphicBuffer->setGenerationNumber(generation);
120 
121     LOG(VERBOSE) << "attachToBufferQueue -- attaching buffer:"
122             << " block dimension " << block.width() << "x"
123                                    << block.height()
124             << ", graphicBuffer dimension " << graphicBuffer->getWidth() << "x"
125                                            << graphicBuffer->getHeight()
126             << std::hex << std::setfill('0')
127             << ", format 0x" << std::setw(8) << graphicBuffer->getPixelFormat()
128             << ", usage 0x" << std::setw(16) << graphicBuffer->getUsage()
129             << std::dec << std::setfill(' ')
130             << ", stride " << graphicBuffer->getStride()
131             << ", generation " << graphicBuffer->getGenerationNumber();
132 
133     C2SyncVariables *syncVar = syncMem ? syncMem->mem() : nullptr;
134     status_t result = OK;
135     if (syncVar) {
136         syncVar->lock();
137         if (!syncVar->isDequeueableLocked() ||
138             syncVar->getSyncStatusLocked() == C2SyncVariables::STATUS_SWITCHING) {
139             syncVar->unlock();
140             LOG(WARNING) << "attachToBufferQueue -- attachBuffer failed: "
141                             "status = " << INVALID_OPERATION << ".";
142             return INVALID_OPERATION;
143         }
144         syncVar->notifyDequeuedLocked();
145         syncVar->unlock();
146         result = igbp->attachBuffer(bqSlot, graphicBuffer);
147         if (result != OK) {
148             syncVar->lock();
149             syncVar->notifyQueuedLocked();
150             syncVar->unlock();
151         }
152     } else {
153         result = igbp->attachBuffer(bqSlot, graphicBuffer);
154     }
155     if (result != OK) {
156         LOG(WARNING) << "attachToBufferQueue -- attachBuffer failed: "
157                         "status = " << result << ".";
158         return result;
159     }
160     LOG(VERBOSE) << "attachToBufferQueue -- attachBuffer returned slot #"
161                  << *bqSlot << ".";
162     return OK;
163 }
164 
getBufferQueueAssignment(const C2ConstGraphicBlock & block,uint32_t * generation,uint64_t * bqId,int32_t * bqSlot)165 bool getBufferQueueAssignment(const C2ConstGraphicBlock& block,
166                               uint32_t* generation,
167                               uint64_t* bqId,
168                               int32_t* bqSlot) {
169     return _C2BlockFactory::GetBufferQueueData(
170             _C2BlockFactory::GetGraphicBlockPoolData(block),
171             generation, bqId, bqSlot);
172 }
173 
174 } // unnamed namespace
175 
OutputBufferQueue()176 OutputBufferQueue::OutputBufferQueue()
177       : mGeneration{0}, mBqId{0}, mStopped{false} {
178 }
179 
~OutputBufferQueue()180 OutputBufferQueue::~OutputBufferQueue() {
181 }
182 
configure(const sp<IGraphicBufferProducer> & igbp,uint32_t generation,uint64_t bqId,int maxDequeueBufferCount,std::shared_ptr<V1_2::SurfaceSyncObj> * syncObj)183 bool OutputBufferQueue::configure(const sp<IGraphicBufferProducer>& igbp,
184                                   uint32_t generation,
185                                   uint64_t bqId,
186                                   int maxDequeueBufferCount,
187                                   std::shared_ptr<V1_2::SurfaceSyncObj> *syncObj) {
188     uint64_t consumerUsage = 0;
189     if (igbp && igbp->getConsumerUsage(&consumerUsage) != OK) {
190         ALOGW("failed to get consumer usage");
191     }
192 
193     // TODO : Abstract creation process into C2SurfaceSyncMemory class.
194     // use C2LinearBlock instead ashmem.
195     std::shared_ptr<C2SurfaceSyncMemory> syncMem;
196     if (syncObj && igbp) {
197         bool mapped = false;
198         int memFd = ashmem_create_region("C2SurfaceMem", sizeof(C2SyncVariables));
199         size_t memSize = memFd < 0 ? 0 : ashmem_get_size_region(memFd);
200         if (memSize > 0) {
201             syncMem = C2SurfaceSyncMemory::Create(memFd, memSize);
202             if (syncMem) {
203                 mapped = true;
204                 *syncObj = std::make_shared<V1_2::SurfaceSyncObj>();
205                 (*syncObj)->syncMemory = syncMem->handle();
206                 (*syncObj)->bqId = bqId;
207                 (*syncObj)->generationId = generation;
208                 (*syncObj)->consumerUsage = consumerUsage;
209                 ALOGD("C2SurfaceSyncMemory created %zu(%zu)", sizeof(C2SyncVariables), memSize);
210             }
211         }
212         if (!mapped) {
213             if (memFd >= 0) {
214                 ::close(memFd);
215             }
216             ALOGW("SurfaceSyncObj creation failure");
217         }
218     }
219 
220     size_t tryNum = 0;
221     size_t success = 0;
222     sp<GraphicBuffer> buffers[BufferQueueDefs::NUM_BUFFER_SLOTS];
223     std::weak_ptr<_C2BlockPoolData>
224             poolDatas[BufferQueueDefs::NUM_BUFFER_SLOTS];
225     std::shared_ptr<C2SurfaceSyncMemory> oldMem;
226     {
227         std::scoped_lock<std::mutex> l(mMutex);
228         bool stopped = mStopped;
229         mStopped = false;
230         if (generation == mGeneration) {
231             // case of old BlockPool destruction
232             C2SyncVariables *var = mSyncMem ? mSyncMem->mem() : nullptr;
233             if (syncObj && var) {
234                 *syncObj = std::make_shared<V1_2::SurfaceSyncObj>();
235                 (*syncObj)->bqId = bqId;
236                 (*syncObj)->syncMemory = mSyncMem->handle();
237                 (*syncObj)->generationId = generation;
238                 (*syncObj)->consumerUsage = consumerUsage;
239                 mMaxDequeueBufferCount = maxDequeueBufferCount;
240                 var->lock();
241                 var->setSyncStatusLocked(C2SyncVariables::STATUS_INIT);
242                 var->setInitialDequeueCountLocked(mMaxDequeueBufferCount, 0);
243                 var->unlock();
244             }
245             return false;
246         }
247         oldMem = mSyncMem;
248         C2SyncVariables *oldSync = mSyncMem ? mSyncMem->mem() : nullptr;
249         if (oldSync) {
250             oldSync->lock();
251             oldSync->setSyncStatusLocked(C2SyncVariables::STATUS_SWITCHING);
252             oldSync->unlock();
253         }
254         mSyncMem.reset();
255         if (syncMem) {
256             mSyncMem = syncMem;
257         }
258         C2SyncVariables *newSync = mSyncMem ? mSyncMem->mem() : nullptr;
259 
260         mIgbp = igbp;
261         mGeneration = generation;
262         mBqId = bqId;
263         mOwner = std::make_shared<int>(0);
264         mConsumerAttachCount = std::make_shared<int>(0);
265         mMaxDequeueBufferCount = maxDequeueBufferCount;
266         if (igbp == nullptr) {
267             return false;
268         }
269         for (int i = 0; i < BufferQueueDefs::NUM_BUFFER_SLOTS; ++i) {
270             if (mBqId == 0 || !mBuffers[i] || stopped) {
271                 continue;
272             }
273             std::shared_ptr<_C2BlockPoolData> data = mPoolDatas[i].lock();
274             if (!data ||
275                 !_C2BlockFactory::BeginAttachBlockToBufferQueue(data)) {
276                 continue;
277             }
278             ++tryNum;
279             int bqSlot;
280 
281             // Update buffer's generation and usage.
282             if ((mBuffers[i]->getUsage() & consumerUsage) != consumerUsage) {
283                 mBuffers[i] = new GraphicBuffer(
284                     mBuffers[i]->handle, GraphicBuffer::CLONE_HANDLE,
285                     mBuffers[i]->width, mBuffers[i]->height,
286                     mBuffers[i]->format, mBuffers[i]->layerCount,
287                     mBuffers[i]->getUsage() | consumerUsage,
288                     mBuffers[i]->stride);
289                 if (mBuffers[i]->initCheck() != OK) {
290                     ALOGW("%s() failed to update usage, original usage=%" PRIx64
291                           ", consumer usage=%" PRIx64,
292                           __func__, mBuffers[i]->getUsage(), consumerUsage);
293                     continue;
294                 }
295             }
296             mBuffers[i]->setGenerationNumber(generation);
297 
298             status_t result = igbp->attachBuffer(&bqSlot, mBuffers[i]);
299             if (result != OK) {
300                 continue;
301             }
302             bool attach =
303                     _C2BlockFactory::EndAttachBlockToBufferQueue(
304                             data, mOwner, getHgbp(mIgbp), mSyncMem,
305                             generation, bqId, bqSlot);
306             if (!attach) {
307                 igbp->cancelBuffer(bqSlot, Fence::NO_FENCE);
308                 continue;
309             }
310             buffers[bqSlot] = mBuffers[i];
311             poolDatas[bqSlot] = data;
312             ++success;
313         }
314         for (int i = 0; i < BufferQueueDefs::NUM_BUFFER_SLOTS; ++i) {
315             mBuffers[i] = buffers[i];
316             mPoolDatas[i] = poolDatas[i];
317         }
318         if (newSync) {
319             newSync->lock();
320             newSync->setInitialDequeueCountLocked(mMaxDequeueBufferCount, success);
321             newSync->unlock();
322         }
323     }
324     {
325         std::scoped_lock<std::mutex> l(mOldMutex);
326         mOldMem = oldMem;
327     }
328     ALOGD("remote graphic buffer migration %zu/%zu",
329           success, tryNum);
330     return true;
331 }
332 
expireOldWaiters()333 void OutputBufferQueue::expireOldWaiters() {
334     std::scoped_lock<std::mutex> l(mOldMutex);
335     if (mOldMem) {
336         C2SyncVariables *oldSync = mOldMem->mem();
337         if (oldSync) {
338             oldSync->notifyAll();
339         }
340         mOldMem.reset();
341     }
342 }
343 
stop()344 void OutputBufferQueue::stop() {
345     std::shared_ptr<C2SurfaceSyncMemory> oldMem;
346     {
347         std::scoped_lock<std::mutex> l(mMutex);
348         if (mStopped) {
349             return;
350         }
351         mStopped = true;
352         mOwner.reset(); // destructor of the block will not trigger IGBP::cancel()
353         // basically configuring null surface
354         oldMem = mSyncMem;
355         mSyncMem.reset();
356         mIgbp.clear();
357         mGeneration = 0;
358         mBqId = 0;
359     }
360     {
361         std::scoped_lock<std::mutex> l(mOldMutex);
362         mOldMem = oldMem;
363     }
364 }
365 
registerBuffer(const C2ConstGraphicBlock & block)366 bool OutputBufferQueue::registerBuffer(const C2ConstGraphicBlock& block) {
367     std::shared_ptr<_C2BlockPoolData> data =
368             _C2BlockFactory::GetGraphicBlockPoolData(block);
369     if (!data) {
370         return false;
371     }
372     std::scoped_lock<std::mutex> l(mMutex);
373 
374     if (!mIgbp || mStopped) {
375         return false;
376     }
377 
378     uint32_t oldGeneration;
379     uint64_t oldId;
380     int32_t oldSlot;
381     // If the block is not bufferqueue-based, do nothing.
382     if (!_C2BlockFactory::GetBufferQueueData(
383             data, &oldGeneration, &oldId, &oldSlot) || (oldId == 0)) {
384         return false;
385     }
386     // If the block's bqId is the same as the desired bqId, just hold.
387     if ((oldId == mBqId) && (oldGeneration == mGeneration)) {
388         LOG(VERBOSE) << "holdBufferQueueBlock -- import without attaching:"
389                      << " bqId " << oldId
390                      << ", bqSlot " << oldSlot
391                      << ", generation " << mGeneration
392                      << ".";
393         _C2BlockFactory::HoldBlockFromBufferQueue(data, mOwner, getHgbp(mIgbp), mSyncMem);
394         mPoolDatas[oldSlot] = data;
395         mBuffers[oldSlot] = createGraphicBuffer(block);
396         mBuffers[oldSlot]->setGenerationNumber(mGeneration);
397         return true;
398     }
399     int32_t d = (int32_t) mGeneration - (int32_t) oldGeneration;
400     LOG(WARNING) << "receiving stale buffer: generation "
401                  << mGeneration << " , diff " << d  << " : slot "
402                  << oldSlot;
403     return false;
404 }
405 
outputBuffer(const C2ConstGraphicBlock & block,const BnGraphicBufferProducer::QueueBufferInput & input,BnGraphicBufferProducer::QueueBufferOutput * output)406 status_t OutputBufferQueue::outputBuffer(
407         const C2ConstGraphicBlock& block,
408         const BnGraphicBufferProducer::QueueBufferInput& input,
409         BnGraphicBufferProducer::QueueBufferOutput* output) {
410     uint32_t generation;
411     uint64_t bqId;
412     int32_t bqSlot;
413     ScopedTrace trace(ATRACE_TAG,"Codec2-OutputBufferQueue::outputBuffer");
414     bool display = V1_0::utils::displayBufferQueueBlock(block);
415     if (!getBufferQueueAssignment(block, &generation, &bqId, &bqSlot) ||
416         bqId == 0) {
417         // Block not from bufferqueue -- it must be attached before queuing.
418 
419         std::shared_ptr<C2SurfaceSyncMemory> syncMem;
420         mMutex.lock();
421         bool stopped = mStopped;
422         sp<IGraphicBufferProducer> outputIgbp = mIgbp;
423         uint32_t outputGeneration = mGeneration;
424         syncMem = mSyncMem;
425         mMutex.unlock();
426 
427         if (stopped) {
428             LOG(INFO) << "outputBuffer -- already stopped.";
429             return DEAD_OBJECT;
430         }
431 
432         status_t status = attachToBufferQueue(
433                 block, outputIgbp, outputGeneration, &bqSlot, syncMem);
434 
435         if (status != OK) {
436             LOG(WARNING) << "outputBuffer -- attaching failed.";
437             return INVALID_OPERATION;
438         }
439 
440         auto syncVar = syncMem ? syncMem->mem() : nullptr;
441         if(syncVar) {
442             status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
443                                          input, output);
444             if (status == OK) {
445                 if (output->bufferReplaced) {
446                     syncVar->lock();
447                     syncVar->notifyQueuedLocked();
448                     syncVar->unlock();
449                 }
450             }
451         } else {
452             status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
453                                          input, output);
454         }
455         if (status != OK) {
456             LOG(ERROR) << "outputBuffer -- queueBuffer() failed "
457                        "on non-bufferqueue-based block. "
458                        "Error = " << status << ".";
459             return status;
460         }
461         return OK;
462     }
463 
464     std::shared_ptr<C2SurfaceSyncMemory> syncMem;
465     mMutex.lock();
466     bool stopped = mStopped;
467     sp<IGraphicBufferProducer> outputIgbp = mIgbp;
468     uint32_t outputGeneration = mGeneration;
469     uint64_t outputBqId = mBqId;
470     syncMem = mSyncMem;
471     mMutex.unlock();
472 
473     if (stopped) {
474         LOG(INFO) << "outputBuffer -- already stopped.";
475         return DEAD_OBJECT;
476     }
477 
478     if (!outputIgbp) {
479         LOG(VERBOSE) << "outputBuffer -- output surface is null.";
480         return NO_INIT;
481     }
482 
483     if (!display) {
484         LOG(WARNING) << "outputBuffer -- cannot display "
485                      "bufferqueue-based block to the bufferqueue.";
486         return UNKNOWN_ERROR;
487     }
488     if (bqId != outputBqId || generation != outputGeneration) {
489         int32_t diff = (int32_t) outputGeneration - (int32_t) generation;
490         LOG(WARNING) << "outputBuffer -- buffers from old generation to "
491                      << outputGeneration << " , diff: " << diff
492                      << " , slot: " << bqSlot;
493         return DEAD_OBJECT;
494     }
495 
496     auto syncVar = syncMem ? syncMem->mem() : nullptr;
497     status_t status = OK;
498     if (syncVar) {
499         status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
500                                                   input, output);
501         if (status == OK) {
502             if (output->bufferReplaced) {
503                 syncVar->lock();
504                 syncVar->notifyQueuedLocked();
505                 syncVar->unlock();
506             }
507         }
508     } else {
509         status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
510                                                   input, output);
511     }
512 
513     if (status != OK) {
514         LOG(ERROR) << "outputBuffer -- queueBuffer() failed "
515                    "on bufferqueue-based block. "
516                    "Error = " << status << ".";
517         return status;
518     }
519     return OK;
520 }
521 
onBufferReleased(uint32_t generation)522 void OutputBufferQueue::onBufferReleased(uint32_t generation) {
523     std::shared_ptr<C2SurfaceSyncMemory> syncMem;
524     sp<IGraphicBufferProducer> outputIgbp;
525     uint32_t outputGeneration = 0;
526     std::shared_ptr<int> consumerAttachCount;
527     {
528         std::unique_lock<std::mutex> l(mMutex);
529         if (mStopped) {
530             return;
531         }
532         outputIgbp = mIgbp;
533         outputGeneration = mGeneration;
534         consumerAttachCount = mConsumerAttachCount;
535         syncMem = mSyncMem;
536     }
537 
538     if (outputIgbp && generation == outputGeneration) {
539         auto syncVar = syncMem ? syncMem->mem() : nullptr;
540         if (syncVar) {
541             syncVar->lock();
542             if (consumerAttachCount && *consumerAttachCount > 0) {
543                 (*consumerAttachCount)--;
544             } else {
545                 syncVar->notifyQueuedLocked();
546             }
547             syncVar->unlock();
548         }
549     }
550 }
551 
onBufferAttached(uint32_t generation)552 void OutputBufferQueue::onBufferAttached(uint32_t generation) {
553     std::shared_ptr<C2SurfaceSyncMemory> syncMem;
554     sp<IGraphicBufferProducer> outputIgbp;
555     uint32_t outputGeneration = 0;
556     std::shared_ptr<int> consumerAttachCount;
557     {
558         std::unique_lock<std::mutex> l(mMutex);
559         if (mStopped) {
560             return;
561         }
562         outputIgbp = mIgbp;
563         outputGeneration = mGeneration;
564         consumerAttachCount = mConsumerAttachCount;
565         syncMem = mSyncMem;
566     }
567 
568     if (outputIgbp && generation == outputGeneration) {
569         auto syncVar = syncMem ? syncMem->mem() : nullptr;
570         if (syncVar) {
571             syncVar->lock();
572             if (consumerAttachCount) {
573                 (*consumerAttachCount)++;
574             }
575             syncVar->unlock();
576         }
577     }
578 }
579 
pollForRenderedFrames(FrameEventHistoryDelta * delta)580 void OutputBufferQueue::pollForRenderedFrames(FrameEventHistoryDelta* delta) {
581     if (mIgbp) {
582         mIgbp->getFrameTimestamps(delta);
583     }
584 }
585 
holdBufferQueueBlocks(const std::list<std::unique_ptr<C2Work>> & workList)586 void OutputBufferQueue::holdBufferQueueBlocks(
587         const std::list<std::unique_ptr<C2Work>>& workList) {
588     forEachBlock(workList,
589                  std::bind(&OutputBufferQueue::registerBuffer,
590                            this, std::placeholders::_1));
591 }
592 
updateMaxDequeueBufferCount(int maxDequeueBufferCount)593 void OutputBufferQueue::updateMaxDequeueBufferCount(int maxDequeueBufferCount) {
594     mMutex.lock();
595     mMaxDequeueBufferCount = maxDequeueBufferCount;
596     auto syncVar = mSyncMem ? mSyncMem->mem() : nullptr;
597     if (syncVar && !mStopped) {
598         syncVar->lock();
599         syncVar->updateMaxDequeueCountLocked(maxDequeueBufferCount);
600         syncVar->unlock();
601     }
602     mMutex.unlock();
603     ALOGD("set max dequeue count %d from update", maxDequeueBufferCount);
604 }
605 
606 }  // namespace c2
607 }  // namespace media
608 }  // namespace hardware
609 }  // namespace android
610