File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2417,6 +2417,28 @@ def _terminate():
24172417 _check (_lib .Pa_Terminate (), "Error terminating PortAudio" )
24182418
24192419
2420+ def _ignore_stderr ():
2421+ """Try to forward PortAudio messages from stderr to /dev/null."""
2422+ ffi = _FFI ()
2423+ ffi .cdef ("""
2424+ /* from stdio.h */
2425+ FILE* fopen(const char* path, const char* mode);
2426+ int fclose(FILE* fp);
2427+ FILE* stderr; /* GNU C library */
2428+ FILE* __stderrp; /* Mac OS X */
2429+ """ )
2430+ stdio = ffi .dlopen (None )
2431+ devnull = stdio .fopen (_os .devnull .encode (), b'w' )
2432+ try :
2433+ stdio .stderr = devnull
2434+ except KeyError :
2435+ try :
2436+ stdio .__stderrp = devnull
2437+ except KeyError :
2438+ stdio .fclose (devnull )
2439+
2440+
2441+ _ignore_stderr ()
24202442_initialize ()
24212443
24222444if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments