Commits

Anonymous committed 8ff0bbe

Fixed and improved openal' error handling.

Comments (0)

Files changed (9)

src/openal/buffers.c

                 vals[cnt] = (ALint) tmp;
             }
 
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             if (ptype == INT3)
                 alBuffer3i ((ALuint)bufnum, param, vals[0], vals[1], vals[2]);
             else
                 vals[cnt] = (ALfloat) tmp;
             }
 
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             if (ptype == FLOAT3)
                 alBuffer3f ((ALuint)bufnum, param, vals[0], vals[1], vals[2]);
             else
         case INT:
             if (!IntFromObj (values, &ival))
                 return NULL;
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             alBufferi ((ALuint)bufnum, param, (ALint) ival);
             break;
         case FLOAT:
             if (!DoubleFromObj (values, &fval))
                 return NULL;
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             alBufferf ((ALuint)bufnum, param, (ALfloat) fval);
             break;
         default:
         }
     }
 
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
         return NULL;
     Py_RETURN_NONE;
 }
     }
 
     ptype = GetPropTypeFromStr (type);
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     switch (ptype)
     {
     case INT:
     {
         ALint val;
         alGetBufferi ((ALuint)bufnum, param, &val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return PyLong_FromLong ((long)val);
     }
     {
         ALfloat val;
         alGetBufferf ((ALuint)bufnum, param, &val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return PyFloat_FromDouble ((double)val);
     }
     {
         ALint val[3];
         alGetBuffer3i ((ALuint)bufnum, param, &val[0], &val[1], &val[2]);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return Py_BuildValue ("(lll)", (long)val[0], (long)val[1],
             (long)val[2]);
     {
         ALfloat val[3];
         alGetBuffer3f ((ALuint)bufnum, param, &val[0], &val[1], &val[2]);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return Py_BuildValue ("(ddd)", (double)val[0], (double)val[1],
             (double)val[2]);
         if (!val)
             return NULL;
         alGetBufferiv ((ALuint)bufnum, param, val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
         {
             PyMem_Free (val);
             return NULL;
         if (!val)
             return NULL;
         alGetBufferfv ((ALuint)bufnum, param, val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
         {
             PyMem_Free (val);
             return NULL;
         PyErr_SetString (PyExc_ValueError, "buffer index out of range");
         return NULL;
     }
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     alBufferData ((ALuint) bufnum, format, (const void*) buf, (ALsizei)len,
         freq);
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
         return NULL;
     Py_RETURN_NONE;
 }
         Py_DECREF (buffers);
         return NULL;
     }
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     alGenBuffers (count, buf);
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
     {
         Py_DECREF (buffers);
         PyMem_Free (buf);

src/openal/capturedevice.c

 
 static PyObject* _capturedevice_start (PyObject* self);
 static PyObject* _capturedevice_stop (PyObject* self);
+static PyObject* _capturedevice_getsamples (PyObject* self, PyObject *args);
 
 static PyObject* _capturedevice_getsize (PyObject *self, void *closure);
+static PyObject* _capturedevice_getfrequency (PyObject *self, void *closure);
+static PyObject* _capturedevice_getformat (PyObject *self, void *closure);
 
 /**
  */
 static PyMethodDef _capturedevice_methods[] = {
-    { "start", (PyCFunction)_capturedevice_start, METH_NOARGS, NULL },
-    { "stop", (PyCFunction)_capturedevice_start, METH_NOARGS, NULL },
+    { "start", (PyCFunction) _capturedevice_start, METH_NOARGS, NULL },
+    { "stop", (PyCFunction) _capturedevice_stop, METH_NOARGS, NULL },
+    { "get_samples", (PyCFunction) _capturedevice_getsamples, METH_VARARGS, NULL },
     { NULL, NULL, 0, NULL }
 };
 
  */
 static PyGetSetDef _capturedevice_getsets[] = {
     { "size", _capturedevice_getsize, NULL, NULL, NULL },
+    { "frequency", _capturedevice_getfrequency, NULL, NULL, NULL },
+    { "format", _capturedevice_getformat, NULL, NULL, NULL },
     { NULL, NULL, NULL, NULL, NULL }
 };
 
     if (!device)
         return NULL;
     device->size = 0;
+    device->format = 0;
+    device->frequency = 0;
+    
     device->device.device = NULL;
     return (PyObject*) device;
 }
     
     if (!PyArg_ParseTuple (args, "slll", &name, &freq, &format, &bufsize))
     {
+        name = NULL;
         PyErr_Clear ();
         if (!PyArg_ParseTuple (args, "lll", &freq, &format, &bufsize))
             return -1;
     }
-
     if (bufsize <= 0)
     {
         PyErr_SetString (PyExc_ValueError,
         return -1;
     }
 
-    Py_BEGIN_ALLOW_THREADS;
+    CLEAR_ALCERROR_STATE ();
     device = alcCaptureOpenDevice ((const ALCchar*)name, (ALCuint) freq,
         (ALCenum)format, (ALCsizei) bufsize);
-    Py_END_ALLOW_THREADS;
     if (!device)
     {
-        SetALErrorException (alGetError ());
+        SetALCErrorException (alcGetError (NULL), 1);
         return -1;
     }
     ((PyCaptureDevice*)self)->device.device = device;
+    ((PyCaptureDevice*)self)->format = (ALCenum)format;
+    ((PyCaptureDevice*)self)->frequency = (ALCuint) freq;
+    ((PyCaptureDevice*)self)->size = (ALCsizei) bufsize;
+
     return 0;
 }
 
 _capturedevice_repr (PyObject *self)
 {
     PyObject *retval;
-    const ALCchar *name = alcGetString (PyCaptureDevice_AsDevice (self),
+    const ALCchar *name;
+    size_t len;
+    char *str;
+    
+    CLEAR_ALCERROR_STATE ();
+    name = alcGetString (PyCaptureDevice_AsDevice (self),
         ALC_CAPTURE_DEVICE_SPECIFIER);
+    if (!name)
+    {
+        SetALCErrorException (alcGetError (PyCaptureDevice_AsDevice (self)), 1);
+        return NULL;
+    }        
     /* CaptureDevice('') == 17 */
-    size_t len = strlen ((const char*) name) + 18;
-    char *str = malloc (len);
+    len = strlen ((const char*) name) + 18;
+    str = malloc (len);
     if (!str)
         return NULL;
 
     return PyInt_FromLong ((long) ((PyCaptureDevice*)self)->size);
 }
 
+static PyObject*
+_capturedevice_getfrequency (PyObject *self, void *closure)
+{
+    return PyInt_FromLong ((long) ((PyCaptureDevice*)self)->frequency);
+}
+
+static PyObject*
+_capturedevice_getformat (PyObject *self, void *closure)
+{
+    return PyInt_FromLong ((long) ((PyCaptureDevice*)self)->format);
+}
+
 /* CaptureDevice methods */
 static PyObject*
 _capturedevice_start (PyObject* self)
 {
+    CLEAR_ALCERROR_STATE ();
+    alcCaptureStart (PyCaptureDevice_AsDevice(self));
+    if (SetALCErrorException (alcGetError (PyCaptureDevice_AsDevice(self)), 0))
+        return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject*
 _capturedevice_stop (PyObject* self)
 {
+    CLEAR_ALCERROR_STATE ();
+    alcCaptureStop (PyCaptureDevice_AsDevice(self));
+    if (SetALCErrorException (alcGetError (PyCaptureDevice_AsDevice(self)), 0))
+        return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject*
+_capturedevice_getsamples (PyObject* self, PyObject *args)
+{
+    PyObject *buffer = NULL;
+    long offset = 0;
+    ALCvoid *buf;
+    ALCsizei count;
+    
+    if (!PyArg_ParseTuple (args, "|Ol:get_samples", &buffer, &offset))
+        return NULL;
+    
+    CLEAR_ALCERROR_STATE ();
+    alcGetIntegerv (PyCaptureDevice_AsDevice (self), ALC_CAPTURE_SAMPLES,
+        (ALCsizei)(sizeof (ALCsizei)), &count);
+    if (SetALCErrorException (alcGetError (PyCaptureDevice_AsDevice(self)), 0))
+        return NULL;
+    if (count == 0)
+    {
+        Py_RETURN_NONE;
+    }
+    
+    alcCaptureSamples (PyCaptureDevice_AsDevice (self), &buf, count);
+    if (SetALCErrorException (alcGetError (PyCaptureDevice_AsDevice(self)), 0))
+        return NULL;
     Py_RETURN_NONE;
 }
 
     if (!device)
         return NULL;
 
+    CLEAR_ALCERROR_STATE ();
     dev = alcCaptureOpenDevice (name, frequency, format, bufsize);
     if (!dev)
     {
-        SetALErrorException (alGetError ());
+        SetALErrorException (alGetError (), 1);
         Py_DECREF (device);
         return NULL;
     }

src/openal/context.c

         }
     }
 
+    CLEAR_ALCERROR_STATE ();
     ((PyContext*)self)->context = alcCreateContext (PyDevice_AsDevice (device),
         attrs);
     if (attrs)
         PyMem_Free (attrs);
     if (((PyContext*)self)->context == NULL)
     {
-        SetALCErrorException (alcGetError (PyDevice_AsDevice (device)));
+        SetALCErrorException (alcGetError (PyDevice_AsDevice (device)), 1);
         return -1;
     }
     Py_INCREF (device);
 static PyObject*
 _context_makecurrent (PyObject *self)
 {
-    if (alcMakeContextCurrent (PyContext_AsContext (self)) == AL_TRUE)
+    PyContext *ctxt = (PyContext*) self;
+    
+    CLEAR_ALCERROR_STATE ();
+    if (alcMakeContextCurrent (ctxt->context) == AL_TRUE)
         Py_RETURN_TRUE;
+    if (SetALCErrorException (alcGetError
+        (PyDevice_AsDevice (ctxt->device)), 0))
+        return NULL;
     Py_RETURN_FALSE;
 }
 
 static PyObject*
 _context_suspend (PyObject *self)
 {
-    alcSuspendContext (PyContext_AsContext (self));
+    PyContext *ctxt = (PyContext*) self;
+    
+    CLEAR_ALCERROR_STATE ();
+    alcSuspendContext (ctxt->context);
+    if (SetALCErrorException (alcGetError
+        (PyDevice_AsDevice (ctxt->device)), 0))
+        return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject*
 _context_process (PyObject *self)
 {
-    alcProcessContext (PyContext_AsContext (self));
+    PyContext *ctxt = (PyContext*) self;
+
+    CLEAR_ALCERROR_STATE ();
+    alcProcessContext (ctxt->context);
+    if (SetALCErrorException (alcGetError
+        (PyDevice_AsDevice (ctxt->device)), 0))
+        return NULL;
     Py_RETURN_NONE;
 }
 
 
     if (!IntFromObj (args, (int*) &val))
         return NULL;
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     alEnable (val);
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
         return NULL;
     Py_RETURN_NONE;
 }
 
     if (!IntFromObj (args, (int*) &val))
         return NULL;
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     alDisable (val);
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
         return NULL;
     Py_RETURN_NONE;
 }
 
     if (!IntFromObj (args, (int*) &val))
         return NULL;
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     ret = alIsEnabled (val);
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
         return NULL;
     if (ret == AL_TRUE)
         Py_RETURN_TRUE;

src/openal/device.c

     if (!PyArg_ParseTuple (args, "|s", &name))
         return -1;
     
+    CLEAR_ALCERROR_STATE ();
     Py_BEGIN_ALLOW_THREADS;
     device = alcOpenDevice (name);
     Py_END_ALLOW_THREADS;
     if (!device)
     {
-        SetALErrorException (alGetError ());
+        SetALCErrorException (alcGetError (NULL), 1);
         return -1;
     }
     ((PyDevice*)self)->device = device;
 _device_repr (PyObject *self)
 {
     PyObject *retval;
-    const ALCchar *name = alcGetString (PyDevice_AsDevice (self),
-        ALC_DEVICE_SPECIFIER);
+    const ALCchar *name;
+    size_t len;
+    char *str;
+    
+    CLEAR_ALCERROR_STATE ();
+    name = alcGetString (PyDevice_AsDevice (self), ALC_DEVICE_SPECIFIER);
+    if (!name)
+    {
+        SetALCErrorException (alcGetError (PyDevice_AsDevice (self)), 1);
+        return NULL;
+    }
+
     /* Device('') == 10 */
-    size_t len = strlen ((const char*) name) + 11;
-    char *str = malloc (len);
+    len = strlen ((const char*) name) + 11;
+    str = malloc (len);
     if (!str)
         return NULL;
 
 static PyObject*
 _device_getname (PyObject* self, void *closure)
 {
-    const ALCchar *name = alcGetString (PyDevice_AsDevice (self),
-        ALC_DEVICE_SPECIFIER);
+    const ALCchar *name;
+
+    CLEAR_ALCERROR_STATE ();
+    name = alcGetString (PyDevice_AsDevice (self), ALC_DEVICE_SPECIFIER);
     if (!name)
     {
-        SetALCErrorException (alcGetError (PyDevice_AsDevice (self)));
+        SetALCErrorException (alcGetError (PyDevice_AsDevice (self)), 1);
         return NULL;
     }
     return Text_FromUTF8 ((const char*)name);
     int i = 0;
     const ALCchar *dptr;
     PyObject *list, *item;
-    const ALCchar *devices = alcGetString (PyDevice_AsDevice (self),
-        ALC_CAPTURE_DEVICE_SPECIFIER);
+    const ALCchar *devices;
+
+    CLEAR_ALCERROR_STATE ();
+    devices = alcGetString (PyDevice_AsDevice (self), ALC_DEVICE_SPECIFIER);
+    if (!devices)
+    {
+        SetALCErrorException (alcGetError (PyDevice_AsDevice (self)), 1);
+        return NULL;
+    }
     
-    if (SetALCErrorException (alcGetError (PyDevice_AsDevice (self))))
-        return NULL;
     list = PyList_New (0);
     dptr = devices;
     while (*dptr)
     if(!PyArg_ParseTuple (args, "s:has_extension", &extname))
         return NULL;
     
+    CLEAR_ALCERROR_STATE ();
     present = alcIsExtensionPresent (PyDevice_AsDevice (self),
         (const ALchar*)extname);
-    if (SetALCErrorException (alcGetError (PyDevice_AsDevice (self))))
+    if (SetALCErrorException (alcGetError (PyDevice_AsDevice (self)), 0))
         return NULL;
     if (present == ALC_FALSE)
         Py_RETURN_FALSE;
     if (!device)
         return NULL;
 
+    CLEAR_ALCERROR_STATE ();
     dev = alcOpenDevice (name);
     if (!dev)
     {
-        SetALErrorException (alGetError ());
+        SetALCErrorException (alcGetError (NULL), 1);
         Py_DECREF (device);
         return NULL;
     }

src/openal/listener.c

                 vals[cnt] = (ALint) tmp;
             }
 
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             if (ptype == INT3)
                 alListener3i (param, vals[0], vals[1], vals[2]);
             else
                 vals[cnt] = (ALfloat) tmp;
             }
 
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             if (ptype == FLOAT3)
                 alListener3f (param, vals[0], vals[1], vals[2]);
             else
         case INT:
             if (!IntFromObj (values, &ival))
                 return NULL;
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             alListeneri (param, (ALint) ival);
             break;
         case FLOAT:
             if (!DoubleFromObj (values, &fval))
                 return NULL;
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             alListenerf (param, (ALfloat) fval);
             break;
         default:
         }
     }
 
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
         return NULL;
     Py_RETURN_NONE;
 }
     }
 
     ptype = GetPropTypeFromStr (type);
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     switch (ptype)
     {
     case INT:
     {
         ALint val;
         alGetListeneri (param, &val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return PyLong_FromLong ((long)val);
     }
     {
         ALfloat val;
         alGetListenerf (param, &val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return PyFloat_FromDouble ((double)val);
     }
     {
         ALint val[3];
         alGetListener3i (param, &val[0], &val[1], &val[2]);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return Py_BuildValue ("(lll)", (long)val[0], (long)val[1],
             (long)val[2]);
     {
         ALfloat val[3];
         alGetListener3f (param, &val[0], &val[1], &val[2]);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return Py_BuildValue ("(ddd)", (double)val[0], (double)val[1],
             (double)val[2]);
         if (!val)
             return NULL;
         alGetListeneriv (param, val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
         {
             PyMem_Free (val);
             return NULL;
         if (!val)
             return NULL;
         alGetListenerfv (param, val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
         {
             PyMem_Free (val);
             return NULL;

src/openal/openalmod.c

     const ALchar* retval;
     if (!IntFromObj (args, (int*) &val))
         return NULL;
-    CLEAR_ERROR_STATE ();
 
     if (alcGetCurrentContext () == NULL)
     {
         return NULL;
     }
 
+    CLEAR_ALERROR_STATE ();
     retval = alGetString (val);
     if (!retval)
     {
-        SetALErrorException (alGetError ());
+        SetALErrorException (alGetError (), 1);
         return NULL;
     }
     return Text_FromUTF8 ((const char*)retval);
         return NULL;
     }
     
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALCERROR_STATE ();
     if (device)
         present = alcIsExtensionPresent (PyDevice_AsDevice (device),
             (const ALchar*) extname);
     else
         present = alIsExtensionPresent ((const ALchar*) extname);
-    if (SetALErrorException (alGetError ()))
+    if (SetALCErrorException (alcGetError (PyDevice_AsDevice (device)), 0))
         return NULL;
     if (present == ALC_FALSE)
         Py_RETURN_FALSE;
     const ALCchar *dptr;
     const ALCchar *devices;
 
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALCERROR_STATE ();
     if (alcIsExtensionPresent (NULL, "ALC_ENUMERATION_EXT") == AL_FALSE)
     {
         PyErr_SetString (PyExc_PyGameError, "device listing not supported");
     if (alcIsExtensionPresent (NULL, "ALC_ENUMERATE_ALL_EXT") == AL_TRUE)
         devices = alcGetString (NULL, ALC_ALL_DEVICES_SPECIFIER);
     else
+    {
+        CLEAR_ALCERROR_STATE (); /* Ignore errors */
         devices = alcGetString (NULL, ALC_DEVICE_SPECIFIER);
-
+    }
+    
     if (!devices)
     {
-        SetALCErrorException (alcGetError (NULL));
+        SetALCErrorException (alcGetError (NULL), 1);
         return NULL;
     }
 
     const ALCchar *dptr;
     const ALCchar *devices;
 
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALCERROR_STATE ();
     if (alcIsExtensionPresent (NULL, "ALC_ENUMERATION_EXT") == AL_FALSE)
     {
         PyErr_SetString (PyExc_PyGameError, "device listing not supported");
     devices = alcGetString (NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
     if (!devices)
     {
-        SetALCErrorException (alcGetError (NULL));
+        SetALCErrorException (alcGetError (NULL), 1);
         return NULL;
     }
     list = PyList_New (0);
 _openal_getdefaultoutputdevicename (PyObject *self)
 {
     const ALCchar *name;
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALCERROR_STATE ();
     name = alcGetString (NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
     if (name)
         return Text_FromUTF8 ((const char*)name);
-    SetALCErrorException (alcGetError (NULL));
+    SetALCErrorException (alcGetError (NULL), 1);
     return NULL;
 }
 
 _openal_getdefaultcapturedevicename (PyObject *self)
 {
     const ALCchar *name;
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALCERROR_STATE ();
     name = alcGetString (NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
     if (name)
         return Text_FromUTF8 ((const char*)name);
-    SetALCErrorException (alcGetError (NULL));
+    SetALCErrorException (alcGetError (NULL), 1);
     return NULL;
 }
 
 /* C API */
 int
-SetALErrorException (ALenum error)
+SetALErrorException (ALenum error, int force)
 {
     switch (error)
     {
         PyErr_SetString (PyExc_PyGameError, "insufficient memory");
         return 1;
     default:
+    {
+        if (force)
+        {
+            PyErr_SetString (PyExc_PyGameError,
+                "an unknown error occured for OpenAL");
+        }
         return 0;
     }
+    }
 }
 
 int
-SetALCErrorException (ALCenum error)
+SetALCErrorException (ALCenum error, int force)
 {
     switch (error)
     {
         PyErr_SetString (PyExc_PyGameError, "invalid context");
         return 1;
     default:
+    {
+        if (force)
+        {
+            PyErr_SetString (PyExc_PyGameError,
+                "an unknown error occured for an OpenAL context");
+        }
         return 0;
     }
+    }
 }
 
 PropType

src/openal/openalmod.h

 } PropType;
 PropType GetPropTypeFromStr (char *name);
 
-int SetALErrorException (ALenum error);
-int SetALCErrorException (ALCenum error);
-#define CLEAR_ERROR_STATE() alGetError()
+int SetALErrorException (ALenum error, int force);
+int SetALCErrorException (ALCenum error, int force);
+#define CLEAR_ALERROR_STATE() alGetError()
+#define CLEAR_ALCERROR_STATE() alcGetError(NULL)
 
 void device_export_capi (void **capi);
 void capturedevice_export_capi (void **capi);

src/openal/pgopenal.h

 {
     PyDevice device;
     ALCsizei size;
+    ALCenum  format;
+    ALCuint  frequency;
 } PyCaptureDevice;
 #define PyCaptureDevice_AsDevice(x) (((PyCaptureDevice*)x)->device.device)
 #define PYGAME_OPENALCAPTUREDEVICE_FIRSTSLOT                   \

src/openal/sources.c

 static PyObject* _sources_action (PyObject *self, PyObject *args,
     SourcesAction action);
 
-
 static PyObject* _sources_setprop (PyObject *self, PyObject *args);
 static PyObject* _sources_getprop (PyObject *self, PyObject *args);
 static PyObject* _sources_play (PyObject *self, PyObject *args);
                 vals[cnt] = (ALint) tmp;
             }
 
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             if (ptype == INT3)
                 alSource3i ((ALuint)bufnum, param, vals[0], vals[1], vals[2]);
             else
                 vals[cnt] = (ALfloat) tmp;
             }
 
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             if (ptype == FLOAT3)
                 alSource3f ((ALuint)bufnum, param, vals[0], vals[1], vals[2]);
             else
         case INT:
             if (!IntFromObj (values, &ival))
                 return NULL;
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             alSourcei ((ALuint)bufnum, param, (ALint) ival);
             break;
         case FLOAT:
             if (!DoubleFromObj (values, &fval))
                 return NULL;
-            CLEAR_ERROR_STATE ();
+            CLEAR_ALERROR_STATE ();
             alSourcef ((ALuint)bufnum, param, (ALfloat) fval);
             break;
         default:
         }
     }
 
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
         return NULL;
     Py_RETURN_NONE;
 }
     }
 
     ptype = GetPropTypeFromStr (type);
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     switch (ptype)
     {
     case INT:
     {
         ALint val;
         alGetSourcei ((ALuint)bufnum, param, &val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return PyLong_FromLong ((long)val);
     }
     {
         ALfloat val;
         alGetSourcef ((ALuint)bufnum, param, &val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return PyFloat_FromDouble ((double)val);
     }
     {
         ALint val[3];
         alGetSource3i ((ALuint)bufnum, param, &val[0], &val[1], &val[2]);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return Py_BuildValue ("(lll)", (long)val[0], (long)val[1],
             (long)val[2]);
     {
         ALfloat val[3];
         alGetSource3f ((ALuint)bufnum, param, &val[0], &val[1], &val[2]);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         return Py_BuildValue ("(ddd)", (double)val[0], (double)val[1],
             (double)val[2]);
         if (!val)
             return NULL;
         alGetSourceiv ((ALuint)bufnum, param, val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
         {
             PyMem_Free (val);
             return NULL;
         if (!val)
             return NULL;
         alGetSourcefv ((ALuint)bufnum, param, val);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
         {
             PyMem_Free (val);
             return NULL;
             }
             sources[i] = source;
         }
-        CLEAR_ERROR_STATE ();
+        CLEAR_ALERROR_STATE ();
         switch (action)
         {
         case PLAY:
             break;
         }
         PyMem_Free (sources);
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         Py_RETURN_NONE;
     }
     else if (UintFromObj (args, &source))
     {
-        CLEAR_ERROR_STATE ();
+        CLEAR_ALERROR_STATE ();
         switch (action)
         {
         case PLAY:
             alSourceRewind ((ALuint)source);
             break;
         }
-        if (SetALErrorException (alGetError ()))
+        if (SetALErrorException (alGetError (), 0))
             return NULL;
         Py_RETURN_NONE;
     }
         return NULL;
     }
     
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     alSourceQueueBuffers ((ALuint) bufnum, ((PyBuffers*)buffers)->count,
         PyBuffers_AsBuffers(buffers));
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
         return NULL;
     
     Py_RETURN_NONE;
         return NULL;
     }
     
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     alSourceUnqueueBuffers ((ALuint) bufnum, ((PyBuffers*)buffers)->count,
         PyBuffers_AsBuffers(buffers));
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
         return NULL;
     
     Py_RETURN_NONE;
         Py_DECREF (sources);
         return NULL;
     }
-    CLEAR_ERROR_STATE ();
+    CLEAR_ALERROR_STATE ();
     alGenSources (count, buf);
-    if (SetALErrorException (alGetError ()))
+    if (SetALErrorException (alGetError (), 0))
     {
         Py_DECREF (sources);
         PyMem_Free (buf);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.