Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(875)

Unified Diff: media/base/android/media_decoder_job.cc

Issue 215783002: Fix an issue that audio and video may run out of sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing acolwell's comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/android/media_decoder_job.cc
diff --git a/media/base/android/media_decoder_job.cc b/media/base/android/media_decoder_job.cc
index b7eef0cdfbfbdb0769aaab6b621fda43f2948108..9295767f26a3248329792743fa6209476de5c788 100644
--- a/media/base/android/media_decoder_job.cc
+++ b/media/base/android/media_decoder_job.cc
@@ -73,7 +73,7 @@ void MediaDecoderJob::OnDataReceived(const DemuxerData& data) {
base::Closure done_cb = base::ResetAndReturn(&on_data_received_cb_);
if (stop_decode_pending_) {
- OnDecodeCompleted(MEDIA_CODEC_STOPPED, kNoTimestamp(), 0);
+ OnDecodeCompleted(MEDIA_CODEC_STOPPED, kNoTimestamp(), kNoTimestamp());
return;
}
@@ -269,8 +269,7 @@ void MediaDecoderJob::DecodeCurrentAccessUnit(
base::Bind(&MediaDecoderJob::OnDecodeCompleted,
base::Unretained(this),
MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER,
- kNoTimestamp(),
- 0));
+ kNoTimestamp(), kNoTimestamp()));
return;
}
@@ -299,7 +298,7 @@ void MediaDecoderJob::DecodeInternal(
output_eos_encountered_ = false;
MediaCodecStatus reset_status = media_codec_bridge_->Reset();
if (MEDIA_CODEC_OK != reset_status) {
- callback.Run(reset_status, kNoTimestamp(), 0);
+ callback.Run(reset_status, kNoTimestamp(), kNoTimestamp());
return;
}
}
@@ -312,7 +311,7 @@ void MediaDecoderJob::DecodeInternal(
// For aborted access unit, just skip it and inform the player.
if (unit.status == DemuxerStream::kAborted) {
// TODO(qinmin): use a new enum instead of MEDIA_CODEC_STOPPED.
- callback.Run(MEDIA_CODEC_STOPPED, kNoTimestamp(), 0);
+ callback.Run(MEDIA_CODEC_STOPPED, kNoTimestamp(), kNoTimestamp());
return;
}
@@ -320,7 +319,8 @@ void MediaDecoderJob::DecodeInternal(
if (unit.end_of_stream || unit.data.empty()) {
input_eos_encountered_ = true;
output_eos_encountered_ = true;
- callback.Run(MEDIA_CODEC_OUTPUT_END_OF_STREAM, kNoTimestamp(), 0);
+ callback.Run(MEDIA_CODEC_OUTPUT_END_OF_STREAM, kNoTimestamp(),
+ kNoTimestamp());
return;
}
@@ -333,7 +333,7 @@ void MediaDecoderJob::DecodeInternal(
if (input_status == MEDIA_CODEC_INPUT_END_OF_STREAM) {
input_eos_encountered_ = true;
} else if (input_status != MEDIA_CODEC_OK) {
- callback.Run(input_status, kNoTimestamp(), 0);
+ callback.Run(input_status, kNoTimestamp(), kNoTimestamp());
return;
}
}
@@ -360,7 +360,7 @@ void MediaDecoderJob::DecodeInternal(
!media_codec_bridge_->GetOutputBuffers()) {
status = MEDIA_CODEC_ERROR;
}
- callback.Run(status, kNoTimestamp(), 0);
+ callback.Run(status, kNoTimestamp(), kNoTimestamp());
return;
}
@@ -387,7 +387,8 @@ void MediaDecoderJob::DecodeInternal(
buffer_index,
size,
render_output,
- base::Bind(callback, status, presentation_timestamp)),
+ presentation_timestamp,
+ base::Bind(callback, status)),
time_to_render);
return;
}
@@ -406,13 +407,14 @@ void MediaDecoderJob::DecodeInternal(
presentation_timestamp = kNoTimestamp();
}
ReleaseOutputCompletionCallback completion_callback = base::Bind(
- callback, status, presentation_timestamp);
- ReleaseOutputBuffer(buffer_index, size, render_output, completion_callback);
+ callback, status);
+ ReleaseOutputBuffer(buffer_index, size, render_output, presentation_timestamp,
+ completion_callback);
}
void MediaDecoderJob::OnDecodeCompleted(
- MediaCodecStatus status, base::TimeDelta presentation_timestamp,
- size_t audio_output_bytes) {
+ MediaCodecStatus status, base::TimeDelta current_presentation_timestamp,
+ base::TimeDelta max_presentation_timestamp) {
DCHECK(ui_task_runner_->BelongsToCurrentThread());
if (destroy_pending_) {
@@ -424,7 +426,7 @@ void MediaDecoderJob::OnDecodeCompleted(
DCHECK(!decode_cb_.is_null());
// If output was queued for rendering, then we have completed prerolling.
- if (presentation_timestamp != kNoTimestamp())
+ if (current_presentation_timestamp != kNoTimestamp())
prerolling_ = false;
switch (status) {
@@ -447,8 +449,8 @@ void MediaDecoderJob::OnDecodeCompleted(
};
stop_decode_pending_ = false;
- base::ResetAndReturn(&decode_cb_).Run(status, presentation_timestamp,
- audio_output_bytes);
+ base::ResetAndReturn(&decode_cb_).Run(
+ status, current_presentation_timestamp, max_presentation_timestamp);
}
const AccessUnit& MediaDecoderJob::CurrentAccessUnit() const {

Powered by Google App Engine
This is Rietveld 408576698