From bbb500632e942b11c16b3637f77d7d190ce3b052 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 7 Nov 2021 16:12:19 +0100 Subject: [PATCH] fix problem with libasound.so --- tnc/daemon.py | 13 ++++++++++--- tnc/modem.py | 9 +++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tnc/daemon.py b/tnc/daemon.py index f990d674..748cd307 100755 --- a/tnc/daemon.py +++ b/tnc/daemon.py @@ -208,9 +208,16 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler): else: data["DAEMON_STATE"].append({"STATUS": "stopped"}) - # UPDATE LIST OF AUDIO DEVICES - with noalsaerr(): # https://github.com/DJ2LS/FreeDATA/issues/22 - p = pyaudio.PyAudio() + # UPDATE LIST OF AUDIO DEVICES + try: + # we need to "try" this, because sometimes libasound.so isn't in the default place + # try to supress error messages + with noalsaerr(): # https://github.com/DJ2LS/FreeDATA/issues/22 + p = pyaudio.PyAudio() + # else do it the default way + except: + p = pyaudio.Pyaudio() + for i in range(0, p.get_device_count()): maxInputChannels = p.get_device_info_by_host_api_device_index( diff --git a/tnc/modem.py b/tnc/modem.py index 583c77e2..3b204e12 100644 --- a/tnc/modem.py +++ b/tnc/modem.py @@ -111,8 +111,13 @@ class RF(): self.c_lib = ctypes.CDLL(libname) print("running libcodec from EXTERNAL library") # --------------------------------------------CREATE PYAUDIO INSTANCE - - with noalsaerr(): # https://github.com/DJ2LS/FreeDATA/issues/22 + try: + # we need to "try" this, because sometimes libasound.so isn't in the default place + # try to supress error messages + with noalsaerr(): # https://github.com/DJ2LS/FreeDATA/issues/22 + self.p = pyaudio.PyAudio() + # else do it the default way + except: self.p = pyaudio.PyAudio() atexit.register(self.p.terminate) # --------------------------------------------OPEN AUDIO CHANNEL RX