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

Load user-provided PortAudio name/path from environ's SD_PORTAUDIO #499

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 17 additions & 6 deletions sounddevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,27 @@

try:
for _libname in (
'portaudio', # Default name on POSIX systems
'bin\\libportaudio-2.dll', # DLL from conda-forge
'lib/libportaudio.dylib', # dylib from anaconda
):
_os.environ.get('SD_PORTAUDIO', ''), # User-provided PortAudio name/path
'portaudio', # Default name on POSIX systems
'bin\\libportaudio-2.dll', # DLL from conda-forge
'lib/libportaudio.dylib', # dylib from anaconda
):
_libname = _find_library(_libname)
if _libname is not None:
break
try:
_lib = _ffi.dlopen(_libname)
# Basic check for the loaded PortAudio binary
assert('PortAudio' in _ffi.string(_lib.Pa_GetVersionText()).decode())
# Exit loop and use _lib if assertion is successful
break
except (AttributeError, AssertionError, OSError):
# Continue checking other libraries on
# AttributeError: Pa_GetVersionText() not available in binary
# AssertionError: 'PortAudio' not found in lib's version text
# OSError: library could not be opened by ffi
continue
else:
raise OSError('PortAudio library not found')

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found

Check failure on line 83 in sounddevice.py

View workflow job for this annotation

GitHub Actions / docs-linkcheck

PortAudio library not found
_lib = _ffi.dlopen(_libname)
except OSError:
if _platform.system() == 'Darwin':
_libname = 'libportaudio.dylib'
Expand Down
Loading