stagefright: reuse buffers instead of cloning
In buffer array mode, the buffer reference is kept in clients of
MediaCodec, so allocating new buffer for new input/output does not
work in that case.
Bug: 32577275
Bug: 32579231
Test: use screenrecord and investigate the output file.
Test: cts-tradefed run cts-dev -m CtsMediaTestCases -t android.media.cts.EncodeDecodeTest
Change-Id: I26d89f6b5735094062b8a2027bcab4754576d574
diff --git a/media/libmedia/MediaCodecBuffer.cpp b/media/libmedia/MediaCodecBuffer.cpp
index 2af31d0..59d6164 100644
--- a/media/libmedia/MediaCodecBuffer.cpp
+++ b/media/libmedia/MediaCodecBuffer.cpp
@@ -80,8 +80,9 @@
return mFormat;
}
-sp<MediaCodecBuffer> MediaCodecBuffer::clone(const sp<AMessage> &format) {
- return new MediaCodecBuffer(format, mBuffer);
+void MediaCodecBuffer::setFormat(const sp<AMessage> &format) {
+ mMeta->clear();
+ mFormat = format;
}
} // namespace android