Bug 1340582 - Handle shared memory allocation failure. r=jchen, a=gchang
authorJohn Lin <jolin@mozilla.com>
Wed, 22 Feb 2017 22:14:00 -0500
changeset 378669 491f9e0666e7070ac5b30ad37392a02d88efc355
parent 378668 3383ac0e02e1a0c308c1e5c0f67e2796d54541f5
child 378670 66a3b90442dde8b43aeebd559268d524c03d917c
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen, gchang
bugs1340582
milestone53.0a2
Bug 1340582 - Handle shared memory allocation failure. r=jchen, a=gchang MozReview-Commit-ID: BMObK2OU8FV
dom/media/platforms/android/RemoteDataDecoder.cpp
mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -623,12 +623,14 @@ RemoteDataDecoder::Input(MediaRawData* a
   BufferInfo::LocalRef bufferInfo;
   nsresult rv = BufferInfo::New(&bufferInfo);
   if (NS_FAILED(rv)) {
     mCallback->Error(MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__));
     return;
   }
   bufferInfo->Set(0, aSample->Size(), aSample->mTime, 0);
 
-  mJavaDecoder->Input(bytes, bufferInfo, GetCryptoInfoFromSample(aSample));
+  if (!mJavaDecoder->Input(bytes, bufferInfo, GetCryptoInfoFromSample(aSample))) {
+    mCallback->Error(MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__));
+  }
 }
 
 } // mozilla
--- a/mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
@@ -172,39 +172,34 @@ public final class CodecProxy {
         }
         try {
             Sample sample = processInput(bytes, info, cryptoInfo);
             if (sample == null) {
                 return false;
             }
             mRemote.queueInput(sample);
             sample.dispose();
-        } catch (RemoteException e) {
-            e.printStackTrace();
+        } catch (RemoteException | IOException e) {
             Log.e(LOGTAG, "fail to input sample: size=" + info.size +
                     ", pts=" + info.presentationTimeUs +
-                    ", flags=" + Integer.toHexString(info.flags));
+                    ", flags=" + Integer.toHexString(info.flags), e);
             return false;
         }
 
         return true;
     }
 
-    private Sample processInput(ByteBuffer bytes, BufferInfo info, CryptoInfo cryptoInfo) throws RemoteException {
+    private Sample processInput(ByteBuffer bytes, BufferInfo info, CryptoInfo cryptoInfo)
+            throws RemoteException, IOException {
         if (info.flags == MediaCodec.BUFFER_FLAG_END_OF_STREAM) {
             mCallbacks.setEndOfInput(true);
             return Sample.EOS;
         } else {
             mCallbacks.setEndOfInput(false);
-            try {
-                return mRemote.dequeueInput(info.size).set(bytes, info, cryptoInfo);
-            } catch (IOException e) {
-                e.printStackTrace();
-                return null;
-            }
+            return mRemote.dequeueInput(info.size).set(bytes, info, cryptoInfo);
         }
     }
 
     @WrapForJNI
     public synchronized boolean flush() {
         if (mRemote == null) {
             Log.e(LOGTAG, "cannot flush an ended codec");
             return false;