File tree Expand file tree Collapse file tree 2 files changed +8
-23
lines changed Expand file tree Collapse file tree 2 files changed +8
-23
lines changed Original file line number Diff line number Diff line change @@ -2823,29 +2823,22 @@ def _initialize():
2823
2823
is automatically called with the ``import sounddevice`` statement.
2824
2824
2825
2825
"""
2826
- old_stderr = None
2826
+ devnull = None
2827
+ old_stderr = 2 # To appease Pyright
2827
2828
try :
2828
- stdio = _ffi .dlopen (None )
2829
+ old_stderr = _os .dup (2 )
2830
+ devnull = open (_os .devnull , 'w' )
2831
+ _os .dup2 (devnull .fileno (), 2 )
2829
2832
except OSError :
2830
2833
pass
2831
- else :
2832
- for stderr_name in 'stderr' , '__stderrp' :
2833
- try :
2834
- old_stderr = getattr (stdio , stderr_name )
2835
- except _ffi .error :
2836
- continue
2837
- else :
2838
- devnull = stdio .fopen (_os .devnull .encode (), b'w' )
2839
- setattr (stdio , stderr_name , devnull )
2840
- break
2841
2834
try :
2842
2835
_check (_lib .Pa_Initialize (), 'Error initializing PortAudio' )
2843
2836
global _initialized
2844
2837
_initialized += 1
2845
2838
finally :
2846
- if old_stderr is not None :
2847
- setattr ( stdio , stderr_name , old_stderr )
2848
- stdio . fclose ( devnull )
2839
+ if devnull is not None :
2840
+ _os . dup2 ( old_stderr , 2 )
2841
+ devnull . close ( )
2849
2842
2850
2843
2851
2844
def _terminate ():
Original file line number Diff line number Diff line change 311
311
int PaWasapi_IsLoopback( PaDeviceIndex device );
312
312
""" )
313
313
314
- ffibuilder .cdef ("""
315
- /* from stdio.h */
316
- FILE* fopen(const char* path, const char* mode);
317
- int fclose(FILE* fp);
318
- extern FILE* stderr; /* GNU C library */
319
- extern FILE* __stderrp; /* macOS */
320
- """ )
321
-
322
314
if __name__ == '__main__' :
323
315
ffibuilder .compile (verbose = True )
You can’t perform that action at this time.
0 commit comments