mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Alternate method.
Use set rather than list in fetch_devices. Has the intended effect vs. the previous commit.
This commit is contained in:
parent
ea1fa38ecc
commit
1614e8b18a
1 changed files with 12 additions and 4 deletions
16
tnc/audio.py
16
tnc/audio.py
|
@ -35,7 +35,7 @@ def get_audio_devices():
|
||||||
proc.join()
|
proc.join()
|
||||||
|
|
||||||
# The use of set forces the list to contain only unique entries.
|
# The use of set forces the list to contain only unique entries.
|
||||||
return list(set(proxy_input_devices)), list(set(proxy_output_devices))
|
return list(proxy_input_devices), list(proxy_output_devices)
|
||||||
|
|
||||||
|
|
||||||
def fetch_audio_devices(input_devices, output_devices):
|
def fetch_audio_devices(input_devices, output_devices):
|
||||||
|
@ -50,7 +50,10 @@ def fetch_audio_devices(input_devices, output_devices):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
devices = sd.query_devices(device=None, kind=None)
|
devices = sd.query_devices(device=None, kind=None)
|
||||||
for index, device in enumerate(devices):
|
input_devs = set()
|
||||||
|
output_devs = set()
|
||||||
|
|
||||||
|
for device in devices:
|
||||||
# Use a try/except block because Windows doesn't have an audio device range
|
# Use a try/except block because Windows doesn't have an audio device range
|
||||||
try:
|
try:
|
||||||
name = device["name"]
|
name = device["name"]
|
||||||
|
@ -65,6 +68,11 @@ def fetch_audio_devices(input_devices, output_devices):
|
||||||
name = ""
|
name = ""
|
||||||
|
|
||||||
if max_input_channels > 0:
|
if max_input_channels > 0:
|
||||||
input_devices.append({"id": index, "name": name})
|
input_devs.add(name)
|
||||||
if max_output_channels > 0:
|
if max_output_channels > 0:
|
||||||
output_devices.append({"id": index, "name": name})
|
output_devs.add(name)
|
||||||
|
|
||||||
|
for index, item in enumerate(input_devs):
|
||||||
|
input_devices.append({"id": index, "name": item})
|
||||||
|
for index, item in enumerate(output_devs):
|
||||||
|
output_devices.append({"id": index, "name": item})
|
||||||
|
|
Loading…
Reference in a new issue