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

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

Issue 2076423004: Remove calls to MessageLoop::current() in media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self-review Created 4 years, 6 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 (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 // This file contains an implementation of VideoDecoderAccelerator 5 // This file contains an implementation of VideoDecoderAccelerator
6 // that utilizes hardware video decoder present on Intel CPUs. 6 // that utilizes hardware video decoder present on Intel CPUs.
7 7
8 #ifndef MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ 8 #ifndef MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_
9 #define MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ 9 #define MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_
10 10
11 #include <stddef.h> 11 #include <stddef.h>
12 #include <stdint.h> 12 #include <stdint.h>
13 13
14 #include <list> 14 #include <list>
15 #include <map> 15 #include <map>
16 #include <memory> 16 #include <memory>
17 #include <queue> 17 #include <queue>
18 #include <utility> 18 #include <utility>
19 #include <vector> 19 #include <vector>
20 20
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/memory/linked_ptr.h" 23 #include "base/memory/linked_ptr.h"
24 #include "base/memory/ref_counted.h"
24 #include "base/memory/weak_ptr.h" 25 #include "base/memory/weak_ptr.h"
25 #include "base/message_loop/message_loop.h" 26 #include "base/single_thread_task_runner.h"
26 #include "base/synchronization/condition_variable.h" 27 #include "base/synchronization/condition_variable.h"
27 #include "base/synchronization/lock.h" 28 #include "base/synchronization/lock.h"
28 #include "base/threading/thread.h" 29 #include "base/threading/thread.h"
29 #include "media/base/bitstream_buffer.h" 30 #include "media/base/bitstream_buffer.h"
30 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" 31 #include "media/gpu/gpu_video_decode_accelerator_helpers.h"
31 #include "media/gpu/media_gpu_export.h" 32 #include "media/gpu/media_gpu_export.h"
32 #include "media/gpu/shared_memory_region.h" 33 #include "media/gpu/shared_memory_region.h"
33 #include "media/gpu/vaapi_wrapper.h" 34 #include "media/gpu/vaapi_wrapper.h"
34 #include "media/video/picture.h" 35 #include "media/video/picture.h"
35 #include "media/video/video_decode_accelerator.h" 36 #include "media/video/video_decode_accelerator.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // to use, we'll execute the callback passing the Picture. The callback 255 // to use, we'll execute the callback passing the Picture. The callback
255 // will put the contents of the surface into the picture and return it to 256 // will put the contents of the surface into the picture and return it to
256 // the client, releasing the surface as well. 257 // the client, releasing the surface as well.
257 // If we don't have any available Pictures at the time when the decoder 258 // If we don't have any available Pictures at the time when the decoder
258 // requests output, we'll store the request on pending_output_cbs_ queue for 259 // requests output, we'll store the request on pending_output_cbs_ queue for
259 // later and run it once the client gives us more textures 260 // later and run it once the client gives us more textures
260 // via ReusePictureBuffer(). 261 // via ReusePictureBuffer().
261 typedef base::Callback<void(VaapiPicture*)> OutputCB; 262 typedef base::Callback<void(VaapiPicture*)> OutputCB;
262 std::queue<OutputCB> pending_output_cbs_; 263 std::queue<OutputCB> pending_output_cbs_;
263 264
264 // ChildThread's message loop 265 // ChildThread's task runner.
265 base::MessageLoop* message_loop_; 266 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
266 267
267 // WeakPtr<> pointing to |this| for use in posting tasks from the decoder 268 // WeakPtr<> pointing to |this| for use in posting tasks from the decoder
268 // thread back to the ChildThread. Because the decoder thread is a member of 269 // thread back to the ChildThread. Because the decoder thread is a member of
269 // this class, any task running on the decoder thread is guaranteed that this 270 // this class, any task running on the decoder thread is guaranteed that this
270 // object is still alive. As a result, tasks posted from ChildThread to 271 // object is still alive. As a result, tasks posted from ChildThread to
271 // decoder thread should use base::Unretained(this), and tasks posted from the 272 // decoder thread should use base::Unretained(this), and tasks posted from the
272 // decoder thread to the ChildThread should use |weak_this_|. 273 // decoder thread to the ChildThread should use |weak_this_|.
273 base::WeakPtr<VaapiVideoDecodeAccelerator> weak_this_; 274 base::WeakPtr<VaapiVideoDecodeAccelerator> weak_this_;
274 275
275 // Callback used when creating VASurface objects. 276 // Callback used when creating VASurface objects.
276 VASurface::ReleaseCB va_surface_release_cb_; 277 VASurface::ReleaseCB va_surface_release_cb_;
277 278
278 // To expose client callbacks from VideoDecodeAccelerator. 279 // To expose client callbacks from VideoDecodeAccelerator.
279 // NOTE: all calls to these objects *MUST* be executed on message_loop_. 280 // NOTE: all calls to these objects *MUST* be executed on task_runner_.
280 std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_; 281 std::unique_ptr<base::WeakPtrFactory<Client>> client_ptr_factory_;
281 base::WeakPtr<Client> client_; 282 base::WeakPtr<Client> client_;
282 283
283 // Accelerators come after vaapi_wrapper_ to ensure they are destroyed first. 284 // Accelerators come after vaapi_wrapper_ to ensure they are destroyed first.
284 std::unique_ptr<VaapiH264Accelerator> h264_accelerator_; 285 std::unique_ptr<VaapiH264Accelerator> h264_accelerator_;
285 std::unique_ptr<VaapiVP8Accelerator> vp8_accelerator_; 286 std::unique_ptr<VaapiVP8Accelerator> vp8_accelerator_;
286 std::unique_ptr<VaapiVP9Accelerator> vp9_accelerator_; 287 std::unique_ptr<VaapiVP9Accelerator> vp9_accelerator_;
287 // After *_accelerator_ to ensure correct destruction order. 288 // After *_accelerator_ to ensure correct destruction order.
288 std::unique_ptr<AcceleratedVideoDecoder> decoder_; 289 std::unique_ptr<AcceleratedVideoDecoder> decoder_;
289 290
(...skipping 26 matching lines...) Expand all
316 317
317 // The WeakPtrFactory for |weak_this_|. 318 // The WeakPtrFactory for |weak_this_|.
318 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_; 319 base::WeakPtrFactory<VaapiVideoDecodeAccelerator> weak_this_factory_;
319 320
320 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator); 321 DISALLOW_COPY_AND_ASSIGN(VaapiVideoDecodeAccelerator);
321 }; 322 };
322 323
323 } // namespace media 324 } // namespace media
324 325
325 #endif // MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ 326 #endif // MEDIA_GPU_VAAPI_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698