fix problem with libasound.so

This commit is contained in:
DJ2LS 2021-11-07 16:12:19 +01:00
parent c386b3608a
commit bbb500632e
2 changed files with 17 additions and 5 deletions

View file

@ -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(

View file

@ -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