mediacodec: try to return an output frame if we failed to get an available input...
authorFelix Abecassis <felix.abecassis@gmail.com>
Mon, 4 Nov 2013 15:17:47 +0000 (16:17 +0100)
committerMartin Storsjö <martin@martin.st>
Mon, 4 Nov 2013 19:56:40 +0000 (21:56 +0200)
Previously we would only return one frame even if multiple output
frames were available, dropping all but the last one, while waiting
for a free input buffer. Instead return the first output buffer
and don't consume the input buffer at all in that case.

Signed-off-by: Martin Storsjö <martin@martin.st>
modules/codec/omxil/android_mediacodec.c

index fb435b4..c078b2b 100644 (file)
@@ -536,7 +536,16 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t **pp_block)
     while (true) {
         int index = (*env)->CallIntMethod(env, p_sys->codec, p_sys->dequeue_input_buffer, timeout);
         if (index < 0) {
-            GetOutput(p_dec, env, &p_pic, timeout > 0);
+            GetOutput(p_dec, env, &p_pic, 0);
+            if (p_pic) {
+                /* If we couldn't get an available input buffer but a
+                 * decoded frame is available, we return the frame
+                 * without assigning NULL to *pp_block. The next call
+                 * to DecodeVideo will try to send the input packet again.
+                 */
+                (*myVm)->DetachCurrentThread(myVm);
+                return p_pic;
+            }
             timeout = 30;
             continue;
         }