Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(865)

Unified Diff: content/common/gpu/media/vaapi_wrapper.cc

Issue 15955009: Call vaInitialize() at PreSandbox stage. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698