From 697cb7610ad37ea6915c37100a6a55db53cf7961 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 8 Nov 2023 14:01:59 +0100 Subject: [PATCH] Improve modem audio device logging info --- modem/audio.py | 3 ++- modem/modem.py | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modem/audio.py b/modem/audio.py index c598dc36..6d38ba61 100644 --- a/modem/audio.py +++ b/modem/audio.py @@ -106,6 +106,7 @@ def fetch_audio_devices(input_devices, output_devices): # FreeData uses the crc as id inside the configuration # SD lib uses a numerical id which is essentially an # index of the device within the list +# returns (id, name) def get_device_index_from_crc(crc, isInput: bool): in_devices = [] out_devices = [] @@ -119,6 +120,6 @@ def get_device_index_from_crc(crc, isInput: bool): for i, dev in enumerate(detected_devices): if dev['id'] == crc: - return i + return (i, dev['name']) raise Exception("Audio device %s not detected." % crc) diff --git a/modem/modem.py b/modem/modem.py index 69777da3..97aac567 100644 --- a/modem/modem.py +++ b/modem/modem.py @@ -191,8 +191,10 @@ class RF: # --------------------------------------------CREATE PORTAUDIO INSTANCE if not TESTMODE and not HamlibParam.hamlib_radiocontrol in ["tci"]: try: - in_dev_index = audio.get_device_index_from_crc(self.audio_input_device, True) - out_dev_index = audio.get_device_index_from_crc(self.audio_output_device, False) + (in_dev_index, in_dev_name) = audio.get_device_index_from_crc( + self.audio_input_device, True) + (out_dev_index, out_dev_name) = audio.get_device_index_from_crc( + self.audio_output_device, False) self.stream = sd.RawStream( channels=1, @@ -203,7 +205,8 @@ class RF: blocksize=4800, ) atexit.register(self.stream.stop) - self.log.info("[MDM] init: opened audio devices") + self.log.info("[MDM] init: receiving audio from '%s'" % in_dev_name) + self.log.info("[MDM] init: transmiting audio on '%s'" % out_dev_name) except Exception as err: self.log.error("[MDM] init: can't open audio device. Exit", e=err) # TODO Disabled sys.exit in case of wrong audio devices. We need to ensure flask server is running.