Commits

Anonymous committed 7cdaf68

Opening audio devices needs threads for recent SDL_mixer versions.

Comments (0)

Files changed (1)

src/sdlmixer/mixermod.c

 static PyObject*
 _mixer_init (PyObject *self, PyObject *args)
 {
-    long flags = MIX_INIT_FLAC | MIX_INIT_MOD | MIX_INIT_MP3 | MIX_INIT_OGG;
+    long flags = 0;
     long retval = 0;
 
+    if (!PyArg_ParseTuple (args, "|l", &flags))
+        return NULL;
+
     if (SDL_WasInit (SDL_INIT_AUDIO))
     {
         retval = Mix_Init (flags);
 static PyObject*
 _mixer_openaudio (PyObject *self, PyObject *args)
 {
-    int freq, chans, chunks;
+    int freq, chans, chunks, retval;
     Uint16 format;
 
     if (!PyArg_ParseTuple (args, "iiii:open_audio", &freq, &format, &chans,
             &chunks))
         return NULL;
+    
+    Py_BEGIN_ALLOW_THREADS;
+    retval = Mix_OpenAudio (freq, format, chans, chunks);
+    Py_END_ALLOW_THREADS;
 
-    if (Mix_OpenAudio (freq, format, chans, chunks) == -1)
+    if (retval == -1)
     {
         PyErr_SetString (PyExc_PyGameError, Mix_GetError ());
         return NULL;
 static PyObject*
 _mixer_closeaudio (PyObject *self)
 {
+    Py_BEGIN_ALLOW_THREADS;
     Mix_CloseAudio ();
+    Py_END_ALLOW_THREADS;
     Py_RETURN_NONE;
 }
 
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.