restart server on input overflow

This commit is contained in:
DJ2LS 2024-03-11 19:52:03 +01:00
parent e4744a113f
commit 2b32fb740c
2 changed files with 7 additions and 6 deletions

View file

@ -4,10 +4,7 @@ import ctypes
import structlog
import threading
import audio
import os
from modem_frametypes import FRAME_TYPE
import itertools
from time import sleep
TESTMODE = False
@ -28,11 +25,11 @@ class Demodulator():
'decoding_thread': None
}
def __init__(self, config, audio_rx_q, data_q_rx, states, event_manager, fft_queue):
def __init__(self, config, audio_rx_q, data_q_rx, states, event_manager, service_queue, fft_queue):
self.log = structlog.get_logger("Demodulator")
self.rx_audio_level = config['AUDIO']['rx_audio_level']
self.service_queue = service_queue
self.AUDIO_FRAMES_PER_BUFFER_RX = 4800
self.buffer_overflow_counter = [0, 0, 0, 0, 0, 0, 0, 0]
self.is_codec2_traffic_counter = 0
@ -129,6 +126,9 @@ class Demodulator():
def sd_input_audio_callback(self, indata: np.ndarray, frames: int, time, status) -> None:
if status:
self.log.warning("[AUDIO STATUS]", status=status, time=time, frames=frames)
# FIXME on windows input overflows crashing the rx audio stream. Lets restart the server then
if status.input_overflow:
self.service_queue.put("restart")
return
try:
audio_48k = np.frombuffer(indata, dtype=np.int16)

View file

@ -65,7 +65,7 @@ class RF:
self.MODEM_SAMPLE_RATE = codec2.api.FREEDV_FS_8000
# 8192 Let's do some tests with very small chunks for TX
self.AUDIO_FRAMES_PER_BUFFER_TX = 1200 if self.radiocontrol in ["tci"] else 2400 * 2
#self.AUDIO_FRAMES_PER_BUFFER_TX = 1200 if self.radiocontrol in ["tci"] else 2400 * 2
# 8 * (self.AUDIO_SAMPLE_RATE/self.MODEM_SAMPLE_RATE) == 48
self.AUDIO_CHANNELS = 1
self.MODE = 0
@ -83,6 +83,7 @@ class RF:
self.data_queue_received,
self.states,
self.event_manager,
self.service_queue,
self.fft_queue
)