OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/common/gpu/media/vaapi_wrapper.h" | 5 #include "content/common/gpu/media/vaapi_wrapper.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 return (ret); \ | 55 return (ret); \ |
56 } \ | 56 } \ |
57 } while (0) | 57 } while (0) |
58 | 58 |
59 namespace content { | 59 namespace content { |
60 | 60 |
61 // Maximum framerate of encoded profile. This value is an arbitary limit | 61 // Maximum framerate of encoded profile. This value is an arbitary limit |
62 // and not taken from HW documentation. | 62 // and not taken from HW documentation. |
63 const int kMaxEncoderFramerate = 30; | 63 const int kMaxEncoderFramerate = 30; |
64 | 64 |
65 #if defined(USE_OZONE) | |
66 base::LazyInstance<base::File> | |
67 VaapiWrapper::drm_file_ = LAZY_INSTANCE_INITIALIZER; | |
68 #endif | |
69 | |
65 base::LazyInstance<VaapiWrapper::LazyProfileInfos> | 70 base::LazyInstance<VaapiWrapper::LazyProfileInfos> |
66 VaapiWrapper::profile_infos_ = LAZY_INSTANCE_INITIALIZER; | 71 VaapiWrapper::profile_infos_ = LAZY_INSTANCE_INITIALIZER; |
67 | 72 |
68 // Config attributes common for both encode and decode. | 73 // Config attributes common for both encode and decode. |
69 static const VAConfigAttrib kCommonVAConfigAttribs[] = { | 74 static const VAConfigAttrib kCommonVAConfigAttribs[] = { |
70 {VAConfigAttribRTFormat, VA_RT_FORMAT_YUV420}, | 75 {VAConfigAttribRTFormat, VA_RT_FORMAT_YUV420}, |
71 }; | 76 }; |
72 | 77 |
73 // Attributes required for encode. | 78 // Attributes required for encode. |
74 static const VAConfigAttrib kEncodeVAConfigAttribs[] = { | 79 static const VAConfigAttrib kEncodeVAConfigAttribs[] = { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 return false; | 315 return false; |
311 } | 316 } |
312 | 317 |
313 report_error_to_uma_cb_ = report_error_to_uma_cb; | 318 report_error_to_uma_cb_ = report_error_to_uma_cb; |
314 | 319 |
315 base::AutoLock auto_lock(va_lock_); | 320 base::AutoLock auto_lock(va_lock_); |
316 | 321 |
317 #if defined(USE_X11) | 322 #if defined(USE_X11) |
318 va_display_ = vaGetDisplay(gfx::GetXDisplay()); | 323 va_display_ = vaGetDisplay(gfx::GetXDisplay()); |
319 #elif defined(USE_OZONE) | 324 #elif defined(USE_OZONE) |
320 const char* kDriRenderNode0Path = "/dev/dri/renderD128"; | 325 va_display_ = vaGetDisplayDRM(drm_file_.Get().GetPlatformFile()); |
dnicoara
2015/05/07 21:17:09
Previously, weren't we crashing because of double
hshi1
2015/05/07 21:50:17
The double close (bug 464628) was because we're us
dnicoara
2015/05/07 22:04:27
Are you sure VAApiWrapper is shared? If I open mul
| |
321 drm_file_ = base::File(base::FilePath::FromUTF8Unsafe(kDriRenderNode0Path), | |
322 base::File::FLAG_OPEN | base::File::FLAG_READ | | |
323 base::File::FLAG_WRITE); | |
324 va_display_ = vaGetDisplayDRM(drm_file_.GetPlatformFile()); | |
325 #endif // USE_X11 | 326 #endif // USE_X11 |
326 | 327 |
327 if (!vaDisplayIsValid(va_display_)) { | 328 if (!vaDisplayIsValid(va_display_)) { |
328 LOG(ERROR) << "Could not get a valid VA display"; | 329 LOG(ERROR) << "Could not get a valid VA display"; |
329 return false; | 330 return false; |
330 } | 331 } |
331 | 332 |
332 VAStatus va_res = vaInitialize(va_display_, &major_version_, &minor_version_); | 333 VAStatus va_res = vaInitialize(va_display_, &major_version_, &minor_version_); |
333 VA_SUCCESS_OR_RETURN(va_res, "vaInitialize failed", false); | 334 VA_SUCCESS_OR_RETURN(va_res, "vaInitialize failed", false); |
334 va_initialized_ = true; | 335 va_initialized_ = true; |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1035 vaDestroyContext(va_display_, va_vpp_context_id_); | 1036 vaDestroyContext(va_display_, va_vpp_context_id_); |
1036 va_vpp_context_id_ = VA_INVALID_ID; | 1037 va_vpp_context_id_ = VA_INVALID_ID; |
1037 } | 1038 } |
1038 if (va_vpp_config_id_ != VA_INVALID_ID) { | 1039 if (va_vpp_config_id_ != VA_INVALID_ID) { |
1039 vaDestroyConfig(va_display_, va_vpp_config_id_); | 1040 vaDestroyConfig(va_display_, va_vpp_config_id_); |
1040 va_vpp_config_id_ = VA_INVALID_ID; | 1041 va_vpp_config_id_ = VA_INVALID_ID; |
1041 } | 1042 } |
1042 } | 1043 } |
1043 | 1044 |
1044 // static | 1045 // static |
1046 void VaapiWrapper::PreSandboxInitialization() { | |
1047 #if defined(USE_OZONE) | |
1048 const char* kDriRenderNode0Path = "/dev/dri/renderD128"; | |
1049 drm_file_.Get().Initialize( | |
1050 base::FilePath::FromUTF8Unsafe(kDriRenderNode0Path), | |
1051 base::File::FLAG_OPEN | base::File::FLAG_READ | | |
1052 base::File::FLAG_WRITE); | |
1053 #endif | |
1054 } | |
1055 | |
1056 // static | |
1045 bool VaapiWrapper::PostSandboxInitialization() { | 1057 bool VaapiWrapper::PostSandboxInitialization() { |
1046 StubPathMap paths; | 1058 StubPathMap paths; |
1047 | 1059 |
1048 paths[kModuleVa].push_back("libva.so.1"); | 1060 paths[kModuleVa].push_back("libva.so.1"); |
1049 | 1061 |
1050 #if defined(USE_X11) | 1062 #if defined(USE_X11) |
1051 paths[kModuleVa_x11].push_back("libva-x11.so.1"); | 1063 paths[kModuleVa_x11].push_back("libva-x11.so.1"); |
1052 #elif defined(USE_OZONE) | 1064 #elif defined(USE_OZONE) |
1053 paths[kModuleVa_drm].push_back("libva-drm.so.1"); | 1065 paths[kModuleVa_drm].push_back("libva-drm.so.1"); |
1054 #endif | 1066 #endif |
(...skipping 26 matching lines...) Expand all Loading... | |
1081 bool VaapiWrapper::LazyProfileInfos::IsProfileSupported( | 1093 bool VaapiWrapper::LazyProfileInfos::IsProfileSupported( |
1082 CodecMode mode, VAProfile va_profile) { | 1094 CodecMode mode, VAProfile va_profile) { |
1083 for (const auto& profile : supported_profiles_[mode]) { | 1095 for (const auto& profile : supported_profiles_[mode]) { |
1084 if (profile.va_profile == va_profile) | 1096 if (profile.va_profile == va_profile) |
1085 return true; | 1097 return true; |
1086 } | 1098 } |
1087 return false; | 1099 return false; |
1088 } | 1100 } |
1089 | 1101 |
1090 } // namespace content | 1102 } // namespace content |
OLD | NEW |