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

Unified Diff: content/renderer/media/rtc_video_decoder.cc

Issue 1817573004: Handle HW decode failures in RTCVideoDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mcasas@ comments. Created 4 years, 9 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: content/renderer/media/rtc_video_decoder.cc
diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc
index 49f64362aa3622623d8b1c55688ebbe5cd6f7c63..c01673f9c5b9b4fe529d06e3af11c248f57e9a40 100644
--- a/content/renderer/media/rtc_video_decoder.cc
+++ b/content/renderer/media/rtc_video_decoder.cc
@@ -28,6 +28,7 @@ namespace content {
const int32_t RTCVideoDecoder::ID_LAST = 0x3FFFFFFF;
const int32_t RTCVideoDecoder::ID_HALF = 0x20000000;
const int32_t RTCVideoDecoder::ID_INVALID = -1;
+const uint32_t kNumVDAErrorsHandled = 5;
mcasas 2016/03/28 18:15:20 micro-pedantic-nit: s/kNumVDAErrorsHandled/kNumVDA
emircan 2016/03/29 01:50:50 kNumVDAResetsBeforeSWFallback?
// Maximum number of concurrent VDA::Decode() operations RVD will maintain.
// Higher values allow better pipelining in the GPU, but also require more
@@ -160,6 +161,16 @@ int32_t RTCVideoDecoder::Decode(
if (state_ == DECODE_ERROR) {
LOG(ERROR) << "Decoding error occurred.";
+ // Try reseting the session |kNumVDAErrorsHandled| times.
+ if (num_vda_errors_ > kNumVDAErrorsHandled) {
+ DVLOG(1) << num_vda_errors_
mcasas 2016/03/28 18:15:20 nit: s/DVLOG(1)/DLOG(ERROR)/
emircan 2016/03/29 01:50:50 Done.
+ << " errors reported by VDA, falling back to software decode";
+ return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
+ }
+ state_ = RESETTING;
+ factories_->GetTaskRunner()->PostTask(
+ FROM_HERE, base::Bind(&RTCVideoDecoder::ResetInternal,
+ weak_factory_.GetWeakPtr()));
return WEBRTC_VIDEO_CODEC_ERROR;
}
@@ -476,6 +487,7 @@ void RTCVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) {
base::AutoLock auto_lock(lock_);
state_ = DECODE_ERROR;
+ num_vda_errors_++;
mcasas 2016/03/28 18:15:20 nit: prefer pre-increment. I know, I know, we coul
emircan 2016/03/29 01:50:50 Done.
}
void RTCVideoDecoder::RequestBufferDecode() {
@@ -605,10 +617,14 @@ void RTCVideoDecoder::MovePendingBuffersToDecodeBuffers() {
}
void RTCVideoDecoder::ResetInternal() {
+ DVLOG(2) << __FUNCTION__;
DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
- DVLOG(2) << "ResetInternal";
- if (vda_)
+
+ if (vda_) {
vda_->Reset();
+ } else {
+ CreateVDA(vda_codec_profile_, nullptr);
+ }
mcasas 2016/03/28 18:15:20 No {} for one-liners as I replied to pbos@ (this i
emircan 2016/03/29 01:50:50 Done.
}
// static
@@ -680,9 +696,11 @@ void RTCVideoDecoder::CreateVDA(media::VideoCodecProfile profile,
media::VideoDecodeAccelerator::Config config(profile);
if (vda_ && !vda_->Initialize(config, this))
vda_.release()->Destroy();
+ vda_codec_profile_ = profile;
}
- waiter->Signal();
+ if (waiter)
+ waiter->Signal();
}
void RTCVideoDecoder::DestroyTextures() {
@@ -705,7 +723,14 @@ void RTCVideoDecoder::DestroyVDA() {
if (vda_)
vda_.release()->Destroy();
DestroyTextures();
+
base::AutoLock auto_lock(lock_);
+
+ // Put the buffers back in case we restart the decoder.
+ for (const auto& buffer : bitstream_buffers_in_decoder_)
+ PutSHM_Locked(scoped_ptr<base::SharedMemory>(buffer.second));
+ bitstream_buffers_in_decoder_.clear();
+
state_ = UNINITIALIZED;
}

Powered by Google App Engine
This is Rietveld 408576698