Skip to content

Add name= parameter to query_hostapis() #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion sounddevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,14 +783,17 @@ def query_devices(device=None, kind=None):
return device_dict


def query_hostapis(index=None):
def query_hostapis(index=None, name=None):
"""Return information about available host APIs.

Parameters
----------
index : int, optional
If specified, information about only the given host API *index*
is returned in a single dictionary.
name : str, optional
If specified, information about only the given host API *name*
is returned in a single dictionary.

Returns
-------
Expand Down Expand Up @@ -820,6 +823,17 @@ def query_hostapis(index=None):
query_devices

"""
if name is not None:
if index is not None:
raise ValueError('May not specify both index and name')
hostapi_list = tuple(query_hostapis(i) for i in
range(_check(_lib.Pa_GetHostApiCount())))
hostapi_list = filter(lambda x: x['name'] == name, hostapi_list)
assert len(hostapi_list) <= 1
try:
return hostapi_list[0]
except IndexError:
raise PortAudioError('Host API {0!r} not found'.format(name))
if index is None:
return tuple(query_hostapis(i)
for i in range(_check(_lib.Pa_GetHostApiCount())))
Expand Down