Small performance optimization by only blocking on an input buffer if we've already got a DU

This commit is contained in:
Cameron Gutman 2014-10-09 19:05:57 -07:00
parent 47d47afd73
commit 8403101d0f

View File

@ -327,9 +327,10 @@ public class MediaCodecDecoderRenderer implements VideoDecoderRenderer {
// frames out of the other end. // frames out of the other end.
if (inputIndex == -1) { if (inputIndex == -1) {
try { try {
// Wait for 3 milliseconds at maximum before continuing to // If we've got a DU waiting to be given to the decoder,
// grab a DU or render a frame // wait a full 3 ms for an input buffer. Otherwise
inputIndex = videoDecoder.dequeueInputBuffer(3000); // just see if we can get one immediately.
inputIndex = videoDecoder.dequeueInputBuffer(du != null ? 3000 : 0);
} catch (Exception e) { } catch (Exception e) {
throw new RendererException(MediaCodecDecoderRenderer.this, e); throw new RendererException(MediaCodecDecoderRenderer.this, e);
} }