/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_dyn.c

https://github.com/aichunyu/FFPlayer · C · 117 lines · 84 code · 12 blank · 21 comment · 14 complexity · 0d3246a6bf75f04bfd7a6abdec537659 MD5 · raw file

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "SDL_config.h"
  19. #if SDL_VIDEO_DRIVER_DIRECTFB
  20. #include "SDL_DirectFB_video.h"
  21. #include "SDL_DirectFB_dyn.h"
  22. #ifdef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
  23. #include "SDL_name.h"
  24. #include "SDL_loadso.h"
  25. #define DFB_SYM(ret, name, args, al, func) ret (*name) args;
  26. static struct _SDL_DirectFB_Symbols
  27. {
  28. DFB_SYMS
  29. const unsigned int *directfb_major_version;
  30. const unsigned int *directfb_minor_version;
  31. const unsigned int *directfb_micro_version;
  32. } SDL_DirectFB_Symbols;
  33. #undef DFB_SYM
  34. #define DFB_SYM(ret, name, args, al, func) ret name args { func SDL_DirectFB_Symbols.name al ; }
  35. DFB_SYMS
  36. #undef DFB_SYM
  37. static void *handle = NULL;
  38. int
  39. SDL_DirectFB_LoadLibrary(void)
  40. {
  41. int retval = 0;
  42. if (handle == NULL) {
  43. handle = SDL_LoadObject(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC);
  44. if (handle != NULL) {
  45. retval = 1;
  46. #define DFB_SYM(ret, name, args, al, func) if (!(SDL_DirectFB_Symbols.name = SDL_LoadFunction(handle, # name))) retval = 0;
  47. DFB_SYMS
  48. #undef DFB_SYM
  49. if (!
  50. (SDL_DirectFB_Symbols.directfb_major_version =
  51. SDL_LoadFunction(handle, "directfb_major_version")))
  52. retval = 0;
  53. if (!
  54. (SDL_DirectFB_Symbols.directfb_minor_version =
  55. SDL_LoadFunction(handle, "directfb_minor_version")))
  56. retval = 0;
  57. if (!
  58. (SDL_DirectFB_Symbols.directfb_micro_version =
  59. SDL_LoadFunction(handle, "directfb_micro_version")))
  60. retval = 0;
  61. }
  62. }
  63. if (retval) {
  64. const char *stemp = DirectFBCheckVersion(DIRECTFB_MAJOR_VERSION,
  65. DIRECTFB_MINOR_VERSION,
  66. DIRECTFB_MICRO_VERSION);
  67. /* Version Check */
  68. if (stemp != NULL) {
  69. fprintf(stderr,
  70. "DirectFB Lib: Version mismatch. Compiled: %d.%d.%d Library %d.%d.%d\n",
  71. DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION,
  72. DIRECTFB_MICRO_VERSION,
  73. *SDL_DirectFB_Symbols.directfb_major_version,
  74. *SDL_DirectFB_Symbols.directfb_minor_version,
  75. *SDL_DirectFB_Symbols.directfb_micro_version);
  76. retval = 0;
  77. }
  78. }
  79. if (!retval)
  80. SDL_DirectFB_UnLoadLibrary();
  81. return retval;
  82. }
  83. void
  84. SDL_DirectFB_UnLoadLibrary(void)
  85. {
  86. if (handle != NULL) {
  87. SDL_UnloadObject(handle);
  88. handle = NULL;
  89. }
  90. }
  91. #else
  92. int
  93. SDL_DirectFB_LoadLibrary(void)
  94. {
  95. return 1;
  96. }
  97. void
  98. SDL_DirectFB_UnLoadLibrary(void)
  99. {
  100. }
  101. #endif
  102. #endif /* SDL_VIDEO_DRIVER_DIRECTFB */