[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:
Fabio Manganiello 2023-10-23 22:11:32 +02:00
parent b91d544b89
commit fc869bf5db

View file

@ -96,9 +96,13 @@ class DeviceManager:
if type:
raise AssertionError(f'No default device for type={type}')
if dev.get('idx') is None:
idx = next(
iter(i for i, d in enumerate(all_devices) if d['name'] == dev['name']), None
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'
return AudioDevice(index=idx, **dev)
dev['index'] = idx
return AudioDevice(**dev)