Free mediacodec resources on stream quit

This commit is contained in:
Patrick Nicolas committed 2024-04-28 18:21:25 +02:00
1 parent dfa74c2f98
commit 62d74db3dc
1 file changed
+9
@@ -253,6 +253,8 @@ decoder::decoder(
try
{
auto index = output_buffers.pop();
if (index == -1)
return;
auto status = AMediaCodec_releaseOutputBuffer(media_codec.get(), index, true);
// will trigger on_image_available through ImageReader
if (status != AMEDIA_OK)
@@ -273,6 +275,13 @@ decoder::decoder(
decoder::~decoder()
{
if (media_codec)
{
AMediaCodec_stop(media_codec.get());
output_buffers.push(-1);
if (output_releaser.joinable())
output_releaser.join();
}
input_buffers.close();
output_buffers.close();