Bug 1140995 - part 2: Don't send the audio/video data when the EOS flag is raised because the decoded data is invalid. r=cpearce

This commit is contained in:
Benjamin Chen 2015-04-23 14:56:52 +08:00
parent 10c2275eec
commit 7c2b98b83d

View File

@ -426,8 +426,11 @@ MediaCodecReader::DecodeAudioDataSync()
}
}
if (bufferInfo.mBuffer != nullptr && bufferInfo.mSize > 0 &&
bufferInfo.mBuffer->data() != nullptr) {
if ((bufferInfo.mFlags & MediaCodec::BUFFER_FLAG_EOS) ||
(status == ERROR_END_OF_STREAM)) {
AudioQueue().Finish();
} else if (bufferInfo.mBuffer != nullptr && bufferInfo.mSize > 0 &&
bufferInfo.mBuffer->data() != nullptr) {
// This is the approximate byte position in the stream.
int64_t pos = mDecoder->GetResource()->Tell();
@ -445,13 +448,7 @@ MediaCodecReader::DecodeAudioDataSync()
bufferInfo.mSize,
mInfo.mAudio.mChannels));
}
if ((bufferInfo.mFlags & MediaCodec::BUFFER_FLAG_EOS) ||
(status == ERROR_END_OF_STREAM)) {
AudioQueue().Finish();
}
mAudioTrack.mCodec->releaseOutputBuffer(bufferInfo.mIndex);
}
void
@ -918,6 +915,13 @@ MediaCodecReader::DecodeVideoFrameSync(int64_t aTimeThreshold)
}
}
if ((bufferInfo.mFlags & MediaCodec::BUFFER_FLAG_EOS) ||
(status == ERROR_END_OF_STREAM)) {
VideoQueue().Finish();
mVideoTrack.mCodec->releaseOutputBuffer(bufferInfo.mIndex);
return;
}
nsRefPtr<VideoData> v;
RefPtr<TextureClient> textureClient;
sp<GraphicBuffer> graphicBuffer;
@ -1014,11 +1018,6 @@ MediaCodecReader::DecodeVideoFrameSync(int64_t aTimeThreshold)
}
}
if ((bufferInfo.mFlags & MediaCodec::BUFFER_FLAG_EOS) ||
(status == ERROR_END_OF_STREAM)) {
VideoQueue().Finish();
}
if (v != nullptr && textureClient != nullptr && graphicBuffer != nullptr) {
MutexAutoLock al(mTextureClientIndexesLock);
mTextureClientIndexes.Put(textureClient.get(), bufferInfo.mIndex);