ijksdl_vout_internal.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*****************************************************************************
  2. * ijksdl_vout_internal.h
  3. *****************************************************************************
  4. *
  5. * Copyright (c) 2013 Bilibili
  6. * copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
  7. *
  8. * This file is part of ijkPlayer.
  9. *
  10. * ijkPlayer is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * ijkPlayer is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with ijkPlayer; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #ifndef IJKSDL__IJKSDL_VOUT_INTERNAL_H
  25. #define IJKSDL__IJKSDL_VOUT_INTERNAL_H
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include "ijksdl_vout.h"
  29. inline static SDL_Vout *SDL_Vout_CreateInternal(size_t opaque_size)
  30. {
  31. SDL_Vout *vout = (SDL_Vout*) calloc(1, sizeof(SDL_Vout));
  32. if (!vout)
  33. return NULL;
  34. vout->opaque = calloc(1, opaque_size);
  35. if (!vout->opaque) {
  36. free(vout);
  37. return NULL;
  38. }
  39. vout->mutex = SDL_CreateMutex();
  40. if (vout->mutex == NULL) {
  41. free(vout->opaque);
  42. free(vout);
  43. return NULL;
  44. }
  45. return vout;
  46. }
  47. inline static void SDL_Vout_FreeInternal(SDL_Vout *vout)
  48. {
  49. if (!vout)
  50. return;
  51. if (vout->mutex) {
  52. SDL_DestroyMutex(vout->mutex);
  53. }
  54. free(vout->opaque);
  55. memset(vout, 0, sizeof(SDL_Vout));
  56. free(vout);
  57. }
  58. inline static SDL_VoutOverlay *SDL_VoutOverlay_CreateInternal(size_t opaque_size)
  59. {
  60. SDL_VoutOverlay *overlay = (SDL_VoutOverlay*) calloc(1, sizeof(SDL_VoutOverlay));
  61. if (!overlay)
  62. return NULL;
  63. overlay->opaque = calloc(1, opaque_size);
  64. if (!overlay->opaque) {
  65. free(overlay);
  66. return NULL;
  67. }
  68. return overlay;
  69. }
  70. inline static void SDL_VoutOverlay_FreeInternal(SDL_VoutOverlay *overlay)
  71. {
  72. if (!overlay)
  73. return;
  74. if (overlay->opaque)
  75. free(overlay->opaque);
  76. memset(overlay, 0, sizeof(SDL_VoutOverlay));
  77. free(overlay);
  78. }
  79. #endif