mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2025-01-09 08:22:00 +00:00
The timeout mechanism is added in RequestBuffer when there is no buffer to use
Signed-off-by: BruceXuXu <xufeilong2@huawei.com>
This commit is contained in:
parent
cf7120d6e7
commit
407207d69b
@ -184,8 +184,8 @@ GSError BufferQueue::RequestBuffer(const BufferRequestConfig &config, BufferExtr
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
// dequeue from free list
|
||||
std::lock_guard<std::mutex> lockGuard(mutex_);
|
||||
sptr<SurfaceBufferImpl> bufferImpl = SurfaceBufferImpl::FromBase(retval.buffer);
|
||||
ret = PopFromFreeList(bufferImpl, config);
|
||||
if (ret == GSERROR_OK) {
|
||||
@ -195,8 +195,17 @@ GSError BufferQueue::RequestBuffer(const BufferRequestConfig &config, BufferExtr
|
||||
|
||||
// check queue size
|
||||
if (GetUsedSize() >= GetQueueSize()) {
|
||||
BLOGN_FAILURE("all buffer are using");
|
||||
return GSERROR_NO_BUFFER;
|
||||
std::condition_variable con;
|
||||
con.wait_for(lock, std::chrono::milliseconds(config.timeout));
|
||||
// try dequeue from free list again
|
||||
ret = PopFromFreeList(bufferImpl, config);
|
||||
if (ret == GSERROR_OK) {
|
||||
retval.buffer = bufferImpl;
|
||||
return ReuseBuffer(config, bedata, retval);
|
||||
} else {
|
||||
BLOGN_FAILURE("all buffer are using");
|
||||
return GSERROR_NO_BUFFER;
|
||||
}
|
||||
}
|
||||
|
||||
ret = AllocBuffer(bufferImpl, config);
|
||||
|
Loading…
Reference in New Issue
Block a user