Bug 1353459 - handle queueInputBuffer exceptions. r?esawin draft
authorJohn Lin <jolin@mozilla.com>
Tue, 11 Apr 2017 16:26:12 +0800
changeset 561232 b6518984559ab8319a4a4d7b24f1c9cd0725fa20
parent 561003 33c2a23d642d4a66dbf650794fe045777499c3bd
child 623907 4501d0fb9682a6787880e1c05f9362e20b19eba1
push id53657
push userbmo:jolin@mozilla.com
push dateWed, 12 Apr 2017 09:46:13 +0000
reviewersesawin
bugs1353459
milestone55.0a1
Bug 1353459 - handle queueInputBuffer exceptions. r?esawin MozReview-Commit-ID: 1Tm0vcl3Uv7
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java
+++ b/mobile/android/geckoview/src/main/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 setRates(int newBitRate) {
         try {
             mCodec.setRates(newBitRate);
         } catch (Exception e) {
             reportError(Error.FATAL, e);
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java
@@ -188,17 +188,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);
         }
     }