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 <dlfcn.h> | 5 #include <dlfcn.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | |
Ami GONE FROM CHROMIUM
2013/05/31 16:19:24
This is a pretty unobvious #include for GetDefault
| |
9 #include "content/common/gpu/media/vaapi_wrapper.h" | 10 #include "content/common/gpu/media/vaapi_wrapper.h" |
10 | 11 |
11 #define LOG_VA_ERROR_AND_REPORT(va_error, err_msg) \ | 12 #define LOG_VA_ERROR_AND_REPORT(va_error, err_msg) \ |
12 do { \ | 13 do { \ |
13 DVLOG(1) << err_msg \ | 14 DVLOG(1) << err_msg \ |
14 << " VA error: " << VAAPI_ErrorStr(va_error); \ | 15 << " VA error: " << VAAPI_ErrorStr(va_error); \ |
15 report_error_to_uma_cb_.Run(); \ | 16 report_error_to_uma_cb_.Run(); \ |
16 } while (0) | 17 } while (0) |
17 | 18 |
18 #define VA_LOG_ON_ERROR(va_error, err_msg) \ | 19 #define VA_LOG_ON_ERROR(va_error, err_msg) \ |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 | 405 |
405 // static | 406 // static |
406 bool VaapiWrapper::pre_sandbox_init_done_ = false; | 407 bool VaapiWrapper::pre_sandbox_init_done_ = false; |
407 | 408 |
408 // static | 409 // static |
409 void VaapiWrapper::PreSandboxInitialization() { | 410 void VaapiWrapper::PreSandboxInitialization() { |
410 DCHECK(!pre_sandbox_init_done_); | 411 DCHECK(!pre_sandbox_init_done_); |
411 vaapi_handle = dlopen("libva.so.1", RTLD_NOW); | 412 vaapi_handle = dlopen("libva.so.1", RTLD_NOW); |
412 vaapi_x11_handle = dlopen("libva-x11.so.1", RTLD_NOW); | 413 vaapi_x11_handle = dlopen("libva-x11.so.1", RTLD_NOW); |
413 pre_sandbox_init_done_ = vaapi_handle && vaapi_x11_handle; | 414 pre_sandbox_init_done_ = vaapi_handle && vaapi_x11_handle; |
415 | |
416 if(!pre_sandbox_init_done_) | |
417 return; | |
418 | |
419 #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
| |
420 do { \ | |
421 VAAPI_##name = reinterpret_cast<Vaapi##name>(dlsym((handle), "va"#name)); \ | |
422 if (VAAPI_##name == NULL) { \ | |
423 DVLOG(1) << "Failed to dlsym va"#name; \ | |
424 pre_sandbox_init_done_ = false; \ | |
425 return; \ | |
426 } \ | |
427 } while (0) | |
428 | |
429 VAAPI_DLSYM_OR_RETURN_ON_ERROR(DisplayIsValid, vaapi_handle); | |
430 VAAPI_DLSYM_OR_RETURN_ON_ERROR(GetDisplay, vaapi_x11_handle); | |
431 VAAPI_DLSYM_OR_RETURN_ON_ERROR(Initialize, vaapi_handle); | |
432 | |
433 Display *x_display = base::MessagePumpForUI::GetDefaultXDisplay(); | |
434 VADisplay va_display = VAAPI_GetDisplay(x_display); | |
435 | |
436 if (VAAPI_DisplayIsValid(va_display)) { | |
437 int major_version, minor_version; | |
438 VAStatus va_res; | |
439 va_res = VAAPI_Initialize(va_display, &major_version, &minor_version); | |
440 if (va_res != VA_STATUS_SUCCESS) | |
441 pre_sandbox_init_done_ = false; | |
442 } else { | |
443 pre_sandbox_init_done_ = false; | |
444 } | |
445 | |
414 } | 446 } |
415 | 447 |
416 // static | 448 // static |
417 bool VaapiWrapper::PostSandboxInitialization() { | 449 bool VaapiWrapper::PostSandboxInitialization() { |
418 if (!pre_sandbox_init_done_) | 450 if (!pre_sandbox_init_done_) |
419 return false; | 451 return false; |
420 #define VAAPI_DLSYM_OR_RETURN_ON_ERROR(name, handle) \ | 452 #define VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(name, handle) \ |
421 do { \ | 453 do { \ |
422 VAAPI_##name = reinterpret_cast<Vaapi##name>(dlsym((handle), "va"#name)); \ | 454 VAAPI_##name = reinterpret_cast<Vaapi##name>(dlsym((handle), "va"#name)); \ |
423 if (VAAPI_##name == NULL) { \ | 455 if (VAAPI_##name == NULL) { \ |
424 DVLOG(1) << "Failed to dlsym va"#name; \ | 456 DVLOG(1) << "Failed to dlsym va"#name; \ |
425 return false; \ | 457 return false; \ |
426 } \ | 458 } \ |
427 } while (0) | 459 } while (0) |
428 | 460 |
429 VAAPI_DLSYM_OR_RETURN_ON_ERROR(BeginPicture, vaapi_handle); | 461 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(BeginPicture, vaapi_handle); |
430 VAAPI_DLSYM_OR_RETURN_ON_ERROR(CreateBuffer, vaapi_handle); | 462 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(CreateBuffer, vaapi_handle); |
431 VAAPI_DLSYM_OR_RETURN_ON_ERROR(CreateConfig, vaapi_handle); | 463 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(CreateConfig, vaapi_handle); |
432 VAAPI_DLSYM_OR_RETURN_ON_ERROR(CreateContext, vaapi_handle); | 464 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(CreateContext, vaapi_handle); |
433 VAAPI_DLSYM_OR_RETURN_ON_ERROR(CreateSurfaces, vaapi_handle); | 465 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(CreateSurfaces, vaapi_handle); |
434 VAAPI_DLSYM_OR_RETURN_ON_ERROR(DestroyBuffer, vaapi_handle); | 466 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(DestroyBuffer, vaapi_handle); |
435 VAAPI_DLSYM_OR_RETURN_ON_ERROR(DestroyConfig, vaapi_handle); | 467 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(DestroyConfig, vaapi_handle); |
436 VAAPI_DLSYM_OR_RETURN_ON_ERROR(DestroyContext, vaapi_handle); | 468 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(DestroyContext, vaapi_handle); |
437 VAAPI_DLSYM_OR_RETURN_ON_ERROR(DestroySurfaces, vaapi_handle); | 469 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(DestroySurfaces, vaapi_handle); |
438 VAAPI_DLSYM_OR_RETURN_ON_ERROR(DisplayIsValid, vaapi_handle); | 470 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(EndPicture, vaapi_handle); |
439 VAAPI_DLSYM_OR_RETURN_ON_ERROR(EndPicture, vaapi_handle); | 471 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(ErrorStr, vaapi_handle); |
440 VAAPI_DLSYM_OR_RETURN_ON_ERROR(ErrorStr, vaapi_handle); | 472 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(GetConfigAttributes, vaapi_handle); |
441 VAAPI_DLSYM_OR_RETURN_ON_ERROR(GetConfigAttributes, vaapi_handle); | 473 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(PutSurface, vaapi_x11_handle); |
442 VAAPI_DLSYM_OR_RETURN_ON_ERROR(GetDisplay, vaapi_x11_handle); | 474 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(RenderPicture, vaapi_handle); |
443 VAAPI_DLSYM_OR_RETURN_ON_ERROR(Initialize, vaapi_handle); | 475 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(SyncSurface, vaapi_handle); |
444 VAAPI_DLSYM_OR_RETURN_ON_ERROR(PutSurface, vaapi_x11_handle); | 476 VAAPI_DLSYM_OR_RETURN_BOOL_ON_ERROR(Terminate, vaapi_handle); |
445 VAAPI_DLSYM_OR_RETURN_ON_ERROR(RenderPicture, vaapi_handle); | |
446 VAAPI_DLSYM_OR_RETURN_ON_ERROR(SyncSurface, vaapi_handle); | |
447 VAAPI_DLSYM_OR_RETURN_ON_ERROR(Terminate, vaapi_handle); | |
448 #undef VAAPI_DLSYM | 477 #undef VAAPI_DLSYM |
449 | 478 |
450 return true; | 479 return true; |
451 } | 480 } |
452 | 481 |
453 } // namespace content | 482 } // namespace content |
OLD | NEW |