Created
February 26, 2014 02:32
-
-
Save halton/9222419 to your computer and use it in GitHub Desktop.
va_stub files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is generated file. Do not modify directly. | |
#include "content/common/gpu/media/va_stubs.h" | |
#include <stdlib.h> // For NULL. | |
#include <dlfcn.h> // For dysym, dlopen. | |
#include <map> | |
#include <vector> | |
// The extra include header needed in the generated stub file for defining | |
// various libva types. | |
extern "C" { | |
#include "third_party/libva/va/va.h" | |
#include "third_party/libva/va/va_x11.h" | |
} | |
extern "C" { | |
// Static pointers that will hold the location of the real function | |
// implementations after the module has been loaded. | |
static VAStatus (*vaBeginPicture_ptr)(VADisplay dpy, VAContextID context, VASurfaceID render_target) = NULL; | |
static VAStatus (*vaCreateBuffer_ptr)(VADisplay dpy, VAContextID context, VABufferType type, unsigned int size, unsigned int num_elements, void *data, VABufferID *buf_id) = NULL; | |
static VAStatus (*vaCreateConfig_ptr)(VADisplay dpy, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id) = NULL; | |
static VAStatus (*vaCreateContext_ptr)(VADisplay dpy, VAConfigID config_id, int picture_width, int picture_height, int flag, VASurfaceID *render_targets, int num_render_targets, VAContextID *context) = NULL; | |
static VAStatus (*vaCreateSurfaces_ptr)(VADisplay dpy, unsigned int format, unsigned int width, unsigned int height, VASurfaceID *surfaces, unsigned int num_surfaces, VASurfaceAttrib *attrib_list, unsigned int num_attribs) = NULL; | |
static VAStatus (*vaDeriveImage_ptr)(VADisplay dpy, VASurfaceID surface, VAImage *image) = NULL; | |
static VAStatus (*vaDestroyBuffer_ptr)(VADisplay dpy, VABufferID buffer_id) = NULL; | |
static VAStatus (*vaDestroyConfig_ptr)(VADisplay dpy, VAConfigID config_id) = NULL; | |
static VAStatus (*vaDestroyContext_ptr)(VADisplay dpy, VAContextID context) = NULL; | |
static VAStatus (*vaDestroyImage_ptr)(VADisplay dpy, VAImageID image) = NULL; | |
static VAStatus (*vaDestroySurfaces_ptr)(VADisplay dpy, VASurfaceID *surfaces, int num_surfaces) = NULL; | |
static int (*vaDisplayIsValid_ptr)(VADisplay dpy) = NULL; | |
static VAStatus (*vaEndPicture_ptr)(VADisplay dpy, VAContextID context) = NULL; | |
static const char * (*vaErrorStr_ptr)(VAStatus error_status) = NULL; | |
static VAStatus (*vaGetConfigAttributes_ptr)(VADisplay dpy, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs) = NULL; | |
static VAStatus (*vaInitialize_ptr)(VADisplay dpy, int *major_version, int *minor_version) = NULL; | |
static VAStatus (*vaMapBuffer_ptr)(VADisplay dpy, VABufferID buf_id, void **pbuf) = NULL; | |
static VAStatus (*vaRenderPicture_ptr)(VADisplay dpy, VAContextID context, VABufferID *buffers, int num_buffers) = NULL; | |
static VAStatus (*vaSetDisplayAttributes_ptr)(VADisplay dpy, VADisplayAttribute *attr_list, int num_attributes) = NULL; | |
static VAStatus (*vaSyncSurface_ptr)(VADisplay dpy, VASurfaceID render_target) = NULL; | |
static VAStatus (*vaTerminate_ptr)(VADisplay dpy) = NULL; | |
static VAStatus (*vaUnmapBuffer_ptr)(VADisplay dpy, VABufferID buf_id) = NULL; | |
static VADisplay (*vaGetDisplay_ptr)(Display *dpy) = NULL; | |
static VAStatus (*vaPutSurface_ptr)(VADisplay dpy, VASurfaceID surface, Drawable draw, short srcx, short srcy, unsigned short srcw, unsigned short srch, short destx, short desty, unsigned short destw, unsigned short desth, VARectangle *cliprects, unsigned int number_cliprects, unsigned int flags) = NULL; | |
// Stubs that dispatch to the real implementations. | |
extern VAStatus vaBeginPicture(VADisplay dpy, VAContextID context, VASurfaceID render_target) __attribute__((weak)); | |
VAStatus vaBeginPicture(VADisplay dpy, VAContextID context, VASurfaceID render_target) { | |
return vaBeginPicture_ptr(dpy, context, render_target); | |
} | |
extern VAStatus vaCreateBuffer(VADisplay dpy, VAContextID context, VABufferType type, unsigned int size, unsigned int num_elements, void *data, VABufferID *buf_id) __attribute__((weak)); | |
VAStatus vaCreateBuffer(VADisplay dpy, VAContextID context, VABufferType type, unsigned int size, unsigned int num_elements, void *data, VABufferID *buf_id) { | |
return vaCreateBuffer_ptr(dpy, context, type, size, num_elements, data, buf_id); | |
} | |
extern VAStatus vaCreateConfig(VADisplay dpy, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id) __attribute__((weak)); | |
VAStatus vaCreateConfig(VADisplay dpy, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id) { | |
return vaCreateConfig_ptr(dpy, profile, entrypoint, attrib_list, num_attribs, config_id); | |
} | |
extern VAStatus vaCreateContext(VADisplay dpy, VAConfigID config_id, int picture_width, int picture_height, int flag, VASurfaceID *render_targets, int num_render_targets, VAContextID *context) __attribute__((weak)); | |
VAStatus vaCreateContext(VADisplay dpy, VAConfigID config_id, int picture_width, int picture_height, int flag, VASurfaceID *render_targets, int num_render_targets, VAContextID *context) { | |
return vaCreateContext_ptr(dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context); | |
} | |
extern VAStatus vaCreateSurfaces(VADisplay dpy, unsigned int format, unsigned int width, unsigned int height, VASurfaceID *surfaces, unsigned int num_surfaces, VASurfaceAttrib *attrib_list, unsigned int num_attribs) __attribute__((weak)); | |
VAStatus vaCreateSurfaces(VADisplay dpy, unsigned int format, unsigned int width, unsigned int height, VASurfaceID *surfaces, unsigned int num_surfaces, VASurfaceAttrib *attrib_list, unsigned int num_attribs) { | |
return vaCreateSurfaces_ptr(dpy, format, width, height, surfaces, num_surfaces, attrib_list, num_attribs); | |
} | |
extern VAStatus vaDeriveImage(VADisplay dpy, VASurfaceID surface, VAImage *image) __attribute__((weak)); | |
VAStatus vaDeriveImage(VADisplay dpy, VASurfaceID surface, VAImage *image) { | |
return vaDeriveImage_ptr(dpy, surface, image); | |
} | |
extern VAStatus vaDestroyBuffer(VADisplay dpy, VABufferID buffer_id) __attribute__((weak)); | |
VAStatus vaDestroyBuffer(VADisplay dpy, VABufferID buffer_id) { | |
return vaDestroyBuffer_ptr(dpy, buffer_id); | |
} | |
extern VAStatus vaDestroyConfig(VADisplay dpy, VAConfigID config_id) __attribute__((weak)); | |
VAStatus vaDestroyConfig(VADisplay dpy, VAConfigID config_id) { | |
return vaDestroyConfig_ptr(dpy, config_id); | |
} | |
extern VAStatus vaDestroyContext(VADisplay dpy, VAContextID context) __attribute__((weak)); | |
VAStatus vaDestroyContext(VADisplay dpy, VAContextID context) { | |
return vaDestroyContext_ptr(dpy, context); | |
} | |
extern VAStatus vaDestroyImage(VADisplay dpy, VAImageID image) __attribute__((weak)); | |
VAStatus vaDestroyImage(VADisplay dpy, VAImageID image) { | |
return vaDestroyImage_ptr(dpy, image); | |
} | |
extern VAStatus vaDestroySurfaces(VADisplay dpy, VASurfaceID *surfaces, int num_surfaces) __attribute__((weak)); | |
VAStatus vaDestroySurfaces(VADisplay dpy, VASurfaceID *surfaces, int num_surfaces) { | |
return vaDestroySurfaces_ptr(dpy, surfaces, num_surfaces); | |
} | |
extern int vaDisplayIsValid(VADisplay dpy) __attribute__((weak)); | |
int vaDisplayIsValid(VADisplay dpy) { | |
return vaDisplayIsValid_ptr(dpy); | |
} | |
extern VAStatus vaEndPicture(VADisplay dpy, VAContextID context) __attribute__((weak)); | |
VAStatus vaEndPicture(VADisplay dpy, VAContextID context) { | |
return vaEndPicture_ptr(dpy, context); | |
} | |
extern const char * vaErrorStr(VAStatus error_status) __attribute__((weak)); | |
const char * vaErrorStr(VAStatus error_status) { | |
return vaErrorStr_ptr(error_status); | |
} | |
extern VAStatus vaGetConfigAttributes(VADisplay dpy, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs) __attribute__((weak)); | |
VAStatus vaGetConfigAttributes(VADisplay dpy, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs) { | |
return vaGetConfigAttributes_ptr(dpy, profile, entrypoint, attrib_list, num_attribs); | |
} | |
extern VAStatus vaInitialize(VADisplay dpy, int *major_version, int *minor_version) __attribute__((weak)); | |
VAStatus vaInitialize(VADisplay dpy, int *major_version, int *minor_version) { | |
return vaInitialize_ptr(dpy, major_version, minor_version); | |
} | |
extern VAStatus vaMapBuffer(VADisplay dpy, VABufferID buf_id, void **pbuf) __attribute__((weak)); | |
VAStatus vaMapBuffer(VADisplay dpy, VABufferID buf_id, void **pbuf) { | |
return vaMapBuffer_ptr(dpy, buf_id, pbuf); | |
} | |
extern VAStatus vaRenderPicture(VADisplay dpy, VAContextID context, VABufferID *buffers, int num_buffers) __attribute__((weak)); | |
VAStatus vaRenderPicture(VADisplay dpy, VAContextID context, VABufferID *buffers, int num_buffers) { | |
return vaRenderPicture_ptr(dpy, context, buffers, num_buffers); | |
} | |
extern VAStatus vaSetDisplayAttributes(VADisplay dpy, VADisplayAttribute *attr_list, int num_attributes) __attribute__((weak)); | |
VAStatus vaSetDisplayAttributes(VADisplay dpy, VADisplayAttribute *attr_list, int num_attributes) { | |
return vaSetDisplayAttributes_ptr(dpy, attr_list, num_attributes); | |
} | |
extern VAStatus vaSyncSurface(VADisplay dpy, VASurfaceID render_target) __attribute__((weak)); | |
VAStatus vaSyncSurface(VADisplay dpy, VASurfaceID render_target) { | |
return vaSyncSurface_ptr(dpy, render_target); | |
} | |
extern VAStatus vaTerminate(VADisplay dpy) __attribute__((weak)); | |
VAStatus vaTerminate(VADisplay dpy) { | |
return vaTerminate_ptr(dpy); | |
} | |
extern VAStatus vaUnmapBuffer(VADisplay dpy, VABufferID buf_id) __attribute__((weak)); | |
VAStatus vaUnmapBuffer(VADisplay dpy, VABufferID buf_id) { | |
return vaUnmapBuffer_ptr(dpy, buf_id); | |
} | |
extern VADisplay vaGetDisplay(Display *dpy) __attribute__((weak)); | |
VADisplay vaGetDisplay(Display *dpy) { | |
return vaGetDisplay_ptr(dpy); | |
} | |
extern VAStatus vaPutSurface(VADisplay dpy, VASurfaceID surface, Drawable draw, short srcx, short srcy, unsigned short srcw, unsigned short srch, short destx, short desty, unsigned short destw, unsigned short desth, VARectangle *cliprects, unsigned int number_cliprects, unsigned int flags) __attribute__((weak)); | |
VAStatus vaPutSurface(VADisplay dpy, VASurfaceID surface, Drawable draw, short srcx, short srcy, unsigned short srcw, unsigned short srch, short destx, short desty, unsigned short destw, unsigned short desth, VARectangle *cliprects, unsigned int number_cliprects, unsigned int flags) { | |
return vaPutSurface_ptr(dpy, surface, draw, srcx, srcy, srcw, srch, destx, desty, destw, desth, cliprects, number_cliprects, flags); | |
} | |
} // extern "C" | |
namespace content_common_gpu_media { | |
// Returns true if all stubs have been properly initialized. | |
bool IsVaInitialized() { | |
if (vaBeginPicture_ptr && | |
vaCreateBuffer_ptr && | |
vaCreateConfig_ptr && | |
vaCreateContext_ptr && | |
vaCreateSurfaces_ptr && | |
vaDeriveImage_ptr && | |
vaDestroyBuffer_ptr && | |
vaDestroyConfig_ptr && | |
vaDestroyContext_ptr && | |
vaDestroyImage_ptr && | |
vaDestroySurfaces_ptr && | |
vaDisplayIsValid_ptr && | |
vaEndPicture_ptr && | |
vaErrorStr_ptr && | |
vaGetConfigAttributes_ptr && | |
vaInitialize_ptr && | |
vaMapBuffer_ptr && | |
vaRenderPicture_ptr && | |
vaSetDisplayAttributes_ptr && | |
vaSyncSurface_ptr && | |
vaTerminate_ptr && | |
vaUnmapBuffer_ptr && | |
vaGetDisplay_ptr && | |
vaPutSurface_ptr) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
// Initializes the module stubs. | |
void InitializeVa(void* module) { | |
vaBeginPicture_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAContextID context, VASurfaceID render_target)>( | |
dlsym(module, "vaBeginPicture")); | |
VLOG_IF(1, !vaBeginPicture_ptr) << "Couldn't load vaBeginPicture, dlerror() says:\n" | |
<< dlerror(); | |
vaCreateBuffer_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAContextID context, VABufferType type, unsigned int size, unsigned int num_elements, void *data, VABufferID *buf_id)>( | |
dlsym(module, "vaCreateBuffer")); | |
VLOG_IF(1, !vaCreateBuffer_ptr) << "Couldn't load vaCreateBuffer, dlerror() says:\n" | |
<< dlerror(); | |
vaCreateConfig_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id)>( | |
dlsym(module, "vaCreateConfig")); | |
VLOG_IF(1, !vaCreateConfig_ptr) << "Couldn't load vaCreateConfig, dlerror() says:\n" | |
<< dlerror(); | |
vaCreateContext_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAConfigID config_id, int picture_width, int picture_height, int flag, VASurfaceID *render_targets, int num_render_targets, VAContextID *context)>( | |
dlsym(module, "vaCreateContext")); | |
VLOG_IF(1, !vaCreateContext_ptr) << "Couldn't load vaCreateContext, dlerror() says:\n" | |
<< dlerror(); | |
vaCreateSurfaces_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, unsigned int format, unsigned int width, unsigned int height, VASurfaceID *surfaces, unsigned int num_surfaces, VASurfaceAttrib *attrib_list, unsigned int num_attribs)>( | |
dlsym(module, "vaCreateSurfaces")); | |
VLOG_IF(1, !vaCreateSurfaces_ptr) << "Couldn't load vaCreateSurfaces, dlerror() says:\n" | |
<< dlerror(); | |
vaDeriveImage_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VASurfaceID surface, VAImage *image)>( | |
dlsym(module, "vaDeriveImage")); | |
VLOG_IF(1, !vaDeriveImage_ptr) << "Couldn't load vaDeriveImage, dlerror() says:\n" | |
<< dlerror(); | |
vaDestroyBuffer_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VABufferID buffer_id)>( | |
dlsym(module, "vaDestroyBuffer")); | |
VLOG_IF(1, !vaDestroyBuffer_ptr) << "Couldn't load vaDestroyBuffer, dlerror() says:\n" | |
<< dlerror(); | |
vaDestroyConfig_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAConfigID config_id)>( | |
dlsym(module, "vaDestroyConfig")); | |
VLOG_IF(1, !vaDestroyConfig_ptr) << "Couldn't load vaDestroyConfig, dlerror() says:\n" | |
<< dlerror(); | |
vaDestroyContext_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAContextID context)>( | |
dlsym(module, "vaDestroyContext")); | |
VLOG_IF(1, !vaDestroyContext_ptr) << "Couldn't load vaDestroyContext, dlerror() says:\n" | |
<< dlerror(); | |
vaDestroyImage_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAImageID image)>( | |
dlsym(module, "vaDestroyImage")); | |
VLOG_IF(1, !vaDestroyImage_ptr) << "Couldn't load vaDestroyImage, dlerror() says:\n" | |
<< dlerror(); | |
vaDestroySurfaces_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VASurfaceID *surfaces, int num_surfaces)>( | |
dlsym(module, "vaDestroySurfaces")); | |
VLOG_IF(1, !vaDestroySurfaces_ptr) << "Couldn't load vaDestroySurfaces, dlerror() says:\n" | |
<< dlerror(); | |
vaDisplayIsValid_ptr = | |
reinterpret_cast<int (*)(VADisplay dpy)>( | |
dlsym(module, "vaDisplayIsValid")); | |
VLOG_IF(1, !vaDisplayIsValid_ptr) << "Couldn't load vaDisplayIsValid, dlerror() says:\n" | |
<< dlerror(); | |
vaEndPicture_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAContextID context)>( | |
dlsym(module, "vaEndPicture")); | |
VLOG_IF(1, !vaEndPicture_ptr) << "Couldn't load vaEndPicture, dlerror() says:\n" | |
<< dlerror(); | |
vaErrorStr_ptr = | |
reinterpret_cast<const char * (*)(VAStatus error_status)>( | |
dlsym(module, "vaErrorStr")); | |
VLOG_IF(1, !vaErrorStr_ptr) << "Couldn't load vaErrorStr, dlerror() says:\n" | |
<< dlerror(); | |
vaGetConfigAttributes_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs)>( | |
dlsym(module, "vaGetConfigAttributes")); | |
VLOG_IF(1, !vaGetConfigAttributes_ptr) << "Couldn't load vaGetConfigAttributes, dlerror() says:\n" | |
<< dlerror(); | |
vaInitialize_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, int *major_version, int *minor_version)>( | |
dlsym(module, "vaInitialize")); | |
VLOG_IF(1, !vaInitialize_ptr) << "Couldn't load vaInitialize, dlerror() says:\n" | |
<< dlerror(); | |
vaMapBuffer_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VABufferID buf_id, void **pbuf)>( | |
dlsym(module, "vaMapBuffer")); | |
VLOG_IF(1, !vaMapBuffer_ptr) << "Couldn't load vaMapBuffer, dlerror() says:\n" | |
<< dlerror(); | |
vaRenderPicture_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VAContextID context, VABufferID *buffers, int num_buffers)>( | |
dlsym(module, "vaRenderPicture")); | |
VLOG_IF(1, !vaRenderPicture_ptr) << "Couldn't load vaRenderPicture, dlerror() says:\n" | |
<< dlerror(); | |
vaSetDisplayAttributes_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VADisplayAttribute *attr_list, int num_attributes)>( | |
dlsym(module, "vaSetDisplayAttributes")); | |
VLOG_IF(1, !vaSetDisplayAttributes_ptr) << "Couldn't load vaSetDisplayAttributes, dlerror() says:\n" | |
<< dlerror(); | |
vaSyncSurface_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VASurfaceID render_target)>( | |
dlsym(module, "vaSyncSurface")); | |
VLOG_IF(1, !vaSyncSurface_ptr) << "Couldn't load vaSyncSurface, dlerror() says:\n" | |
<< dlerror(); | |
vaTerminate_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy)>( | |
dlsym(module, "vaTerminate")); | |
VLOG_IF(1, !vaTerminate_ptr) << "Couldn't load vaTerminate, dlerror() says:\n" | |
<< dlerror(); | |
vaUnmapBuffer_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VABufferID buf_id)>( | |
dlsym(module, "vaUnmapBuffer")); | |
VLOG_IF(1, !vaUnmapBuffer_ptr) << "Couldn't load vaUnmapBuffer, dlerror() says:\n" | |
<< dlerror(); | |
vaGetDisplay_ptr = | |
reinterpret_cast<VADisplay (*)(Display *dpy)>( | |
dlsym(module, "vaGetDisplay")); | |
VLOG_IF(1, !vaGetDisplay_ptr) << "Couldn't load vaGetDisplay, dlerror() says:\n" | |
<< dlerror(); | |
vaPutSurface_ptr = | |
reinterpret_cast<VAStatus (*)(VADisplay dpy, VASurfaceID surface, Drawable draw, short srcx, short srcy, unsigned short srcw, unsigned short srch, short destx, short desty, unsigned short destw, unsigned short desth, VARectangle *cliprects, unsigned int number_cliprects, unsigned int flags)>( | |
dlsym(module, "vaPutSurface")); | |
VLOG_IF(1, !vaPutSurface_ptr) << "Couldn't load vaPutSurface, dlerror() says:\n" | |
<< dlerror(); | |
} | |
// Uninitialize the module stubs. Reset pointers to NULL. | |
void UninitializeVa() { | |
vaBeginPicture_ptr = NULL; | |
vaCreateBuffer_ptr = NULL; | |
vaCreateConfig_ptr = NULL; | |
vaCreateContext_ptr = NULL; | |
vaCreateSurfaces_ptr = NULL; | |
vaDeriveImage_ptr = NULL; | |
vaDestroyBuffer_ptr = NULL; | |
vaDestroyConfig_ptr = NULL; | |
vaDestroyContext_ptr = NULL; | |
vaDestroyImage_ptr = NULL; | |
vaDestroySurfaces_ptr = NULL; | |
vaDisplayIsValid_ptr = NULL; | |
vaEndPicture_ptr = NULL; | |
vaErrorStr_ptr = NULL; | |
vaGetConfigAttributes_ptr = NULL; | |
vaInitialize_ptr = NULL; | |
vaMapBuffer_ptr = NULL; | |
vaRenderPicture_ptr = NULL; | |
vaSetDisplayAttributes_ptr = NULL; | |
vaSyncSurface_ptr = NULL; | |
vaTerminate_ptr = NULL; | |
vaUnmapBuffer_ptr = NULL; | |
vaGetDisplay_ptr = NULL; | |
vaPutSurface_ptr = NULL; | |
} | |
} // namespace content_common_gpu_media | |
namespace content_common_gpu_media { | |
typedef std::map<StubModules, void*> StubHandleMap; | |
static void CloseLibraries(StubHandleMap* stub_handles) { | |
for (StubHandleMap::const_iterator it = stub_handles->begin(); | |
it != stub_handles->end(); | |
++it) { | |
dlclose(it->second); | |
} | |
stub_handles->clear(); | |
} | |
bool InitializeStubs(const StubPathMap& path_map) { | |
StubHandleMap opened_libraries; | |
for (int i = 0; i < kNumStubModules; ++i) { | |
StubModules cur_module = static_cast<StubModules>(i); | |
// If a module is missing, we fail. | |
StubPathMap::const_iterator it = path_map.find(cur_module); | |
if (it == path_map.end()) { | |
CloseLibraries(&opened_libraries); | |
return false; | |
} | |
// Otherwise, attempt to dlopen the library. | |
const std::vector<std::string>& paths = it->second; | |
bool module_opened = false; | |
for (std::vector<std::string>::const_iterator dso_path = paths.begin(); | |
!module_opened && dso_path != paths.end(); | |
++dso_path) { | |
void* handle = dlopen(dso_path->c_str(), RTLD_LAZY); | |
if (handle != NULL) { | |
module_opened = true; | |
opened_libraries[cur_module] = handle; | |
} else { | |
VLOG(1) << "dlopen(" << dso_path->c_str() << ") failed, " | |
<< "dlerror() says:\n" << dlerror(); | |
} | |
} | |
if (!module_opened) { | |
CloseLibraries(&opened_libraries); | |
return false; | |
} | |
} | |
// Initialize each module if we have not already failed. | |
InitializeVa(opened_libraries[kModuleVa]); | |
// Check that each module is initialized correctly. | |
// Close all previously opened libraries on failure. | |
if (!IsVaInitialized()) { | |
UninitializeVa(); | |
CloseLibraries(&opened_libraries); | |
return false; | |
} | |
return true; | |
} | |
} // namespace content_common_gpu_media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is generated file. Do not modify directly. | |
#ifndef CONTENT_COMMON_GPU_MEDIA_ | |
#define CONTENT_COMMON_GPU_MEDIA_ | |
#include <map> | |
#include <string> | |
#include <vector> | |
#include "base/logging.h" | |
namespace content_common_gpu_media { | |
// Individual module initializer functions. | |
bool IsVaInitialized(); | |
void InitializeVa(void* module); | |
void UninitializeVa(); | |
// Enum and typedef for umbrella initializer. | |
enum StubModules { | |
kModuleVa = 0, | |
kNumStubModules | |
}; | |
typedef std::map<StubModules, std::vector<std::string> > StubPathMap; | |
// Umbrella initializer for all the modules in this stub file. | |
bool InitializeStubs(const StubPathMap& path_map); | |
} // namespace content_common_gpu_media | |
#endif // CONTENT_COMMON_GPU_MEDIA_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment