ffmpeg | branch: master | sfan5 <sf...@live.de> | Wed Aug 7 17:48:06 2024 +0200| [c779766b5cb940fdf2170c1ad12eacaf62eaf1d0] | committer: Matthieu Bouron
avcodec/mediacodecdec: call MediaCodec.stop on close Usually the MediaCodec context will be released immediately, or it needs to stay alive due to existing hardware buffers. However we can free resources early in the case of hw_buffer_count == 0 && refcount > 1, which can be reproduced by keeping frames referenced after flushing and closing. mpv currently behaves like this. Signed-off-by: sfan5 <sf...@live.de> Signed-off-by: Matthieu Bouron <matthieu.bou...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c779766b5cb940fdf2170c1ad12eacaf62eaf1d0 --- libavcodec/mediacodecdec_common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index d6f91e6e89..c888dea8cf 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -841,6 +841,18 @@ int ff_mediacodec_dec_flush(AVCodecContext *avctx, MediaCodecDecContext *s) int ff_mediacodec_dec_close(AVCodecContext *avctx, MediaCodecDecContext *s) { + if (!s) + return 0; + + if (s->codec) { + if (atomic_load(&s->hw_buffer_count) == 0) { + ff_AMediaCodec_stop(s->codec); + av_log(avctx, AV_LOG_DEBUG, "MediaCodec %p stopped\n", s->codec); + } else { + av_log(avctx, AV_LOG_DEBUG, "Not stopping MediaCodec (there are buffers pending)\n"); + } + } + ff_mediacodec_dec_unref(s); return 0; _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".