Merge m-c to m-i
authorPhil Ringnalda <philringnalda@gmail.com>
Thu, 23 Feb 2017 22:31:18 -0800
changeset 373693 395af43e7b9c68903f594698a9c3b6bc982ccb4b
parent 373692 77b0ddb1fd71b626f023f70c5c64b85bdc310617 (current diff)
parent 373512 69d2cf007cdc13cf2bd33370b1732d4f969fd9af (diff)
child 373694 f199785e14a4f948f6c5d525feb8f4cf2519caaa
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone54.0a1
Merge m-c to m-i
--- a/mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
@@ -35,56 +35,49 @@ public final class CodecProxy {
 
     public interface Callbacks {
         void onInputExhausted();
         void onOutputFormatChanged(MediaFormat format);
         void onOutput(Sample output);
         void onError(boolean fatal);
     }
 
-    private static Callbacks sNoOpCallbacks = new Callbacks() {
-        public void onInputExhausted() { }
-        public void onOutputFormatChanged(MediaFormat format) { }
-        public void onOutput(Sample output) { output.dispose(); }
-        public void onError(boolean fatal) { }
-    };
-
     @WrapForJNI
     public static class NativeCallbacks extends JNIObject implements Callbacks {
         public native void onInputExhausted();
         public native void onOutputFormatChanged(MediaFormat format);
         public native void onOutput(Sample output);
         public native void onError(boolean fatal);
 
         @Override // JNIObject
         protected native void disposeNative();
     }
 
     private class CallbacksForwarder extends ICodecCallbacks.Stub {
-        private Callbacks mCallbacks;
+        private final Callbacks mCallbacks;
         private boolean mEndOfInput;
 
         CallbacksForwarder(Callbacks callbacks) {
             mCallbacks = callbacks;
         }
 
         @Override
-        public synchronized void onInputExhausted() throws RemoteException {
+        public void onInputExhausted() throws RemoteException {
             if (!mEndOfInput) {
                 mCallbacks.onInputExhausted();
             }
         }
 
         @Override
-        public synchronized void onOutputFormatChanged(FormatParam format) throws RemoteException {
+        public void onOutputFormatChanged(FormatParam format) throws RemoteException {
             mCallbacks.onOutputFormatChanged(format.asFormat());
         }
 
         @Override
-        public synchronized void onOutput(Sample sample) throws RemoteException {
+        public void onOutput(Sample sample) throws RemoteException {
             if (mOutputSurface != null) {
                 // Don't render to surface just yet. Callback will make that happen when it's time.
                 mSurfaceOutputs.offer(sample);
                 mCallbacks.onOutput(sample);
             } else {
                 // Non-surface output needs no rendering.
                 mCallbacks.onOutput(sample);
                 mRemote.releaseOutput(sample, false);
@@ -92,27 +85,23 @@ public final class CodecProxy {
             }
         }
 
         @Override
         public void onError(boolean fatal) throws RemoteException {
             reportError(fatal);
         }
 
-        private synchronized void reportError(boolean fatal) {
+        private void reportError(boolean fatal) {
             mCallbacks.onError(fatal);
         }
 
         private void setEndOfInput(boolean end) {
             mEndOfInput = end;
         }
-
-        private synchronized void cancel() {
-            mCallbacks = sNoOpCallbacks;
-        }
     }
 
     @WrapForJNI
     public static CodecProxy create(MediaFormat format,
                                     Surface surface,
                                     Callbacks callbacks,
                                     String drmStubId) {
         return RemoteManager.getInstance().createCodec(format, surface, callbacks, drmStubId);
@@ -224,18 +213,16 @@ public final class CodecProxy {
             e.printStackTrace();
             return false;
         }
         return true;
     }
 
     @WrapForJNI
     public synchronized boolean release() {
-        mCallbacks.cancel();
-
         if (mRemote == null) {
             Log.w(LOGTAG, "codec already ended");
             return true;
         }
         if (DEBUG) { Log.d(LOGTAG, "release " + this); }
 
         if (!mSurfaceOutputs.isEmpty()) {
             // Flushing output buffers to surface may cause some frames to be skipped and