vlc | branch: master | Thomas Guillem <tho...@gllm.fr> | Tue Mar 31 07:22:48 2015 +0000| [008a2122acf9d8d544c1540298970a1169e2ac41] | committer: Jean-Baptiste Kempf
mediacodec: don't wait indefinitely for data The decoder can be in a bad state without throwing any exception. Issue seen with a MPEG4 sample on a Tegra 3 and Tegra K1 tablet but may happens on others devices/samples. Signed-off-by: Jean-Baptiste Kempf <j...@videolan.org> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=008a2122acf9d8d544c1540298970a1169e2ac41 --- modules/codec/omxil/android_mediacodec.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c index aa90cc4..adf88e2 100644 --- a/modules/codec/omxil/android_mediacodec.c +++ b/modules/codec/omxil/android_mediacodec.c @@ -1087,6 +1087,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t **pp_block) p_dec->fmt_out.video.i_sar_den = p_dec->fmt_in.video.i_sar_den; } + unsigned int i_attempts = 0; jlong timeout = 0; int i_output_ret = 0; int i_input_ret = 0; @@ -1123,12 +1124,22 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t **pp_block) if (i_output_ret == -1) { p_sys->error_state = true; break; - } else if (i_output_ret == 0 && p_pic) { - picture_Release(p_pic); - p_pic = NULL; + } else if (i_output_ret == 0) { + if (p_pic) { + picture_Release(p_pic); + p_pic = NULL; + } else if (++i_attempts > 100) { + /* No p_pic, so no pixel_format, thereforce mediacodec + * didn't produce any output or events yet. Don't wait + * indefinitely and abort after 2seconds (100 * 2 * 10ms) + * without any data. Indeed, MediaCodec can fail without + * throwing any exception or error returns... */ + p_sys->error_state = true; + break; + } } } - timeout = 10 * 1000; + timeout = 10 * 1000; // 10 ms } endclean: _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits