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

Unified Diff: media/gpu/android_video_decode_accelerator.cc

Issue 2147843002: Drop idle MediaCodec instances after a few seconds within AVDA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reduce to 1 second. Make const. Created 4 years, 5 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
« no previous file with comments | « media/gpu/android_video_decode_accelerator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/android_video_decode_accelerator.cc
diff --git a/media/gpu/android_video_decode_accelerator.cc b/media/gpu/android_video_decode_accelerator.cc
index 5b8c856701c5645cd6324720a9d1086ba9b0532c..0a3e80833caa228133350c22fc65b464601144a3 100644
--- a/media/gpu/android_video_decode_accelerator.cc
+++ b/media/gpu/android_video_decode_accelerator.cc
@@ -109,6 +109,12 @@ static inline const base::TimeDelta ErrorPostingDelay() {
return base::TimeDelta::FromSeconds(2);
}
+// Time allowed to elapse between codec configuration completion and the first
+// Decode() callback. Unless a site is intentionally stalling after providing
+// initialization information, this timeout should never be hit.
+constexpr base::TimeDelta kNoDecodeIdleTimeout =
+ base::TimeDelta::FromSeconds(1);
+
// For RecordFormatChangedMetric.
enum FormatChangedValue {
CodecInitialized = false,
@@ -963,6 +969,7 @@ void AndroidVideoDecodeAccelerator::SendDecodedFrameToClient(
void AndroidVideoDecodeAccelerator::Decode(
const BitstreamBuffer& bitstream_buffer) {
DCHECK(thread_checker_.CalledOnValidThread());
+ no_decode_timeout_.Stop();
// If we previously deferred a codec restart, take care of it now. This can
// happen on older devices where configuration changes require a codec reset.
@@ -1202,7 +1209,8 @@ void AndroidVideoDecodeAccelerator::OnCodecConfigured(
}
state_ = NO_ERROR;
-
+ no_decode_timeout_.Start(FROM_HERE, kNoDecodeIdleTimeout, this,
+ &AndroidVideoDecodeAccelerator::CloseIdleCodec);
ManageTimer(true);
}
@@ -1311,7 +1319,7 @@ void AndroidVideoDecodeAccelerator::ResetCodecState() {
// Prior to JB-MR2, flush() had several bugs (b/8125974, b/8347958) so we must
// delete the MediaCodec and create a new one. The full reconfigure is much
// slower and may cause visible freezing if done mid-stream.
- if (!did_codec_error_happen &&
+ if (!did_codec_error_happen && media_codec_ &&
base::android::BuildInfo::GetInstance()->sdk_int() >= 18) {
DVLOG(3) << __FUNCTION__ << " Flushing MediaCodec.";
media_codec_->Flush();
@@ -1671,6 +1679,8 @@ void AndroidVideoDecodeAccelerator::ReleaseMediaCodec() {
if (!media_codec_)
return;
+ no_decode_timeout_.Stop();
+
// If codec construction is broken, then we can't release this codec if it's
// backed by hardware, else it may hang too. Post it to the construction
// thread, and it'll get freed if things start working. If things are
@@ -1786,4 +1796,12 @@ bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden()
codec_config_->codec_ == media::kCodecVP9);
}
+void AndroidVideoDecodeAccelerator::CloseIdleCodec() {
+ if (!media_codec_)
+ return;
+
+ ReleaseMediaCodec();
+ codec_needs_reset_ = true;
watk 2016/07/13 22:38:25 Do we need to call strategy_->CodecChanged(nullptr
liberato (no reviews please) 2016/07/14 15:33:57 i don't think that we do, since no decode has been
+}
+
} // namespace media
« no previous file with comments | « media/gpu/android_video_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698