Bail out early in case of error

Otherwise the test will loop until CTS times out after 10 minutes,
and there will be no useful information in the logs anymore.

This is for tracking down the cause of b/9105408

Change-Id: I99c676880c247b5060eeeb1b950508ec57a70d60
diff --git a/tests/tests/media/src/android/media/cts/DecoderTest.java b/tests/tests/media/src/android/media/cts/DecoderTest.java
index 231bd83..4700d85 100644
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -161,7 +161,9 @@
         MediaCodec.BufferInfo info = new MediaCodec.BufferInfo();
         boolean sawInputEOS = false;
         boolean sawOutputEOS = false;
-        while (!sawOutputEOS) {
+        int noOutputCounter = 0;
+        while (!sawOutputEOS && noOutputCounter < 50) {
+            noOutputCounter++;
             if (!sawInputEOS) {
                 int inputBufIndex = codec.dequeueInputBuffer(kTimeOutUs);
 
@@ -199,6 +201,9 @@
             if (res >= 0) {
                 //Log.d(TAG, "got frame, size " + info.size + "/" + info.presentationTimeUs);
 
+                if (info.size > 0) {
+                    noOutputCounter = 0;
+                }
                 if (info.size > 0 && reconfigure) {
                     // once we've gotten some data out of the decoder, reconfigure it again
                     reconfigure = false;