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

Unified Diff: content/common/gpu/media/dxva_video_decode_accelerator.cc

Issue 1427213002: Lock the decoder device (Angle) device from the decoder thread before copying the decoded frame to … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix member order Created 5 years, 1 month 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 | « content/common/gpu/media/dxva_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: content/common/gpu/media/dxva_video_decode_accelerator.cc
diff --git a/content/common/gpu/media/dxva_video_decode_accelerator.cc b/content/common/gpu/media/dxva_video_decode_accelerator.cc
index 29d90065efdb6b9d81dec1bd73d0cb2da761f0bb..eba652e0179cd81e7042c014f4997e47ace347ef 100644
--- a/content/common/gpu/media/dxva_video_decode_accelerator.cc
+++ b/content/common/gpu/media/dxva_video_decode_accelerator.cc
@@ -621,6 +621,7 @@ DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator(
use_dx11_(false),
dx11_video_format_converter_media_type_needs_init_(true),
gl_context_(gl_context),
+ dx11_device_locked_(false),
weak_this_factory_(this) {
weak_ptr_ = weak_this_factory_.GetWeakPtr();
memset(&input_stream_info_, 0, sizeof(input_stream_info_));
@@ -804,10 +805,9 @@ bool DXVAVideoDecodeAccelerator::CreateDX11DevManager() {
// context are synchronized across threads. We have multiple threads
// accessing the context, the media foundation decoder threads and the
// decoder thread via the video format conversion transform.
- base::win::ScopedComPtr<ID3D10Multithread> multi_threaded;
- hr = multi_threaded.QueryFrom(d3d11_device_context_.get());
+ hr = multi_threaded_.QueryFrom(d3d11_device_context_.get());
RETURN_ON_HR_FAILURE(hr, "Failed to query ID3D10Multithread", false);
- multi_threaded->SetMultithreadProtected(TRUE);
+ multi_threaded_->SetMultithreadProtected(TRUE);
hr = d3d11_device_manager_->ResetDevice(d3d11_device_.get(),
dx11_dev_manager_reset_token_);
@@ -968,7 +968,7 @@ void DXVAVideoDecodeAccelerator::Reset() {
RETURN_AND_NOTIFY_ON_FAILURE((state == kNormal || state == kStopped),
"Reset: invalid state: " << state, ILLEGAL_STATE,);
- decoder_thread_.Stop();
+ StopDecoderThread();
SetState(kResetting);
@@ -1498,7 +1498,7 @@ void DXVAVideoDecodeAccelerator::StopOnError(
void DXVAVideoDecodeAccelerator::Invalidate() {
if (GetState() == kUninitialized)
return;
- decoder_thread_.Stop();
+ StopDecoderThread();
weak_this_factory_.InvalidateWeakPtrs();
output_picture_buffers_.clear();
stale_output_picture_buffers_.clear();
@@ -2011,6 +2011,12 @@ void DXVAVideoDecodeAccelerator::CopyTexture(ID3D11Texture2D* src_texture,
output_sample->AddBuffer(output_buffer.get());
+ // Lock the device here as we are accessing the destination texture created
+ // on the main thread.
+ CHECK(!dx11_device_locked_);
+ dx11_device_locked_ = true;
+ multi_threaded_->Enter();
+
DWORD status = 0;
MFT_OUTPUT_DATA_BUFFER format_converter_output = {};
format_converter_output.pSample = output_sample.get();
@@ -2091,6 +2097,9 @@ void DXVAVideoDecodeAccelerator::FlushDecoder(
return;
}
+ dx11_device_locked_ = false;
+ multi_threaded_->Leave();
+
main_thread_task_runner_->PostTask(
FROM_HERE,
base::Bind(&DXVAVideoDecodeAccelerator::CopySurfaceComplete,
@@ -2271,4 +2280,22 @@ bool DXVAVideoDecodeAccelerator::GetVideoFrameDimensions(
return true;
}
+void DXVAVideoDecodeAccelerator::StopDecoderThread() {
+ if (main_thread_task_runner_->BelongsToCurrentThread()) {
+ if (decoder_thread_.IsRunning()) {
+ decoder_thread_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&DXVAVideoDecodeAccelerator::StopDecoderThread,
+ base::Unretained(this)));
+ }
+ decoder_thread_.Stop();
+ return;
+ }
+
+ if (dx11_device_locked_) {
+ dx11_device_locked_ = false;
+ multi_threaded_->Leave();
+ }
+}
+
} // namespace content
« no previous file with comments | « content/common/gpu/media/dxva_video_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698