Bug 1340582 - handle shared memory allocation failure. r=jchen

MozReview-Commit-ID: ETk9nHHkyYA
This commit is contained in:
John Lin 2017-02-20 15:17:10 +08:00
parent 83ea92dc1b
commit 584224e8cd
2 changed files with 11 additions and 13 deletions

View File

@ -584,9 +584,11 @@ RemoteDataDecoder::Decode(MediaRawData* aSample)
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__);
});
}

View File

@ -177,29 +177,25 @@ public final class CodecProxy {
}
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);
}
}