Skip to content

Commit

Permalink
codec2: fix issue in allocating too many 8k buffers
Browse files Browse the repository at this point in the history
default output delay is too large, in 8k use case, framework doesn't
allow to use so much memory to allocate those 8k buffers.

if exceeds max capacity and underlying buffer alloc fail. do not
create MediaCodecBuffer holds a null underlying ABuffer. Otherwise,
some MediaCodecBuffer APIs may access ABuffer (nullptr).

Bug: b/208481412
Change-Id: Ic8e33f6c27ee1c435bf0dc4bc09df87cb0ad3c3a
  • Loading branch information
Jiajia Cong authored and thestinger committed Sep 18, 2023
1 parent 75fc175 commit b023ec3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions media/codec2/sfplugin/Codec2Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,10 @@ sp<ConstGraphicBlockBuffer> ConstGraphicBlockBuffer::AllocateEmpty(
}
}
sp<ABuffer> aBuffer(alloc(align(width, 16) * align(height, 16) * bpp / 8));
if (aBuffer == nullptr) {
ALOGD("%s: failed to allocate buffer", __func__);
return nullptr;
}
return new ConstGraphicBlockBuffer(
format,
aBuffer,
Expand Down

0 comments on commit b023ec3

Please sign in to comment.