/project/jni/sdl_sound/extra_rwops.h

https://github.com/aichunyu/FFPlayer · C Header · 71 lines · 12 code · 11 blank · 48 comment · 0 complexity · 9a5d0af6811baee9b4a7c03b557ded4d MD5 · raw file

  1. /*
  2. * SDL_sound -- An abstract sound format decoding API.
  3. * Copyright (C) 2001 Ryan C. Gordon.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. /*
  20. * Some extra RWops that are needed or are just handy to have.
  21. *
  22. * Please see the file COPYING in the source's root directory.
  23. *
  24. * This file written by Ryan C. Gordon. (icculus@icculus.org)
  25. */
  26. #ifndef _INCLUDE_EXTRA_RWOPS_H_
  27. #define _INCLUDE_EXTRA_RWOPS_H_
  28. #include "SDL.h"
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /*
  33. * The Reference Counter RWops...
  34. *
  35. * This wraps another RWops with a reference counter. When you create a
  36. * reference counter RWops, it sets a counter to one. Everytime you call
  37. * RWops_RWRefCounter_new(), that's RWops's counter increments by one.
  38. * Everytime you call that RWops's close() method, the counter decrements
  39. * by one. If the counter hits zero, the original RWops's close() method
  40. * is called, and the reference counting wrapper deletes itself. The read,
  41. * write, and seek methods just pass through to the original.
  42. *
  43. * This is handy if you have two libraries (in the original case, SDL_sound
  44. * and SMPEG), who both want an SDL_RWops, and both want to close it when
  45. * they are finished. This resolves that contention. The user creates a
  46. * RWops, passes it to SDL_sound, which wraps it in a reference counter and
  47. * increments the number of references, and passes the wrapped RWops to
  48. * SMPEG. SMPEG "closes" this wrapped RWops when the MP3 has finished
  49. * playing, and SDL_sound then closes it, too. This second closing removes
  50. * the last reference, and the RWops is smoothly destructed.
  51. */
  52. /* Return a SDL_RWops that is a reference counting wrapper of (rw). */
  53. SDL_RWops *RWops_RWRefCounter_new(SDL_RWops *rw);
  54. /* Increment a reference counting RWops's refcount by one. */
  55. void RWops_RWRefCounter_addRef(SDL_RWops *rw);
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #endif /* !defined _INCLUDE_EXTRA_RWOPS_H_ */
  60. /* end of extra_rwops.h ... */