Skip to content

Commit 676dd0b

Browse files
committed
Fix default.extra_settings
1 parent 3827d2e commit 676dd0b

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

sounddevice.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -2053,9 +2053,9 @@ class default(object):
20532053
>>> sd.default.reset()
20542054
20552055
"""
2056-
# The class attributes device, channels, dtype and latency are only
2057-
# provided here for static analysis tools and for the docs.
2058-
# They're overwritten in __init__().
2056+
_pairs = 'device', 'channels', 'dtype', 'latency', 'extra_settings'
2057+
# The class attributes listed in _pairs are only provided here for static
2058+
# analysis tools and for the docs. They're overwritten in __init__().
20592059
device = None, None
20602060
"""Index or query string of default input/output device.
20612061
@@ -2112,7 +2112,6 @@ class default(object):
21122112
:func:`query_devices`
21132113
21142114
"""
2115-
21162115
extra_settings = _default_extra_settings = None, None
21172116
"""Host-API-specific input/output settings.
21182117
@@ -2121,7 +2120,6 @@ class default(object):
21212120
AsioSettings, WasapiSettings
21222121
21232122
"""
2124-
21252123
samplerate = None
21262124
"""Sampling frequency in Hertz (= frames per second).
21272125
@@ -2168,17 +2166,13 @@ class default(object):
21682166
"""
21692167

21702168
def __init__(self):
2171-
# __setattr__() must be avoided here
2172-
vars(self)['device'] = _InputOutputPair(self, '_default_device')
2173-
vars(self)['channels'] = _InputOutputPair(self, '_default_channels')
2174-
vars(self)['dtype'] = _InputOutputPair(self, '_default_dtype')
2175-
vars(self)['latency'] = _InputOutputPair(self, '_default_latency')
2176-
vars(self)['extra_settings'] = _InputOutputPair(self,
2177-
'_default_extra_settings')
2169+
for attr in self._pairs:
2170+
# __setattr__() must be avoided here
2171+
vars(self)[attr] = _InputOutputPair(self, '_default_' + attr)
21782172

21792173
def __setattr__(self, name, value):
21802174
"""Only allow setting existing attributes."""
2181-
if name in ('device', 'channels', 'dtype', 'latency'):
2175+
if name in _pairs:
21822176
getattr(self, name)._pair[:] = _split(value)
21832177
elif name in dir(self) and name != 'reset':
21842178
object.__setattr__(self, name, value)

0 commit comments

Comments
 (0)