[FFmpeg-devel] avcodec/mediacodecdec: fix immediate EAGAIN with buffered packet

Submitted by Aman Gupta on March 13, 2018, 9:46 a.m.

Details

Message ID 20180313094657.12332-1-ffmpeg@tmm1.net
State Accepted
Commit 3172b31223e1f0a64233fa5b355e11d7a00e477b
Headers show

Commit Message

Aman Gupta March 13, 2018, 9:46 a.m.
From: Aman Gupta <aman@tmm1.net>

In cases where the mediacodec decoder consumed a partial packet,
receive_frame() would start returning EAGAIN if the rest of the
packet couldn't be flushed and no frames were immediately available.

This fixes receive_frame() to perform its normal blocking wait for
new frames before returning EAGAIN. Fixes an issue I could reproduce
fairly often on a FireOS 6 device, and reported to be happening
intermittently by two mpv users.
---
 libavcodec/mediacodecdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matthieu Bouron March 13, 2018, 3:32 p.m.
On Tue, Mar 13, 2018 at 02:46:57AM -0700, Aman Gupta wrote:
> From: Aman Gupta <aman@tmm1.net>
> 
> In cases where the mediacodec decoder consumed a partial packet,
> receive_frame() would start returning EAGAIN if the rest of the
> packet couldn't be flushed and no frames were immediately available.
> 
> This fixes receive_frame() to perform its normal blocking wait for
> new frames before returning EAGAIN. Fixes an issue I could reproduce
> fairly often on a FireOS 6 device, and reported to be happening
> intermittently by two mpv users.
> ---
>  libavcodec/mediacodecdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
> index 89d2421ae9..0d4a853f07 100644
> --- a/libavcodec/mediacodecdec.c
> +++ b/libavcodec/mediacodecdec.c
> @@ -452,7 +452,7 @@ static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
>  
>      /* skip fetching new packet if we still have one buffered */
>      if (s->buffered_pkt.size > 0)
> -        return AVERROR(EAGAIN);
> +        return mediacodec_send_receive(avctx, s, frame, true);
>  
>      /* fetch new packet or eof */
>      ret = ff_decode_get_packet(avctx, &s->buffered_pkt);
> -- 
> 2.14.2
> 

LGTM.

Patch hide | download patch | download mbox

diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 89d2421ae9..0d4a853f07 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -452,7 +452,7 @@  static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
 
     /* skip fetching new packet if we still have one buffered */
     if (s->buffered_pkt.size > 0)
-        return AVERROR(EAGAIN);
+        return mediacodec_send_receive(avctx, s, frame, true);
 
     /* fetch new packet or eof */
     ret = ff_decode_get_packet(avctx, &s->buffered_pkt);