本文整理汇总了C++中sp::cancelBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::cancelBuffer方法的具体用法?C++ sp::cancelBuffer怎么用?C++ sp::cancelBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::cancelBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepareBuffer
status_t GuiExtPoolItem::prepareBuffer(sp<IGraphicBufferProducer> producer, uint32_t usage, uint32_t type, uint32_t gralloc_usage, uint32_t bufNum)
{
status_t err = NO_ERROR;
uint32_t usg = (gralloc_usage & GRALLOC_USAGE_SECURE) != 0 ? (LOCK_FOR_USAGE | GRALLOC_USAGE_SECURE) : LOCK_FOR_USAGE;
uint32_t fmt = gAcquiredFormat[usage];
GUIEXT_LOGV("prepareBuffer, type=%d, fmt=%x, usage=%x, usg=%x, bufNum=%d", usage, fmt, gralloc_usage, usg, bufNum);
for (uint32_t i = 0; i < bufNum; i++) {
int buf = -1;
sp<Fence> fence;
producer->dequeueBuffer(&buf, &fence, false, 0, 0, fmt, usg);
uint32_t combine_id = POOL_COMBINED_ID(usage, type, i);
sp<ConsumerSlot> consumerSlot = mConsumerList.valueFor(combine_id);
if (consumerSlot == 0) {
sp<ConsumerSlot> slot = new ConsumerSlot();
slot->token = NULL;
slot->pid = -1;
slot->usage = usage;
slot->type = type;
slot->idx = i;
mConsumerList.add(combine_id, slot);
}
#ifdef TOUCH_ION_BUFFER
sp<GraphicBuffer> gb;
producer->requestBuffer(buf, &gb);
touchIonBuffer(gb);
#endif
}
for (uint32_t i = 0; i < bufNum; i++) {
sp<Fence> fence = Fence::NO_FENCE;
producer->cancelBuffer(i, fence);
}
return err;
}
示例2: main
//.........这里部分代码省略.........
err = native_window_set_buffer_count(mNativeWindow.get(), outputQueueCapacity);
if (err != 0) {
fprintf(stderr, "native_window_set_buffer_count failed: %s (%d)", strerror(-err), -err);
return -1;
}
//queue buffs
for (uint32_t i = 0; i < outputQueueCapacity; i++) {
ANativeWindowBuffer* pbuf = NULL;
memset(&buffer, 0, sizeof(buffer));
err = native_window_dequeue_buffer_and_wait(mNativeWindow.get(), &pbuf);
if (err != 0) {
fprintf(stderr, "dequeueBuffer failed: %s (%d)\n", strerror(-err), -err);
return -1;
}
buffer.m.userptr = (unsigned long)pbuf;
buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
buffer.index = i;
ioctlRet = SIMULATE_V4L2_OP(Ioctl)(fd, VIDIOC_QBUF, &buffer);
ASSERT(ioctlRet != -1);
mWindBuff.push_back(pbuf);
}
for (uint32_t i = 0; i < minUndequeuedBuffs; i++) {
memset(&buffer, 0, sizeof(buffer));
buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
ioctlRet = SIMULATE_V4L2_OP(Ioctl)(fd, VIDIOC_DQBUF, &buffer);
ASSERT(ioctlRet != -1);
err = mNativeWindow->cancelBuffer(mNativeWindow.get(), mWindBuff[buffer.index], -1);
if (err) {
fprintf(stderr, "queue empty window buffer error\n");
return -1;
}
}
#endif
// output port starts as late as possible to adopt user provide output buffer
type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
ioctlRet = SIMULATE_V4L2_OP(Ioctl)(fd, VIDIOC_STREAMON, &type);
ASSERT(ioctlRet != -1);
bool event_pending=true; // try to get video resolution.
int dqCountAfterEOS = 0;
do {
if (event_pending) {
handleResolutionChange(fd);
}
takeOneOutputFrame(fd);
if (!feedOneInputFrame(input, fd)) {
if (stagingBufferInDevice == 0)
break;
dqCountAfterEOS++;
}
if (dqCountAfterEOS == inputQueueCapacity) // input drain
break;
} while (SIMULATE_V4L2_OP(Poll)(fd, true, &event_pending) == 0);
// drain output buffer
int retry = 3;
while (takeOneOutputFrame(fd) || (--retry)>0) { // output drain