ijksdl_aout_internal.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*****************************************************************************
  2. * ijksdl_aout_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_AOUT_INTERNAL_H
  25. #define IJKSDL__IJKSDL_AOUT_INTERNAL_H
  26. #include "ijksdl_mutex.h"
  27. #include "ijksdl_aout.h"
  28. inline static SDL_Aout *SDL_Aout_CreateInternal(size_t opaque_size)
  29. {
  30. SDL_Aout *aout = (SDL_Aout*) mallocz(sizeof(SDL_Aout));
  31. if (!aout)
  32. return NULL;
  33. aout->opaque = mallocz(opaque_size);
  34. if (!aout->opaque) {
  35. free(aout);
  36. return NULL;
  37. }
  38. aout->mutex = SDL_CreateMutex();
  39. if (aout->mutex == NULL) {
  40. free(aout->opaque);
  41. free(aout);
  42. return NULL;
  43. }
  44. return aout;
  45. }
  46. inline static void SDL_Aout_FreeInternal(SDL_Aout *aout)
  47. {
  48. if (!aout)
  49. return;
  50. if (aout->mutex) {
  51. SDL_DestroyMutex(aout->mutex);
  52. }
  53. free(aout->opaque);
  54. memset(aout, 0, sizeof(SDL_Aout));
  55. free(aout);
  56. }
  57. #endif