Chromium Code Reviews| Index: content/common/gpu/media/vaapi_wrapper.cc |
| diff --git a/content/common/gpu/media/vaapi_wrapper.cc b/content/common/gpu/media/vaapi_wrapper.cc |
| index 4734200f73b532b1d7ddf8a8e5c8d74e185ecbf9..986a2134dc089e737287438f871a8edcc12598c6 100644 |
| --- a/content/common/gpu/media/vaapi_wrapper.cc |
| +++ b/content/common/gpu/media/vaapi_wrapper.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/bind.h" |
| #include "base/logging.h" |
| +#include "base/message_loop.h" |
|
Ami GONE FROM CHROMIUM
2013/05/31 16:19:24
This is a pretty unobvious #include for GetDefault
|
| #include "content/common/gpu/media/vaapi_wrapper.h" |
| #define LOG_VA_ERROR_AND_REPORT(va_error, err_msg) \ |
| @@ -411,13 +412,44 @@ void VaapiWrapper::PreSandboxInitialization() { |
| vaapi_handle = dlopen("libva.so.1", RTLD_NOW); |
| vaapi_x11_handle = dlopen("libva-x11.so.1", RTLD_NOW); |
| pre_sandbox_init_done_ = vaapi_handle && vaapi_x11_handle; |
| + |
| + if(!pre_sandbox_init_done_) |
| + return; |
| + |
| +#define VAAPI_DLSYM_OR_RETURN_ON_ERROR(name, handle) \ |
|
Ami GONE FROM CHROMIUM
2013/05/31 16:19:24
This doesn't need to be a macro (and doesn't need
|
| + do { \ |
| + VAAPI_##name = reinterpret_cast<Vaapi##name>(dlsym((handle), "va"#name)); \ |
| + if (VAAPI_##name == NULL) { \ |
| + DVLOG(1) << "Failed to dlsym va"#name; \ |
| + pre_sandbox_init_done_ = false; \ |
| + return; \ |
| + } \ |
| + } while (0) |
| + |
| + VAAPI_DLSYM_OR_RETURN_ON_ERROR(DisplayIsValid, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_ON_ERROR(GetDisplay, vaapi_x11_handle); |
| + VAAPI_DLSYM_OR_RETURN_ON_ERROR(Initialize, vaapi_handle); |
| + |
| + Display *x_display = base::MessagePumpForUI::GetDefaultXDisplay(); |
| + VADisplay va_display = VAAPI_GetDisplay(x_display); |
| + |
| + if (VAAPI_DisplayIsValid(va_display)) { |
| + int major_version, minor_version; |
| + VAStatus va_res; |
| + va_res = VAAPI_Initialize(va_display, &major_version, &minor_version); |
| + if (va_res != VA_STATUS_SUCCESS) |
| + pre_sandbox_init_done_ = false; |
| + } else { |
| + pre_sandbox_init_done_ = false; |
| + } |
| + |
| } |
| // static |
| bool VaapiWrapper::PostSandboxInitialization() { |
| if (!pre_sandbox_init_done_) |
| return false; |
| -#define VAAPI_DLSYM_OR_RETURN_ON_ERROR(name, handle) \ |
| +#define VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(name, handle) \ |
| do { \ |
| VAAPI_##name = reinterpret_cast<Vaapi##name>(dlsym((handle), "va"#name)); \ |
| if (VAAPI_##name == NULL) { \ |
| @@ -426,25 +458,22 @@ bool VaapiWrapper::PostSandboxInitialization() { |
| } \ |
| } while (0) |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(BeginPicture, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(CreateBuffer, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(CreateConfig, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(CreateContext, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(CreateSurfaces, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(DestroyBuffer, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(DestroyConfig, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(DestroyContext, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(DestroySurfaces, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(DisplayIsValid, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(EndPicture, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(ErrorStr, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(GetConfigAttributes, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(GetDisplay, vaapi_x11_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(Initialize, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(PutSurface, vaapi_x11_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(RenderPicture, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(SyncSurface, vaapi_handle); |
| - VAAPI_DLSYM_OR_RETURN_ON_ERROR(Terminate, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(BeginPicture, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(CreateBuffer, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(CreateConfig, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(CreateContext, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(CreateSurfaces, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(DestroyBuffer, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(DestroyConfig, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(DestroyContext, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(DestroySurfaces, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(EndPicture, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(ErrorStr, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(GetConfigAttributes, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(PutSurface, vaapi_x11_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(RenderPicture, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(SyncSurface, vaapi_handle); |
| + VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(Terminate, vaapi_handle); |
| #undef VAAPI_DLSYM |
| return true; |