Index: media/gpu/ipc/service/gpu_video_encode_accelerator.h |
diff --git a/media/gpu/ipc/service/gpu_video_encode_accelerator.h b/media/gpu/ipc/service/gpu_video_encode_accelerator.h |
index d4c23ae2e71077f634ffc060b83297607844f443..2727e66eb554a9833a533daf10b305c0313ffb7c 100644 |
--- a/media/gpu/ipc/service/gpu_video_encode_accelerator.h |
+++ b/media/gpu/ipc/service/gpu_video_encode_accelerator.h |
@@ -13,6 +13,7 @@ |
#include "base/macros.h" |
#include "base/memory/weak_ptr.h" |
+#include "base/synchronization/waitable_event.h" |
#include "gpu/config/gpu_info.h" |
#include "gpu/ipc/service/gpu_command_buffer_stub.h" |
#include "ipc/ipc_listener.h" |
@@ -39,8 +40,10 @@ class GpuVideoEncodeAccelerator |
public VideoEncodeAccelerator::Client, |
public gpu::GpuCommandBufferStub::DestructionObserver { |
public: |
- GpuVideoEncodeAccelerator(int32_t host_route_id, |
- gpu::GpuCommandBufferStub* stub); |
+ GpuVideoEncodeAccelerator( |
+ int32_t host_route_id, |
+ gpu::GpuCommandBufferStub* stub, |
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
~GpuVideoEncodeAccelerator() override; |
// Initialize this accelerator with the given parameters and send |
@@ -72,6 +75,9 @@ class GpuVideoEncodeAccelerator |
static gpu::VideoEncodeAcceleratorSupportedProfiles GetSupportedProfiles( |
const gpu::GpuPreferences& gpu_preferences); |
+ // Called on IO thread when |filter_| has been removed. |
+ void OnFilterRemoved(); |
+ |
private: |
// Returns a vector of VEAFactoryFunctions for the current platform. |
using VEAFactoryFunction = |
@@ -79,6 +85,8 @@ class GpuVideoEncodeAccelerator |
static std::vector<VEAFactoryFunction> GetVEAFactoryFunctions( |
const gpu::GpuPreferences& gpu_preferences); |
+ class MessageFilter; |
+ |
// IPC handlers, proxying VideoEncodeAccelerator for the renderer |
// process. |
void OnEncode(const AcceleratedVideoEncoderMsg_Encode_Params& params); |
@@ -91,7 +99,12 @@ class GpuVideoEncodeAccelerator |
void EncodeFrameFinished(int32_t frame_id, |
std::unique_ptr<base::SharedMemory> shm); |
- void Send(IPC::Message* message); |
+ bool Send(IPC::Message* message); |
+ |
+ // Checks that function is called on the correct thread. If MessageFilter is |
+ // used, checks if it is called on |io_task_runner_|. If not, checks if it is |
+ // called on |main_task_runner_|. |
+ bool CheckCalledOnMessageFilterThread(); |
Pawel Osciak
2016/10/25 01:44:05
Since this checks whether we are on message filter
emircan
2016/10/25 21:57:51
Done.
|
// Route ID to communicate with the host. |
const uint32_t host_route_id_; |
@@ -111,6 +124,19 @@ class GpuVideoEncodeAccelerator |
gfx::Size input_coded_size_; |
size_t output_buffer_size_; |
+ // The message filter to run VDA::Decode on IO thread if VDA supports it. |
Pawel Osciak
2016/10/25 01:44:05
"VDA::Decode", "VDA"...
emircan
2016/10/25 21:57:51
Done.
|
+ scoped_refptr<MessageFilter> filter_; |
+ |
+ // Used to wait on for |filter_| to be removed, before we can safely |
+ // destroy the VEA. |
+ base::WaitableEvent filter_removed_; |
+ |
+ // GPU main thread task runner. |
+ const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
+ |
+ // GPU IO thread task runner. |
+ const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
+ |
// Weak pointer for VideoFrames that refer back to |this|. |
base::WeakPtrFactory<GpuVideoEncodeAccelerator> weak_this_factory_; |