Bug 1353459 - handle queueInputBuffer exceptions. r=esawin. a=gchang
MozReview-Commit-ID: 1IgLfpmGnN3
--- a/mobile/android/base/java/org/mozilla/gecko/media/Codec.java
+++ b/mobile/android/base/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 releaseOutput(Sample sample, boolean render) {
try {
mOutputProcessor.onRelease(sample, render);
} catch (Exception e) {
reportError(Error.FATAL, e);
--- a/mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/CodecProxy.java
@@ -182,17 +182,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);
}
}