Skip to content
Snippets Groups Projects
Commit 32fc3471 authored by Chih-Yu Huang's avatar Chih-Yu Huang
Browse files

V4L2Decoder: respect the number of output buffers from V4L2 driver

When we allocate V4L2 output buffers, the driver might change the
number of buffers. This CL respects the number of buffers from V4L2
driver, instead of using the original requested number.

Bug: 202923667
Test: pass e2e test

Change-Id: Ic0d8e34014a0e3015bb995026f4b17f50c6b578e
parent 78318668
No related branches found
No related tags found
No related merge requests found
...@@ -529,10 +529,13 @@ bool V4L2Decoder::changeResolution() { ...@@ -529,10 +529,13 @@ bool V4L2Decoder::changeResolution() {
mFrameAtDevice.clear(); mFrameAtDevice.clear();
mBlockIdToV4L2Id.clear(); mBlockIdToV4L2Id.clear();
if (mOutputQueue->allocateBuffers(*numOutputBuffers, V4L2_MEMORY_DMABUF) == 0) { const size_t adjustedNumOutputBuffers =
mOutputQueue->allocateBuffers(*numOutputBuffers, V4L2_MEMORY_DMABUF);
if (adjustedNumOutputBuffers == 0) {
ALOGE("Failed to allocate output buffer."); ALOGE("Failed to allocate output buffer.");
return false; return false;
} }
ALOGV("Allocated %zu output buffers.", adjustedNumOutputBuffers);
if (!mOutputQueue->streamon()) { if (!mOutputQueue->streamon()) {
ALOGE("Failed to streamon output queue."); ALOGE("Failed to streamon output queue.");
return false; return false;
...@@ -542,7 +545,8 @@ bool V4L2Decoder::changeResolution() { ...@@ -542,7 +545,8 @@ bool V4L2Decoder::changeResolution() {
// exists at the same time. // exists at the same time.
mVideoFramePool.reset(); mVideoFramePool.reset();
// Always use flexible pixel 420 format YCBCR_420_888 in Android. // Always use flexible pixel 420 format YCBCR_420_888 in Android.
mVideoFramePool = mGetPoolCb.Run(mCodedSize, HalPixelFormat::YCBCR_420_888, *numOutputBuffers); mVideoFramePool =
mGetPoolCb.Run(mCodedSize, HalPixelFormat::YCBCR_420_888, adjustedNumOutputBuffers);
if (!mVideoFramePool) { if (!mVideoFramePool) {
ALOGE("Failed to get block pool with size: %s", toString(mCodedSize).c_str()); ALOGE("Failed to get block pool with size: %s", toString(mCodedSize).c_str());
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment