summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authordalecurtis <dalecurtis@chromium.org>2016-03-25 15:04:38 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-25 22:07:11 +0000
commit02d355d4a23e20555f17279a6153ec75ee21bd9a (patch)
treea49801498062b0cdccd9846216c3d6fdce1ceb1c /content/common
parent8799bb02c20d52878bde3eb9e2e33138919233ac (diff)
downloadchromium_src-02d355d4a23e20555f17279a6153ec75ee21bd9a.zip
chromium_src-02d355d4a23e20555f17279a6153ec75ee21bd9a.tar.gz
chromium_src-02d355d4a23e20555f17279a6153ec75ee21bd9a.tar.bz2
Always ensure the AVDA timer runs for at least one cycle.
Previously the code would only force restart the timer in some cases, this change causes the timer to be restarted in all cases where a DoIOTask() is manually invoked. It also changes ManageTimer() to ensure it's not basing the idle timeout on a null/uninitialized |most_recent_work_| value. BUG=594246 TEST=no more playback failures. Review URL: https://codereview.chromium.org/1834683003 Cr-Commit-Position: refs/heads/master@{#383376}
Diffstat (limited to 'content/common')
-rw-r--r--content/common/gpu/media/android_video_decode_accelerator.cc27
-rw-r--r--content/common/gpu/media/android_video_decode_accelerator.h2
2 files changed, 12 insertions, 17 deletions
diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc
index e4d7802..d058451 100644
--- a/content/common/gpu/media/android_video_decode_accelerator.cc
+++ b/content/common/gpu/media/android_video_decode_accelerator.cc
@@ -222,7 +222,7 @@ class AVDATimerManager {
// deferred until after all iterations are complete.
base::AutoReset<bool> scoper(&timer_running_, true);
for (auto* avda : avda_instances_)
- avda->DoIOTask();
+ avda->DoIOTask(false);
}
// Take care of any deferred erasures.
@@ -406,7 +406,7 @@ void AndroidVideoDecodeAccelerator::SetCdm(int cdm_id) {
#endif // !defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
}
-void AndroidVideoDecodeAccelerator::DoIOTask() {
+void AndroidVideoDecodeAccelerator::DoIOTask(bool start_timer) {
DCHECK(thread_checker_.CalledOnValidThread());
TRACE_EVENT0("media", "AVDA::DoIOTask");
if (state_ == ERROR) {
@@ -417,7 +417,7 @@ void AndroidVideoDecodeAccelerator::DoIOTask() {
while (DequeueOutput())
did_work = true;
- ManageTimer(did_work);
+ ManageTimer(did_work || start_timer);
}
bool AndroidVideoDecodeAccelerator::QueueInput() {
@@ -783,7 +783,7 @@ void AndroidVideoDecodeAccelerator::DecodeBuffer(
TRACE_COUNTER1("media", "AVDA::PendingBitstreamBufferCount",
pending_bitstream_buffers_.size());
- DoIOTask();
+ DoIOTask(true);
}
void AndroidVideoDecodeAccelerator::RequestPictureBuffers() {
@@ -821,8 +821,7 @@ void AndroidVideoDecodeAccelerator::AssignPictureBuffers(
strategy_->AssignOnePictureBuffer(buffers[i]);
}
TRACE_COUNTER1("media", "AVDA::FreePictureIds", free_picture_ids_.size());
-
- DoIOTask();
+ DoIOTask(true);
}
void AndroidVideoDecodeAccelerator::ReusePictureBuffer(
@@ -848,13 +847,7 @@ void AndroidVideoDecodeAccelerator::ReusePictureBuffer(
}
strategy_->ReuseOnePictureBuffer(i->second);
-
- // Turn the timer back on. If it timed out, it might be because MediaCodec
- // is waiting for us to return a buffer. We can't assume that it will be
- // ready to send us a buffer back immediately, though we do try DoIOTask
- // to be optimistic.
- ManageTimer(true);
- DoIOTask();
+ DoIOTask(true);
}
void AndroidVideoDecodeAccelerator::Flush() {
@@ -1099,7 +1092,7 @@ void AndroidVideoDecodeAccelerator::OnKeyAdded() {
if (state_ == WAITING_FOR_KEY)
state_ = NO_ERROR;
- DoIOTask();
+ DoIOTask(true);
}
void AndroidVideoDecodeAccelerator::NotifyCdmAttached(bool success) {
@@ -1139,10 +1132,12 @@ void AndroidVideoDecodeAccelerator::ManageTimer(bool did_work) {
bool should_be_running = true;
base::TimeTicks now = base::TimeTicks::Now();
- if (!did_work) {
+ if (!did_work && !most_recent_work_.is_null()) {
// Make sure that we have done work recently enough, else stop the timer.
- if (now - most_recent_work_ > IdleTimerTimeOut())
+ if (now - most_recent_work_ > IdleTimerTimeOut()) {
+ most_recent_work_ = base::TimeTicks();
should_be_running = false;
+ }
} else {
most_recent_work_ = now;
}
diff --git a/content/common/gpu/media/android_video_decode_accelerator.h b/content/common/gpu/media/android_video_decode_accelerator.h
index 9e6645b..378bc6f 100644
--- a/content/common/gpu/media/android_video_decode_accelerator.h
+++ b/content/common/gpu/media/android_video_decode_accelerator.h
@@ -164,7 +164,7 @@ class CONTENT_EXPORT AndroidVideoDecodeAccelerator
// Does pending IO tasks if any. Once this is called, it polls |media_codec_|
// until it finishes pending tasks. For the polling, |kDecodePollDelay| is
// used.
- void DoIOTask();
+ void DoIOTask(bool start_timer);
// Feeds input data to |media_codec_|. This checks
// |pending_bitstream_buffers_| and queues a buffer to |media_codec_|.