Make AVDACodecAllocator thread safe

Desktop / Chromium - liberato@chromium.org [chromium.org] - 4 October 2017 14:46 EDT

AVDACodecAllocator previously was designed to work with AVDA on the GPU main thread. This CL makes it work properly even if clients call it from other threads, such as MCVD will do.

It does three main things:

- Create/ReleaseCodec calls post to the thread on which the allocator was constructed. This keeps everything ordered. Otherwise, it's very difficult to ensure that one client stopping threads won't happen concurrently with another posting tasks. Locks worked, but this prevents blocking the caller, and makes it easier to deal with the weakptr used to cancel StopThreadTask.
- Responses to the client are on whatever thread it called on. This lets us continue to use client-provided WeakPtrs.- StartThread now sends its results asynchronously, since it posts to another thread sometimes.

Bug: 760822 Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: Ib1bca55602a2f43ea9e2ecfd55fa98c877fb6217 Reviewed-on: https://chromium-review.googlesource.com/669799 Commit-Queue: Frank Liberato

04ed2188 Make AVDACodecAllocator thread safe.
media/base/android/BUILD.gn | 1 -
media/base/android/media_codec_bridge.h | 7 +
media/base/android/media_codec_bridge_impl.h | 7 -
media/base/android/mock_media_codec_bridge.cc | 22 +-
media/base/android/mock_media_codec_bridge.h | 21 ++
.../android/android_video_decode_accelerator.cc | 5 +-
.../android_video_decode_accelerator_unittest.cc | 11 +-
media/gpu/android/avda_codec_allocator.cc | 239 +++++++++++++++------
media/gpu/android/avda_codec_allocator.h | 77 +++++--
media/gpu/android/avda_codec_allocator_unittest.cc | 163 +++++++++++++-
.../content_video_view_overlay_allocator.cc | 9 +-
.../android/content_video_view_overlay_allocator.h | 2 +-
...ontent_video_view_overlay_allocator_unittest.cc | 10 +-
media/gpu/android/fake_codec_allocator.cc | 11 +-
media/gpu/android/fake_codec_allocator.h | 4 +-
media/gpu/android/media_codec_video_decoder.cc | 5 +-
.../android/media_codec_video_decoder_unittest.cc | 3 +-
media/gpu/gpu_video_decode_accelerator_factory.cc | 3 +-
media/mojo/services/gpu_mojo_media_client.cc | 3 +-
19 files changed, 481 insertions(+), 122 deletions(-)

Upstream: git.chromium.org


  • Share