diff options
| author | Matthias Geier <Matthias.Geier@gmail.com> | 2023-12-09 22:27:53 +0100 |
|---|---|---|
| committer | Matthias Geier <Matthias.Geier@gmail.com> | 2024-01-21 18:05:46 +0100 |
| commit | a7c32598d6a4410e23c20a06f72dfd96f2143cfd (patch) | |
| tree | 9df95287e6833e81fe81c81802c067e16f3f2582 /sounddevice.py | |
| parent | 4ae39d9d854fe5fe69344847b794472f0719225a (diff) | |
ASIO: retry decoding device name after UnicodeDecodeError
Diffstat (limited to 'sounddevice.py')
| -rw-r--r-- | sounddevice.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sounddevice.py b/sounddevice.py index e292c4f..fc44b83 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -574,13 +574,15 @@ def query_devices(device=None, kind=None): # 'utf-8' or 'mbcs' encoding. Let's try 'utf-8' first, because it more # likely raises an exception on 'mbcs' data than vice versa, see also # https://github.com/spatialaudio/python-sounddevice/issues/72. - # All other host APIs use 'utf-8' anyway. name = name_bytes.decode('utf-8') except UnicodeDecodeError: - if info.hostApi in ( - _lib.Pa_HostApiTypeIdToHostApiIndex(_lib.paDirectSound), - _lib.Pa_HostApiTypeIdToHostApiIndex(_lib.paMME)): + api_idx = _lib.Pa_HostApiTypeIdToHostApiIndex + if info.hostApi in (api_idx(_lib.paDirectSound), api_idx(_lib.paMME)): name = name_bytes.decode('mbcs') + elif info.hostApi == api_idx(_lib.paASIO): + # See https://github.com/spatialaudio/python-sounddevice/issues/490 + import locale + name = name_bytes.decode(locale.getpreferredencoding()) else: raise device_dict = { |
