Bug 1306483 - Part 2: send notification immediately when caller sender shares looper with buffer poller. r=esawin
authorJohn Lin <jolin@mozilla.com>
Thu, 20 Oct 2016 15:43:25 +0800
changeset 319304 9f2f66e3762fac55594ae72c24634b13eea36ab4
parent 319303 77c515e8350a7d07d807fd9e8ac3bbe136043a4a
child 319305 86bd96be9409864d04e3f2e46667d699486ecd32
push id30869
push userphilringnalda@gmail.com
push dateWed, 26 Oct 2016 04:57:48 +0000
treeherdermozilla-central@9471b3c49b2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1306483
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1306483 - Part 2: send notification immediately when caller sender shares looper with buffer poller. r=esawin MozReview-Commit-ID: 9hZB6TI4A6X
mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java
--- a/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java
@@ -82,40 +82,47 @@ final class JellyBeanAsyncCodec implemen
 
         public void notifyInputBuffer(int index) {
             if (isCanceled()) {
                 return;
             }
 
             Message msg = obtainMessage(MSG_INPUT_BUFFER_AVAILABLE);
             msg.arg1 = index;
-            sendMessage(msg);
+            processMessage(msg);
+        }
+
+        private void processMessage(Message msg) {
+            if (Looper.myLooper() == getLooper()) {
+                handleMessage(msg);
+            } else {
+                sendMessage(msg);
+            }
         }
 
         public void notifyOutputBuffer(int index, MediaCodec.BufferInfo info) {
             if (isCanceled()) {
                 return;
             }
 
             Message msg = obtainMessage(MSG_OUTPUT_BUFFER_AVAILABLE, info);
             msg.arg1 = index;
-            sendMessage(msg);
+            processMessage(msg);
         }
 
         public void notifyOutputFormat(MediaFormat format) {
             if (isCanceled()) {
                 return;
             }
-
-            sendMessage(obtainMessage(MSG_OUTPUT_FORMAT_CHANGE, format));
+            processMessage(obtainMessage(MSG_OUTPUT_FORMAT_CHANGE, format));
         }
 
         public void notifyError(int result) {
             Log.e(LOGTAG, "codec error:" + result);
-            sendMessage(obtainMessage(MSG_ERROR, result, 0));
+            processMessage(obtainMessage(MSG_ERROR, result, 0));
         }
 
         protected boolean handleMessageLocked(Message msg) {
             switch (msg.what) {
                 case MSG_INPUT_BUFFER_AVAILABLE: // arg1: buffer index.
                     mCallbacks.onInputBufferAvailable(JellyBeanAsyncCodec.this,
                                                       msg.arg1);
                     break;