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

Side by Side Diff: media/gpu/avda_codec_allocator.h

Issue 2629223003: media: Ensure MediaCodecs are released before attached SurfaceTextures (Closed)
Patch Set: more comments 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_AVDA_CODEC_ALLOCATOR_H_ 5 #ifndef MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_
6 #define MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ 6 #define MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 class CodecConfig : public base::RefCountedThreadSafe<CodecConfig> { 47 class CodecConfig : public base::RefCountedThreadSafe<CodecConfig> {
48 public: 48 public:
49 CodecConfig(); 49 CodecConfig();
50 50
51 VideoCodec codec = kUnknownVideoCodec; 51 VideoCodec codec = kUnknownVideoCodec;
52 52
53 // The surface that MediaCodec is configured to output to. 53 // The surface that MediaCodec is configured to output to.
54 gl::ScopedJavaSurface surface; 54 gl::ScopedJavaSurface surface;
55 int surface_id = SurfaceManager::kNoSurfaceID; 55 int surface_id = SurfaceManager::kNoSurfaceID;
56 56
57 // The SurfaceTexture attached to |surface|, or nullptr if |surface| is
58 // SurfaceView backed.
59 scoped_refptr<gl::SurfaceTexture> surface_texture;
liberato (no reviews please) 2017/01/17 18:58:24 is this used?
watk 2017/01/17 19:02:48 Yes, I put a comment on its usage. The point of it
60
57 // The MediaCrypto that MediaCodec is configured with for an encrypted stream. 61 // The MediaCrypto that MediaCodec is configured with for an encrypted stream.
58 MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto; 62 MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto;
59 63
60 // Whether the encryption scheme requires us to use a protected surface. 64 // Whether the encryption scheme requires us to use a protected surface.
61 bool needs_protected_surface = false; 65 bool needs_protected_surface = false;
62 66
63 // The initial coded size. The actual size might change at any time, so this 67 // The initial coded size. The actual size might change at any time, so this
64 // is only a hint. 68 // is only a hint.
65 gfx::Size initial_expected_coded_size; 69 gfx::Size initial_expected_coded_size;
66 70
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // detector will see no pending jobs in that case, so it's automatic. 157 // detector will see no pending jobs in that case, so it's automatic.
154 bool IsThreadLikelyHung(TaskType task_type); 158 bool IsThreadLikelyHung(TaskType task_type);
155 159
156 // Return true if and only if there is any AVDA registered. 160 // Return true if and only if there is any AVDA registered.
157 bool IsAnyRegisteredAVDA(); 161 bool IsAnyRegisteredAVDA();
158 162
159 // Return the task type to use for a new codec allocation, or nullopt if 163 // Return the task type to use for a new codec allocation, or nullopt if
160 // both threads are hung. 164 // both threads are hung.
161 base::Optional<TaskType> TaskTypeForAllocation(); 165 base::Optional<TaskType> TaskTypeForAllocation();
162 166
167 // Return the task runner for tasks of type |type|.
168 scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerFor(TaskType task_type);
169
163 // Return a reference to the thread for unit tests. 170 // Return a reference to the thread for unit tests.
164 base::Thread& GetThreadForTesting(TaskType task_type); 171 base::Thread& GetThreadForTesting(TaskType task_type);
165 172
166 private: 173 private:
167 friend struct base::DefaultLazyInstanceTraits<AVDACodecAllocator>; 174 friend struct base::DefaultLazyInstanceTraits<AVDACodecAllocator>;
168 friend class AVDACodecAllocatorTest; 175 friend class AVDACodecAllocatorTest;
169 176
170 struct OwnerRecord { 177 struct OwnerRecord {
171 AVDACodecAllocatorClient* owner = nullptr; 178 AVDACodecAllocatorClient* owner = nullptr;
172 AVDACodecAllocatorClient* waiter = nullptr; 179 AVDACodecAllocatorClient* waiter = nullptr;
(...skipping 23 matching lines...) Expand all
196 : thread(name), hang_detector(tick_clock) {} 203 : thread(name), hang_detector(tick_clock) {}
197 base::Thread thread; 204 base::Thread thread;
198 HangDetector hang_detector; 205 HangDetector hang_detector;
199 }; 206 };
200 207
201 // |tick_clock| and |stop_event| are for tests only. 208 // |tick_clock| and |stop_event| are for tests only.
202 AVDACodecAllocator(base::TickClock* tick_clock = nullptr, 209 AVDACodecAllocator(base::TickClock* tick_clock = nullptr,
203 base::WaitableEvent* stop_event = nullptr); 210 base::WaitableEvent* stop_event = nullptr);
204 ~AVDACodecAllocator(); 211 ~AVDACodecAllocator();
205 212
206 // Return the task runner for tasks of type |type|.
207 scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerFor(TaskType task_type);
208
209 void OnMediaCodecAndSurfaceReleased(int surface_id); 213 void OnMediaCodecAndSurfaceReleased(int surface_id);
210 214
211 // Stop the thread indicated by |index|. This signals stop_event_for_testing_ 215 // Stop the thread indicated by |index|. This signals stop_event_for_testing_
212 // after both threads are stopped. 216 // after both threads are stopped.
213 void StopThreadTask(size_t index); 217 void StopThreadTask(size_t index);
214 218
215 // All registered AVDAs. 219 // All registered AVDAs.
216 std::set<AVDACodecAllocatorClient*> clients_; 220 std::set<AVDACodecAllocatorClient*> clients_;
217 221
218 // Indexed by surface id. 222 // Indexed by surface id.
(...skipping 13 matching lines...) Expand all
232 236
233 // For canceling pending StopThreadTask()s. 237 // For canceling pending StopThreadTask()s.
234 base::WeakPtrFactory<AVDACodecAllocator> weak_this_factory_; 238 base::WeakPtrFactory<AVDACodecAllocator> weak_this_factory_;
235 239
236 DISALLOW_COPY_AND_ASSIGN(AVDACodecAllocator); 240 DISALLOW_COPY_AND_ASSIGN(AVDACodecAllocator);
237 }; 241 };
238 242
239 } // namespace media 243 } // namespace media
240 244
241 #endif // MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_ 245 #endif // MEDIA_GPU_AVDA_CODEC_ALLOCATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698