Commit 609b671a authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

VADisplayState::PostSandboxInitialization from ctor

This CL moves the call to static PostSandboxInitialization()
from its user, VASupportedProfiles ctor, to the Initialize()
method; this way we improve encapsulation and guarantee that
VADisplayState sandbox is correctly initialize in all possible
call stacks.

TEST=simplechrome on Soraka playing back VP9 videos, chrome://gpu
enumeration and chrome://media-internals OK.
Compile-ran video_decode_accelerator_unittest with the vp9 file
and looked ok too.

Bug: 778093

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: I960437bb36e2d2fdf43c33251394b76f84d2ea74
Reviewed-on: https://chromium-review.googlesource.com/784470Reviewed-by: default avatarPawel Osciak <posciak@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519908}
parent 8347c25b
......@@ -149,8 +149,6 @@ class VADisplayState {
// Initialize static data before sandbox is enabled.
static void PreSandboxInitialization();
// Returns false on init failure.
static bool PostSandboxInitialization();
VADisplayState();
~VADisplayState() = delete;
......@@ -165,6 +163,9 @@ class VADisplayState {
void SetDrmFd(base::PlatformFile fd) { drm_fd_.reset(HANDLE_EINTR(dup(fd))); }
private:
// Returns false on init failure.
static bool PostSandboxInitialization();
// Protected by |va_lock_|.
int refcount_;
......@@ -231,6 +232,11 @@ VADisplayState::VADisplayState()
bool VADisplayState::Initialize() {
va_lock_.AssertAcquired();
static bool result = PostSandboxInitialization();
if (!result)
return false;
if (refcount_++ > 0)
return true;
......@@ -411,10 +417,6 @@ VASupportedProfiles::VASupportedProfiles()
report_error_to_uma_cb_(base::Bind(&base::DoNothing)) {
static_assert(arraysize(supported_profiles_) == VaapiWrapper::kCodecModeMax,
"The array size of supported profile is incorrect.");
static bool result = VADisplayState::PostSandboxInitialization();
if (!result)
return;
{
base::AutoLock auto_lock(*va_lock_);
if (!VADisplayState::Get()->Initialize())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment