Chromium Code Reviews| Index: media/gpu/vaapi_wrapper.cc |
| diff --git a/media/gpu/vaapi_wrapper.cc b/media/gpu/vaapi_wrapper.cc |
| index dcec8b971480adef3841710a07c5ac1c528f1d76..7188ee705dd0a0cf1922d6aaf0e0700d6de315f5 100644 |
| --- a/media/gpu/vaapi_wrapper.cc |
| +++ b/media/gpu/vaapi_wrapper.cc |
| @@ -104,12 +104,6 @@ namespace media { |
| // and not taken from HW documentation. |
| const int kMaxEncoderFramerate = 30; |
| -base::LazyInstance<VaapiWrapper::VADisplayState> |
|
scottmg
2017/01/31 21:10:34
Just confirming that you really meant for these to
DaleCurtis
2017/01/31 22:04:33
Nope, definitely did not. Totally fubared this one
|
| - VaapiWrapper::va_display_state_ = LAZY_INSTANCE_INITIALIZER; |
| - |
| -base::LazyInstance<VaapiWrapper::LazyProfileInfos> |
| - VaapiWrapper::profile_infos_ = LAZY_INSTANCE_INITIALIZER; |
| - |
| // Config attributes common for both encode and decode. |
| static const VAConfigAttrib kCommonVAConfigAttribs[] = { |
| {VAConfigAttribRTFormat, VA_RT_FORMAT_YUV420}, |
| @@ -177,7 +171,13 @@ VaapiWrapper::VaapiWrapper() |
| va_vpp_config_id_(VA_INVALID_ID), |
| va_vpp_context_id_(VA_INVALID_ID), |
| va_vpp_buffer_id_(VA_INVALID_ID) { |
| - va_lock_ = va_display_state_.Get().va_lock(); |
| + static VADisplayState* display_state = new VADisplayState(); |
| + va_display_state_ = display_state; |
| + |
| + static LazyProfileInfos* profile_infos = new LazyProfileInfos(); |
| + profile_infos_ = profile_infos; |
| + |
| + va_lock_ = va_display_state_->va_lock(); |
| } |
| VaapiWrapper::~VaapiWrapper() { |
| @@ -193,7 +193,7 @@ scoped_refptr<VaapiWrapper> VaapiWrapper::Create( |
| CodecMode mode, |
| VAProfile va_profile, |
| const base::Closure& report_error_to_uma_cb) { |
| - if (!profile_infos_.Get().IsProfileSupported(mode, va_profile)) { |
| + if (!profile_infos_->IsProfileSupported(mode, va_profile)) { |
|
scottmg
2017/01/31 21:14:51
Oh, actually, I think this won't work too. So mayb
|
| DVLOG(1) << "Unsupported va_profile: " << va_profile; |
| return nullptr; |
| } |
| @@ -223,7 +223,7 @@ VideoEncodeAccelerator::SupportedProfiles |
| VaapiWrapper::GetSupportedEncodeProfiles() { |
| VideoEncodeAccelerator::SupportedProfiles profiles; |
| std::vector<ProfileInfo> encode_profile_infos = |
| - profile_infos_.Get().GetSupportedProfileInfosForCodecMode(kEncode); |
| + profile_infos_->GetSupportedProfileInfosForCodecMode(kEncode); |
| for (size_t i = 0; i < arraysize(kProfileMap); ++i) { |
| VAProfile va_profile = ProfileToVAProfile(kProfileMap[i].profile, kEncode); |
| @@ -249,7 +249,7 @@ VideoDecodeAccelerator::SupportedProfiles |
| VaapiWrapper::GetSupportedDecodeProfiles() { |
| VideoDecodeAccelerator::SupportedProfiles profiles; |
| std::vector<ProfileInfo> decode_profile_infos = |
| - profile_infos_.Get().GetSupportedProfileInfosForCodecMode(kDecode); |
| + profile_infos_->GetSupportedProfileInfosForCodecMode(kDecode); |
| for (size_t i = 0; i < arraysize(kProfileMap); ++i) { |
| VAProfile va_profile = ProfileToVAProfile(kProfileMap[i].profile, kDecode); |
| @@ -271,8 +271,7 @@ VaapiWrapper::GetSupportedDecodeProfiles() { |
| // static |
| bool VaapiWrapper::IsJpegDecodeSupported() { |
| - return profile_infos_.Get().IsProfileSupported(kDecode, |
| - VAProfileJPEGBaseline); |
| + return profile_infos_->IsProfileSupported(kDecode, VAProfileJPEGBaseline); |
| } |
| void VaapiWrapper::TryToSetVADisplayAttributeToLocalGPU() { |
| @@ -298,15 +297,15 @@ VAProfile VaapiWrapper::ProfileToVAProfile(VideoCodecProfile profile, |
| break; |
| } |
| } |
| - if (!profile_infos_.Get().IsProfileSupported(mode, va_profile) && |
| + if (!profile_infos_->IsProfileSupported(mode, va_profile) && |
| va_profile == VAProfileH264Baseline) { |
| // crbug.com/345569: ProfileIDToVideoCodecProfile() currently strips |
| // the information whether the profile is constrained or not, so we have no |
| // way to know here. Try for baseline first, but if it is not supported, |
| // try constrained baseline and hope this is what it actually is |
| // (which in practice is true for a great majority of cases). |
| - if (profile_infos_.Get().IsProfileSupported( |
| - mode, VAProfileH264ConstrainedBaseline)) { |
| + if (profile_infos_->IsProfileSupported(mode, |
| + VAProfileH264ConstrainedBaseline)) { |
| va_profile = VAProfileH264ConstrainedBaseline; |
| DVLOG(1) << "Fall back to constrained baseline profile."; |
| } |
| @@ -364,17 +363,10 @@ bool VaapiWrapper::VaInitialize(const base::Closure& report_error_to_uma_cb) { |
| report_error_to_uma_cb_ = report_error_to_uma_cb; |
| base::AutoLock auto_lock(*va_lock_); |
| - |
| - VADisplayState* va_display_state = &va_display_state_.Get(); |
| - if (!va_display_state) { |
| - LOG(ERROR) << "Failed to allocate VA display state"; |
| - return false; |
| - } |
| - |
| - if (!va_display_state->Initialize()) |
| + if (!va_display_state_->Initialize()) |
| return false; |
| - va_display_ = va_display_state->va_display(); |
| + va_display_ = va_display_state_->va_display(); |
| return true; |
| } |
| @@ -520,12 +512,9 @@ void VaapiWrapper::Deinitialize() { |
| VA_LOG_ON_ERROR(va_res, "vaDestroyConfig failed"); |
| } |
| - VADisplayState* va_display_state = &va_display_state_.Get(); |
| - if (va_display_state) { |
| - VAStatus va_res = VA_STATUS_SUCCESS; |
| - va_display_state->Deinitialize(&va_res); |
| - VA_LOG_ON_ERROR(va_res, "vaTerminate failed"); |
| - } |
| + VAStatus va_res = VA_STATUS_SUCCESS; |
| + va_display_state->Deinitialize(&va_res); |
| + VA_LOG_ON_ERROR(va_res, "vaTerminate failed"); |
| va_config_id_ = VA_INVALID_ID; |
| va_display_ = NULL; |
| @@ -1146,7 +1135,7 @@ void VaapiWrapper::PreSandboxInitialization() { |
| base::FilePath::FromUTF8Unsafe(kDriRenderNode0Path), |
| base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE); |
| if (drm_file.IsValid()) |
| - va_display_state_.Get().SetDrmFd(drm_file.GetPlatformFile()); |
| + va_display_state_->SetDrmFd(drm_file.GetPlatformFile()); |
| #endif |
| } |