mixer.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. pygame - Python Game Library
  3. Copyright (C) 2000-2001 Pete Shinners
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. Pete Shinners
  16. pete@shinners.org
  17. */
  18. #include <Python.h>
  19. #include <SDL_mixer.h>
  20. #include <structmember.h>
  21. /* test mixer initializations */
  22. #define MIXER_INIT_CHECK() \
  23. if(!SDL_WasInit(SDL_INIT_AUDIO)) \
  24. return RAISE(pgExc_SDLError, "mixer not initialized")
  25. #define PYGAMEAPI_MIXER_FIRSTSLOT 0
  26. #define PYGAMEAPI_MIXER_NUMSLOTS 7
  27. typedef struct {
  28. PyObject_HEAD
  29. Mix_Chunk *chunk;
  30. Uint8 *mem;
  31. PyObject *weakreflist;
  32. } pgSoundObject;
  33. typedef struct {
  34. PyObject_HEAD
  35. int chan;
  36. } pgChannelObject;
  37. #define pgSound_AsChunk(x) (((pgSoundObject*)x)->chunk)
  38. #define pgChannel_AsInt(x) (((pgChannelObject*)x)->chan)
  39. #ifndef PYGAMEAPI_MIXER_INTERNAL
  40. #define pgSound_Check(x) ((x)->ob_type == (PyTypeObject*)pgMIXER_C_API[0])
  41. #define pgSound_Type (*(PyTypeObject*)pgMIXER_C_API[0])
  42. #define pgSound_New (*(PyObject*(*)(Mix_Chunk*))pgMIXER_C_API[1])
  43. #define pgSound_Play (*(PyObject*(*)(PyObject*, PyObject*))pgMIXER_C_API[2])
  44. #define pgChannel_Check(x) ((x)->ob_type == (PyTypeObject*)pgMIXER_C_API[3])
  45. #define pgChannel_Type (*(PyTypeObject*)pgMIXER_C_API[3])
  46. #define pgChannel_New (*(PyObject*(*)(int))pgMIXER_C_API[4])
  47. #define pgMixer_AutoInit (*(PyObject*(*)(PyObject*, PyObject*))pgMIXER_C_API[5])
  48. #define pgMixer_AutoQuit (*(void(*)(void))pgMIXER_C_API[6])
  49. #define import_pygame_mixer() \
  50. _IMPORT_PYGAME_MODULE(mixer, MIXER, pgMIXER_C_API)
  51. static void* pgMIXER_C_API[PYGAMEAPI_MIXER_NUMSLOTS] = {NULL};
  52. #endif