Skip to content

Commit

Permalink
If sound card API not found, list options (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
buranconsult authored Nov 15, 2021
1 parent 5516e45 commit dfbdf47
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion expyfun/_sound_controllers/_rtmixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ def _init_mixer(fs, n_channels, api, name, api_options=None):
if len(devices) == 0:
raise OSError('No sound devices found!')
apis = sounddevice.query_hostapis()
valid_apis = []
for ai, this_api in enumerate(apis):
if this_api['name'] == api:
api = this_api
break
else:
valid_apis.append(this_api['name'])
else:
raise RuntimeError('Could not find host API %s' % (api,))
m = 'Could not find host API %s. Valid choices are "%s"'
raise RuntimeError(m % (api, ', '.join(valid_apis)))
del this_api

# Name
Expand Down

0 comments on commit dfbdf47

Please sign in to comment.