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

Side by Side Diff: media/gpu/ipc/client/gpu_video_encode_accelerator_host.h

Issue 2627173002: Adds locks for CommandBufferProxyImpl invalidation (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 MEDIA_GPU_IPC_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_ 5 #ifndef MEDIA_GPU_IPC_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
6 #define MEDIA_GPU_IPC_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_ 6 #define MEDIA_GPU_IPC_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/single_thread_task_runner.h"
16 #include "base/threading/non_thread_safe.h" 17 #include "base/threading/non_thread_safe.h"
17 #include "gpu/config/gpu_info.h" 18 #include "gpu/config/gpu_info.h"
18 #include "gpu/ipc/client/command_buffer_proxy_impl.h" 19 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
19 #include "ipc/ipc_listener.h" 20 #include "ipc/ipc_listener.h"
20 #include "media/video/video_encode_accelerator.h" 21 #include "media/video/video_encode_accelerator.h"
21 22
22 namespace gfx { 23 namespace gfx {
23 class Size; 24 class Size;
24 } // namespace gfx 25 } // namespace gfx
25 26
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 uint32_t output_buffer_size); 92 uint32_t output_buffer_size);
92 void OnNotifyInputDone(int32_t frame_id); 93 void OnNotifyInputDone(int32_t frame_id);
93 void OnBitstreamBufferReady(int32_t bitstream_buffer_id, 94 void OnBitstreamBufferReady(int32_t bitstream_buffer_id,
94 uint32_t payload_size, 95 uint32_t payload_size,
95 bool key_frame, 96 bool key_frame,
96 base::TimeDelta timestamp); 97 base::TimeDelta timestamp);
97 void OnNotifyError(Error error); 98 void OnNotifyError(Error error);
98 99
99 scoped_refptr<gpu::GpuChannelHost> channel_; 100 scoped_refptr<gpu::GpuChannelHost> channel_;
100 101
102 // Callback to a function that releases |channel_|.
103 base::Callback<void(void)> channel_error_cb_;
104
101 // Route ID for the associated encoder in the GPU process. 105 // Route ID for the associated encoder in the GPU process.
102 int32_t encoder_route_id_; 106 int32_t encoder_route_id_;
103 107
104 // The client that will receive callbacks from the encoder. 108 // The client that will receive callbacks from the encoder.
105 Client* client_; 109 Client* client_;
106 110
111 // Protect |impl_|. |impl_| is used on media thread, but it can be invalidated
112 // on main thread.
113 base::Lock impl_lock_;
114
107 // Unowned reference to the gpu::CommandBufferProxyImpl that created us. 115 // Unowned reference to the gpu::CommandBufferProxyImpl that created us.
108 // |this| registers as a DeletionObserver of |impl_|, so the reference is 116 // |this| registers as a DeletionObserver of |impl_|, so the reference is
109 // always valid as long as it is not NULL. 117 // always valid as long as it is not NULL.
110 gpu::CommandBufferProxyImpl* impl_; 118 gpu::CommandBufferProxyImpl* impl_;
111 119
112 // VideoFrames sent to the encoder. 120 // VideoFrames sent to the encoder.
113 // base::IDMap not used here, since that takes pointers, not scoped_refptr. 121 // base::IDMap not used here, since that takes pointers, not scoped_refptr.
114 typedef base::hash_map<int32_t, scoped_refptr<VideoFrame>> FrameMap; 122 typedef base::hash_map<int32_t, scoped_refptr<VideoFrame>> FrameMap;
115 FrameMap frame_map_; 123 FrameMap frame_map_;
116 124
117 // ID serial number for the next frame to send to the GPU process. 125 // ID serial number for the next frame to send to the GPU process.
118 int32_t next_frame_id_; 126 int32_t next_frame_id_;
119 127
128 // Task runner for tasks that should run on the thread this class is
129 // constructed.
130 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
131
120 // WeakPtr factory for posting tasks back to itself. 132 // WeakPtr factory for posting tasks back to itself.
121 base::WeakPtrFactory<GpuVideoEncodeAcceleratorHost> weak_this_factory_; 133 base::WeakPtrFactory<GpuVideoEncodeAcceleratorHost> weak_this_factory_;
122 134
123 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAcceleratorHost); 135 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAcceleratorHost);
124 }; 136 };
125 137
126 } // namespace media 138 } // namespace media
127 139
128 #endif // MEDIA_GPU_IPC_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_ 140 #endif // MEDIA_GPU_IPC_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698