Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CoreAudio for Python 3.x builds. #64

Open
moubctez opened this issue Apr 28, 2016 · 0 comments
Open

Fix CoreAudio for Python 3.x builds. #64

moubctez opened this issue Apr 28, 2016 · 0 comments

Comments

@moubctez
Copy link

CoreAudio output does not work with Python 3.x, because PyString_AsString is not part of 3.x API. Here is a fix that also removes /dev/null detection – /dev/null is always available on OS X, so no need to go through os module to find the obvious.

--- src/output/core_audio.c.orig    2015-10-31 21:51:57.000000000 +0000
+++ src/output/core_audio.c
@@ -95,31 +95,10 @@ CoreAudio_init(output_CoreAudio *self, P
           at init-time, we'll need to temporarily redirect
           stdout to /dev/null*/

-        /*first, determine the location of /dev/null from os.devnull*/
-        if ((os_module_obj = PyImport_ImportModule("os")) == NULL) {
-            return -1;
-        }
-        if ((devnull_obj =
-             PyObject_GetAttrString(os_module_obj, "devnull")) == NULL) {
-            Py_DECREF(os_module_obj);
-            return -1;
-        }
-        if ((devnull = PyString_AsString(devnull_obj)) == NULL) {
-            Py_DECREF(os_module_obj);
-            Py_DECREF(devnull_obj);
-            return -1;
-        }
-
         /*open /dev/null*/
-        if ((devnull_stdout = open(devnull, O_WRONLY | O_TRUNC)) == -1) {
-            Py_DECREF(os_module_obj);
-            Py_DECREF(devnull_obj);
+        if ((devnull_stdout = open("/dev/null", O_WRONLY | O_TRUNC)) == -1) {
             PyErr_SetFromErrno(PyExc_IOError);
             return -1;
-        } else {
-            /*close unneeded Python objects once descriptor is open*/
-            Py_DECREF(os_module_obj);
-            Py_DECREF(devnull_obj);
         }

         /*swap file descriptors*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant