From 66a39b53680e4c312b62b0a5b3573e8ca96478f6 Mon Sep 17 00:00:00 2001 From: dj2ls Date: Mon, 27 Dec 2021 15:28:58 +0100 Subject: [PATCH] fix audio device selection #96 --- gui/preload-main.js | 24 ++++++++++++++++++++++-- tnc/daemon.py | 8 ++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gui/preload-main.js b/gui/preload-main.js index b962da24..9931024f 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -305,8 +305,27 @@ advancedHamlibSettingsModal var stop_bits = document.getElementById('hamlib_stopbits_advanced').value var handshake = document.getElementById('hamlib_handshake_advanced').value - config.rx_audio = document.getElementById("audio_input_selectbox").options[rx_audio].text - config.tx_audio = document.getElementById("audio_output_selectbox").options[tx_audio].text + + // loop through audio device list and select + for(i = 0; i < document.getElementById("audio_input_selectbox").length; i++) { + device = document.getElementById("audio_input_selectbox")[i]; + + if (device.value == rx_audio) { + console.log(device.text); + config.rx_audio = device.text + } + } + + // loop through audio device list and select + for(i = 0; i < document.getElementById("audio_output_selectbox").length; i++) { + device = document.getElementById("audio_output_selectbox")[i]; + + if (device.value == tx_audio) { + console.log(device.text); + config.tx_audio = device.text + } + } + config.deviceid = deviceid config.deviceport = deviceport config.serialspeed = serialspeed @@ -981,6 +1000,7 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => { option.text = arg.input_devices[i]['NAME']; option.value = arg.input_devices[i]['ID']; // set device from config if available + if(config.rx_audio == option.text){ option.setAttribute('selected', true); } diff --git a/tnc/daemon.py b/tnc/daemon.py index eb0ace5e..76d28f7f 100755 --- a/tnc/daemon.py +++ b/tnc/daemon.py @@ -256,10 +256,10 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler): maxInputChannels = p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels') maxOutputChannels = p.get_device_info_by_host_api_device_index(0, i).get('maxOutputChannels') name = p.get_device_info_by_host_api_device_index(0, i).get('name') - crc_name = crc_algorithm(bytes(name, encoding='utf-8')) - crc_name = crc_name.to_bytes(2, byteorder='big') - crc_name = crc_name.hex() - name = name + ' [' + crc_name + ']' + #crc_name = crc_algorithm(bytes(name, encoding='utf-8')) + #crc_name = crc_name.to_bytes(2, byteorder='big') + #crc_name = crc_name.hex() + #name = name + ' [' + crc_name + ']' if maxInputChannels > 0: data["INPUT_DEVICES"].append(