🐛[bugfix] Model : SpeakerDeviceの取得処理を修正
This commit is contained in:
@@ -33,16 +33,14 @@ def getOutputDevices():
|
|||||||
devices = []
|
devices = []
|
||||||
with PyAudio() as p:
|
with PyAudio() as p:
|
||||||
wasapi_info = p.get_host_api_info_by_type(paWASAPI)
|
wasapi_info = p.get_host_api_info_by_type(paWASAPI)
|
||||||
defaultOutputDevice = wasapi_info["defaultOutputDevice"]
|
|
||||||
|
|
||||||
for host_index in range(0, p.get_host_api_count()):
|
for host_index in range(0, p.get_host_api_count()):
|
||||||
for device_index in range(0, p.get_host_api_info_by_index(host_index)['deviceCount']):
|
host = p.get_host_api_info_by_index(host_index)
|
||||||
device = p.get_device_info_by_host_api_device_index(host_index, device_index)
|
if host["name"] == wasapi_info["name"]:
|
||||||
if device["index"] == defaultOutputDevice:
|
for device_index in range(0, p.get_host_api_info_by_index(host_index)['deviceCount']):
|
||||||
default_speakers = device
|
device = p.get_device_info_by_host_api_device_index(host_index, device_index)
|
||||||
if not default_speakers["isLoopbackDevice"]:
|
if not device["isLoopbackDevice"]:
|
||||||
for loopback in p.get_loopback_device_info_generator():
|
for loopback in p.get_loopback_device_info_generator():
|
||||||
if default_speakers["name"] in loopback["name"]:
|
if device["name"] in loopback["name"]:
|
||||||
devices.append(loopback)
|
devices.append(loopback)
|
||||||
|
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
@@ -66,5 +64,5 @@ def getDefaultOutputDevice():
|
|||||||
return {"device": {"name": "NoDevice"}}
|
return {"device": {"name": "NoDevice"}}
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("getOutputDevices():", getOutputDevices())
|
print("getOutputDevices()", getOutputDevices())
|
||||||
print("getDefaultOutputDevice()", getDefaultOutputDevice())
|
print("getDefaultOutputDevice()", getDefaultOutputDevice())
|
||||||
Reference in New Issue
Block a user