Bug 1340582 - handle shared memory allocation failure. r?jchen
MozReview-Commit-ID: ETk9nHHkyYA
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -579,19 +579,21 @@ RemoteDataDecoder::Decode(MediaRawData*
nsresult rv = BufferInfo::New(&bufferInfo);
if (NS_FAILED(rv)) {
return DecodePromise::CreateAndReject(
MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__);
}
bufferInfo->Set(0, sample->Size(), sample->mTime, 0);
mDrainStatus = DrainStatus::DRAINABLE;
- RefPtr<DecodePromise> p = mDecodePromise.Ensure(__func__);
- mJavaDecoder->Input(bytes, bufferInfo, GetCryptoInfoFromSample(sample));
- return p;
+ return mJavaDecoder->Input(bytes, bufferInfo, GetCryptoInfoFromSample(sample))
+ ? mDecodePromise.Ensure(__func__)
+ : DecodePromise::CreateAndReject(
+ MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__);
+
});
}
void
RemoteDataDecoder::Output(MediaData* aSample)
{
if (!mTaskQueue->IsCurrentThreadIn()) {
mTaskQueue->Dispatch(
--- 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,35 @@ 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=" + 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;