|
|
|
@ -223,7 +223,6 @@ private:
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (!transResult.isOk() || status != android::OK) {
|
|
|
|
|
ALOGD("cannot dequeue buffer %d", status);
|
|
|
|
|
if (transResult.isOk()) {
|
|
|
|
|
if (status == android::INVALID_OPERATION ||
|
|
|
|
|
status == android::TIMED_OUT ||
|
|
|
|
@ -233,6 +232,7 @@ private:
|
|
|
|
|
return C2_BLOCKING;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ALOGD("cannot dequeue buffer %d", status);
|
|
|
|
|
return C2_BAD_VALUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -355,39 +355,31 @@ public:
|
|
|
|
|
return mInit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int kMaxIgbpRetry = 20; // TODO: small number can cause crash in releasing.
|
|
|
|
|
static int kMaxIgbpRetryDelayUs = 10000;
|
|
|
|
|
|
|
|
|
|
int curTry = 0;
|
|
|
|
|
|
|
|
|
|
while (curTry++ < kMaxIgbpRetry) {
|
|
|
|
|
std::unique_lock<std::mutex> lock(mMutex);
|
|
|
|
|
// TODO: return C2_NO_INIT
|
|
|
|
|
if (mProducerId == 0) {
|
|
|
|
|
std::shared_ptr<C2GraphicAllocation> alloc;
|
|
|
|
|
c2_status_t err = mAllocator->newGraphicAllocation(
|
|
|
|
|
width, height, format, usage, &alloc);
|
|
|
|
|
if (err != C2_OK) {
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
std::shared_ptr<C2BufferQueueBlockPoolData> poolData =
|
|
|
|
|
std::make_shared<C2BufferQueueBlockPoolData>(
|
|
|
|
|
0, (uint64_t)0, ~0, shared_from_this());
|
|
|
|
|
// TODO: config?
|
|
|
|
|
*block = _C2BlockFactory::CreateGraphicBlock(alloc, poolData);
|
|
|
|
|
ALOGV("allocated a buffer successfully");
|
|
|
|
|
|
|
|
|
|
return C2_OK;
|
|
|
|
|
std::unique_lock<std::mutex> lock(mMutex);
|
|
|
|
|
if (mProducerId == 0) {
|
|
|
|
|
std::shared_ptr<C2GraphicAllocation> alloc;
|
|
|
|
|
c2_status_t err = mAllocator->newGraphicAllocation(
|
|
|
|
|
width, height, format, usage, &alloc);
|
|
|
|
|
if (err != C2_OK) {
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
c2_status_t status = fetchFromIgbp_l(width, height, format, usage, block);
|
|
|
|
|
if (status == C2_BLOCKING) {
|
|
|
|
|
lock.unlock();
|
|
|
|
|
::usleep(kMaxIgbpRetryDelayUs);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return status;
|
|
|
|
|
std::shared_ptr<C2BufferQueueBlockPoolData> poolData =
|
|
|
|
|
std::make_shared<C2BufferQueueBlockPoolData>(
|
|
|
|
|
0, (uint64_t)0, ~0, shared_from_this());
|
|
|
|
|
*block = _C2BlockFactory::CreateGraphicBlock(alloc, poolData);
|
|
|
|
|
ALOGV("allocated a buffer successfully");
|
|
|
|
|
|
|
|
|
|
return C2_OK;
|
|
|
|
|
}
|
|
|
|
|
c2_status_t status = fetchFromIgbp_l(width, height, format, usage, block);
|
|
|
|
|
if (status == C2_BLOCKING) {
|
|
|
|
|
lock.unlock();
|
|
|
|
|
// in order not to drain cpu from component's spinning
|
|
|
|
|
::usleep(kMaxIgbpRetryDelayUs);
|
|
|
|
|
}
|
|
|
|
|
return C2_BLOCKING;
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setRenderCallback(const OnRenderCallback &renderCallback) {
|
|
|
|
|