forked from platypush/platypush
[Fix] sounddevice arguments fix.
Different versions of the `sounddevice` dependency may or may not return the `index` parameter when querying the available sound devices. Thus, the code should be ready for both cases.
This commit is contained in:
parent
b91d544b89
commit
fc869bf5db
1 changed files with 9 additions and 5 deletions
|
@ -96,9 +96,13 @@ class DeviceManager:
|
||||||
if type:
|
if type:
|
||||||
raise AssertionError(f'No default device for type={type}')
|
raise AssertionError(f'No default device for type={type}')
|
||||||
|
|
||||||
idx = next(
|
if dev.get('idx') is None:
|
||||||
iter(i for i, d in enumerate(all_devices) if d['name'] == dev['name']), None
|
idx = next(
|
||||||
)
|
iter(i for i, d in enumerate(all_devices) if d['name'] == dev['name']),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
|
||||||
assert idx is not None, 'Could not infer the sound device index'
|
assert idx is not None, 'Could not infer the sound device index'
|
||||||
return AudioDevice(index=idx, **dev)
|
dev['index'] = idx
|
||||||
|
|
||||||
|
return AudioDevice(**dev)
|
||||||
|
|
Loading…
Reference in a new issue