MediaCodec: release all output buffers on release

This prevents leaking video memory
This commit is contained in:
Julian Winkler
2024-11-06 23:25:28 +01:00
parent fc0091a989
commit 7c9a32d041
2 changed files with 15 additions and 1 deletions

View File

@@ -147,8 +147,15 @@ public class MediaCodec {
public void release() {
System.out.println("MediaCodec.release(): codecName=" + codecName);
if (native_codec != 0)
if (native_codec != 0) {
if (outputBuffers != null) {
for (int i=0; i<outputBuffers.length; i++) {
if (!freeOutputBuffers.contains(i))
releaseOutputBuffer(i, false);
}
}
native_release(native_codec);
}
native_codec = 0;
}