Bug 1353459 - handle queueInputBuffer exceptions. r=esawin. a=gchang
authorJohn Lin <jolin@mozilla.com>
Tue, 18 Apr 2017 17:59:28 +0800
changeset 375968 7595a01c76d1
parent 375967 3bab94261ee0
child 375969 de3b2daf03b4
push id11069
push userihsiao@mozilla.com
push dateTue, 18 Apr 2017 10:00:59 +0000
treeherdermozilla-aurora@7595a01c76d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin, gchang
bugs1353459
milestone54.0a2
Bug 1353459 - handle queueInputBuffer exceptions. r=esawin. a=gchang MozReview-Commit-ID: 1IgLfpmGnN3
mobile/android/base/java/org/mozilla/gecko/media/Codec.java
mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
--- a/mobile/android/base/java/org/mozilla/gecko/media/Codec.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/Codec.java
@@ -142,25 +142,28 @@ import java.util.concurrent.ConcurrentLi
                         sample.writeToByteBuffer(buf);
                     } catch (IOException e) {
                         e.printStackTrace();
                         len = 0;
                     }
                     mSamplePool.recycleInput(sample);
                 }
 
-                if (cryptoInfo != null && len > 0) {
-                    mCodec.queueSecureInputBuffer(index, 0, cryptoInfo, pts, flags);
-                } else {
-                    mCodec.queueInputBuffer(index, 0, len, pts, flags);
-                }
                 try {
+                    if (cryptoInfo != null && len > 0) {
+                        mCodec.queueSecureInputBuffer(index, 0, cryptoInfo, pts, flags);
+                    } else {
+                        mCodec.queueInputBuffer(index, 0, len, pts, flags);
+                    }
                     mCallbacks.onInputQueued(pts);
                 } catch (RemoteException e) {
                     e.printStackTrace();
+                } catch (Exception e) {
+                    reportError(Error.FATAL, e);
+                    return;
                 }
             }
             reportPendingInputs();
         }
 
         private void reportPendingInputs() {
             try {
                 for (Input i : mInputSamples) {
@@ -506,17 +509,21 @@ import java.util.concurrent.ConcurrentLi
         } catch (Exception e) {
             // Translate allocation error to remote exception.
             throw new RemoteException(e.getMessage());
         }
     }
 
     @Override
     public synchronized void queueInput(Sample sample) throws RemoteException {
-        mInputProcessor.onSample(sample);
+        try {
+            mInputProcessor.onSample(sample);
+        } catch (Exception e) {
+            throw new RemoteException(e.getMessage());
+        }
     }
 
     @Override
     public synchronized void releaseOutput(Sample sample, boolean render) {
         try {
             mOutputProcessor.onRelease(sample, render);
         } catch (Exception e) {
             reportError(Error.FATAL, e);
--- a/mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
@@ -182,17 +182,17 @@ public final class CodecProxy {
         mCallbacks.setEndOfInput(eos);
 
         if (eos) {
             return sendInput(Sample.EOS);
         }
 
         try {
             return sendInput(mRemote.dequeueInput(info.size).set(bytes, info, cryptoInfo));
-        } catch (RemoteException e) {
+        } catch (RemoteException | NullPointerException e) {
             Log.e(LOGTAG, "fail to dequeue input buffer", e);
             return false;
         } catch (IOException e) {
             Log.e(LOGTAG, "fail to copy input data.", e);
             // Balance dequeue/queue.
             return sendInput(null);
         }
     }