summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
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_|.