From 6f0fdac6f16880ef46cbcfb399fd6beec5afe735 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Thu, 6 Jul 2017 10:49:54 -0700 Subject: vo: add VO_CAP_NOREDRAW for upcoming vo_mediacodec_embed MediaCodec uses a fixed number of output buffers to hold frames, and expects that output buffers will be released as soon as possible. Once rendered, the underlying frame is automatically released and cannot be reused or rerendered. The new VO_CAP_NOREDRAW forces mpv to release frames immediately after they are rendered or dropped, to ensure that MediaCodec decoder does not run out of buffers and stall out. --- video/out/vo.c | 7 ++++++- video/out/vo.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/video/out/vo.c b/video/out/vo.c index d761300a47..6f0dbb3d33 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -882,6 +882,11 @@ static bool render_frame(struct vo *vo) update_vsync_timing_after_swap(vo); } + if (vo->driver->caps & VO_CAP_NOREDRAW) { + talloc_free(in->current_frame); + in->current_frame = NULL; + } + if (in->dropped_frame) { MP_STATS(vo, "drop-vo"); } else { @@ -903,7 +908,7 @@ static void do_redraw(struct vo *vo) { struct vo_internal *in = vo->in; - if (!vo->config_ok) + if (!vo->config_ok || (vo->driver->caps & VO_CAP_NOREDRAW)) return; pthread_mutex_lock(&in->lock); diff --git a/video/out/vo.h b/video/out/vo.h index 50f6e4942e..fc6cf394e4 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -172,6 +172,8 @@ enum { VO_CAP_ROTATE90 = 1 << 0, // VO does framedrop itself (vo_vdpau). Untimed/encoding VOs never drop. VO_CAP_FRAMEDROP = 1 << 1, + // VO does not support redraws (vo_mediacodec_embed). + VO_CAP_NOREDRAW = 1 << 2, }; #define VO_MAX_REQ_FRAMES 10 -- cgit v1.2.3