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

Side by Side Diff: content/common/gpu/media/dxva_video_decode_accelerator.h

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 locking 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ 5 #ifndef CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ 6 #define CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_
7 7
8 #include <d3d11.h> 8 #include <d3d11.h>
9 #include <d3d9.h> 9 #include <d3d9.h>
10 // Work around bug in this header by disabling the relevant warning for it. 10 // Work around bug in this header by disabling the relevant warning for it.
11 // https://connect.microsoft.com/VisualStudio/feedback/details/911260/dxva2api-h -in-win8-sdk-triggers-c4201-with-w4 11 // https://connect.microsoft.com/VisualStudio/feedback/details/911260/dxva2api-h -in-win8-sdk-triggers-c4201-with-w4
12 #pragma warning(push) 12 #pragma warning(push)
13 #pragma warning(disable:4201) 13 #pragma warning(disable:4201)
14 #include <dxva2api.h> 14 #include <dxva2api.h>
15 #pragma warning(pop) 15 #pragma warning(pop)
16 #include <list> 16 #include <list>
17 #include <map> 17 #include <map>
18 #include <mfidl.h> 18 #include <mfidl.h>
19 #include <vector> 19 #include <vector>
20 20
21 #include "base/compiler_specific.h" 21 #include "base/compiler_specific.h"
22 #include "base/macros.h"
22 #include "base/memory/linked_ptr.h" 23 #include "base/memory/linked_ptr.h"
23 #include "base/memory/weak_ptr.h" 24 #include "base/memory/weak_ptr.h"
24 #include "base/synchronization/lock.h" 25 #include "base/synchronization/lock.h"
25 #include "base/threading/non_thread_safe.h" 26 #include "base/threading/non_thread_safe.h"
26 #include "base/threading/thread.h" 27 #include "base/threading/thread.h"
27 #include "base/win/scoped_comptr.h" 28 #include "base/win/scoped_comptr.h"
28 #include "content/common/content_export.h" 29 #include "content/common/content_export.h"
29 #include "media/video/video_decode_accelerator.h" 30 #include "media/video/video_decode_accelerator.h"
30 31
31 interface IMFSample; 32 interface IMFSample;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // Returns true on success. 235 // Returns true on success.
235 bool InitializeDX11VideoFormatConverterMediaType(int width, int height); 236 bool InitializeDX11VideoFormatConverterMediaType(int width, int height);
236 237
237 // Returns the output video frame dimensions (width, height). 238 // Returns the output video frame dimensions (width, height).
238 // |sample| :- This is the output sample containing the video frame. 239 // |sample| :- This is the output sample containing the video frame.
239 // |width| :- The width is returned here. 240 // |width| :- The width is returned here.
240 // |height| :- The height is returned here. 241 // |height| :- The height is returned here.
241 // Returns true on success. 242 // Returns true on success.
242 bool GetVideoFrameDimensions(IMFSample* sample, int* width, int* height); 243 bool GetVideoFrameDimensions(IMFSample* sample, int* width, int* height);
243 244
245 // Performs any cleanup on the decoder thread and stops it.
246 void StopDecoderThread();
247
244 // To expose client callbacks from VideoDecodeAccelerator. 248 // To expose client callbacks from VideoDecodeAccelerator.
245 media::VideoDecodeAccelerator::Client* client_; 249 media::VideoDecodeAccelerator::Client* client_;
246 250
247 base::win::ScopedComPtr<IMFTransform> decoder_; 251 base::win::ScopedComPtr<IMFTransform> decoder_;
248 base::win::ScopedComPtr<IMFTransform> video_format_converter_mft_; 252 base::win::ScopedComPtr<IMFTransform> video_format_converter_mft_;
249 253
250 base::win::ScopedComPtr<IDirect3D9Ex> d3d9_; 254 base::win::ScopedComPtr<IDirect3D9Ex> d3d9_;
251 base::win::ScopedComPtr<IDirect3DDevice9Ex> d3d9_device_ex_; 255 base::win::ScopedComPtr<IDirect3DDevice9Ex> d3d9_device_ex_;
252 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_; 256 base::win::ScopedComPtr<IDirect3DDeviceManager9> device_manager_;
253 base::win::ScopedComPtr<IDirect3DQuery9> query_; 257 base::win::ScopedComPtr<IDirect3DQuery9> query_;
254 258
255 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_; 259 base::win::ScopedComPtr<ID3D11DeviceContext> d3d11_device_context_;
256 base::win::ScopedComPtr<ID3D11Device > d3d11_device_; 260 base::win::ScopedComPtr<ID3D11Device > d3d11_device_;
257 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_; 261 base::win::ScopedComPtr<IMFDXGIDeviceManager> d3d11_device_manager_;
258 base::win::ScopedComPtr<ID3D11Query> d3d11_query_; 262 base::win::ScopedComPtr<ID3D11Query> d3d11_query_;
263 base::win::ScopedComPtr<ID3D10Multithread> multi_threaded_;
259 264
260 // Ideally the reset token would be a stack variable which is used while 265 // Ideally the reset token would be a stack variable which is used while
261 // creating the device manager. However it seems that the device manager 266 // creating the device manager. However it seems that the device manager
262 // holds onto the token and attempts to access it if the underlying device 267 // holds onto the token and attempts to access it if the underlying device
263 // changes. 268 // changes.
264 // TODO(ananta): This needs to be verified. 269 // TODO(ananta): This needs to be verified.
265 uint32 dev_manager_reset_token_; 270 uint32 dev_manager_reset_token_;
266 271
267 // Reset token for the DX11 device manager. 272 // Reset token for the DX11 device manager.
268 uint32 dx11_dev_manager_reset_token_; 273 uint32 dx11_dev_manager_reset_token_;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 bool dx11_video_format_converter_media_type_needs_init_; 366 bool dx11_video_format_converter_media_type_needs_init_;
362 367
363 // The GLContext to be used by the decoder. 368 // The GLContext to be used by the decoder.
364 scoped_refptr<gfx::GLContext> gl_context_; 369 scoped_refptr<gfx::GLContext> gl_context_;
365 370
366 // WeakPtrFactory for posting tasks back to |this|. 371 // WeakPtrFactory for posting tasks back to |this|.
367 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; 372 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_;
368 373
369 // Function pointer for the MFCreateDXGIDeviceManager API. 374 // Function pointer for the MFCreateDXGIDeviceManager API.
370 static CreateDXGIDeviceManager create_dxgi_device_manager_; 375 static CreateDXGIDeviceManager create_dxgi_device_manager_;
376
377 // Set to true if the DX11 device has been locked. This member is only
378 // accessed on the decoder thread.
379 bool dx11_device_locked_;
380
381 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator);
371 }; 382 };
372 383
373 } // namespace content 384 } // namespace content
374 385
375 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ 386 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698