Bug 1306483 - Part 2: send notification immediately when caller sender shares looper with buffer poller.
MozReview-Commit-ID: 9hZB6TI4A6X
--- 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;