Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/sounddevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2925,13 +2925,17 @@ def _initialize():

"""
old_stderr = None
try:
old_stderr = _os.dup(2)
devnull = _os.open(_os.devnull, _os.O_WRONLY)
_os.dup2(devnull, 2)
_os.close(devnull)
except OSError:
pass
# Duping std file descriptors in a frozen context on windows will corrupt
# the fd and cause issues with e.g. subprocess.check_output. This happens
# for example in a compiled pyinstaller exe. See #461 for details.
if _sys.platform != 'win32' or not getattr(_sys, 'frozen', False):
try:
old_stderr = _os.dup(2)
devnull = _os.open(_os.devnull, _os.O_WRONLY)
_os.dup2(devnull, 2)
_os.close(devnull)
except OSError:
pass
try:
_check(_lib.Pa_Initialize(), 'Error initializing PortAudio')
global _initialized
Expand Down