2
pygame - Python Game Library
3
Copyright (C) 2000-2001 Pete Shinners
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
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
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public
16
License along with this library; if not, write to the Free
17
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include <SDL_mixer.h>
27
/* test mixer initializations */
28
#define MIXER_INIT_CHECK() \
29
if(!SDL_WasInit(SDL_INIT_AUDIO)) \
30
return RAISE(PyExc_SDLError, "mixer system not initialized")
34
#define PYGAMEAPI_MIXER_NUMSLOTS 7
43
#define PySound_AsChunk(x) (((PySoundObject*)x)->chunk)
44
#define PyChannel_AsInt(x) (((PyChannelObject*)x)->chan)
45
#ifndef PYGAMEAPI_MIXER_INTERNAL
46
#define PySound_Check(x) ((x)->ob_type == (PyTypeObject*)PyMIXER_C_API[0])
47
#define PySound_Type (*(PyTypeObject*)PyMIXER_C_API[0])
48
#define PySound_New (*(PyObject*(*)(Mix_Chunk*))PyMIXER_C_API[1])
49
#define PySound_Play (*(PyObject*(*)(PyObject*, PyObject*))PyMIXER_C_API[2])
50
#define PyChannel_Check(x) ((x)->ob_type == (PyTypeObject*)PyMIXER_C_API[3])
51
#define PyChannel_Type (*(PyTypeObject*)PyMIXER_C_API[3])
52
#define PyChannel_New (*(PyObject*(*)(int))PyMIXER_C_API[4])
53
#define PyMixer_AutoInit (*(PyObject*(*)(PyObject*, PyObject*))PyMIXER_C_API[5])
54
#define PyMixer_AutoQuit (*(void(*)(void))PyMIXER_C_API[6])
55
#define import_pygame_mixer() { \
56
PyObject *module = PyImport_ImportModule("pygame.mixer"); \
57
if (module != NULL) { \
58
PyObject *dict = PyModule_GetDict(module); \
59
PyObject *c_api = PyDict_GetItemString(dict, PYGAMEAPI_LOCAL_ENTRY); \
60
if(PyCObject_Check(c_api)) {\
61
void** localptr = (void*)PyCObject_AsVoidPtr(c_api); \
62
memcpy(PyMIXER_C_API, localptr, sizeof(void*)*PYGAMEAPI_MIXER_NUMSLOTS); \
63
} Py_DECREF(module); } }
68
static void* PyMIXER_C_API[PYGAMEAPI_MIXER_NUMSLOTS] = {NULL};