Some sanity checks. Removed activateSiggen and deactivateSiggen fucntionality, as it has no use.

This commit is contained in:
Anne de Jong 2022-02-02 14:07:21 +01:00
parent 5e26f4a026
commit d51d3f7d37

View File

@ -67,8 +67,6 @@ class StreamMsg(Enum):
endProcess = auto()
scanDaqDevices = auto()
activateSiggen = auto()
deactivateSiggen = auto()
"""
Second part, status messages that are send back on all listeners
"""
@ -116,7 +114,6 @@ class AudioStream:
self.running = False
self.aframectr = 0
self.avtype = avtype
self.siggen_activated = Atomic(False)
api_devices = devices[daqconfig.api]
self.processCallback = processCallback
@ -138,6 +135,12 @@ class AudioStream:
if en_in_ch == 0 and en_out_ch == 0:
raise RuntimeError('No enabled input / output channels')
elif en_out_ch == 0 and avtype in (AvType.audio_duplex,
AvType.audio_output):
raise RuntimeError('No enabled output channels')
elif en_in_ch == 0 and avtype in (AvType.audio_input,
AvType.audio_duplex):
raise RuntimeError('No enabled input channels')
logging.debug('Ready to start device...')
samplerate = self.daq.start(self.streamCallback)
@ -264,7 +267,6 @@ class AvStreamProcess(mp.Process):
# Check for devices
self.rescanDaqDevices()
self.siggen_activated = Atomic(False)
while True:
try:
@ -275,13 +277,7 @@ class AvStreamProcess(mp.Process):
self.terminate()
logging.debug(f"Streamprocess obtained message {msg}")
if msg == StreamMsg.activateSiggen:
self.siggen_activated <<= True
elif msg == StreamMsg.deactivateSiggen:
self.siggen_activated <<= False
elif msg == StreamMsg.scanDaqDevices:
if msg == StreamMsg.scanDaqDevices:
self.rescanDaqDevices()
elif msg == StreamMsg.stopAllStreams:
@ -355,7 +351,7 @@ class AvStreamProcess(mp.Process):
self.sendAllQueues(
StreamMsg.streamError,
stream.avtype,
"Error occured in stopping stream: {str(e)}",
f"Error occured in stopping stream: {str(e)}",
)
self.streams[avtype] = None
@ -427,7 +423,6 @@ class AvStreamProcess(mp.Process):
"""This is called (from a separate thread) for each audio block."""
# logging.debug('streamCallback()')
if outdata is not None:
if self.siggen_activated():
if not self.outq.empty():
newdata = self.outq.get()
if newdata.shape[0] != outdata.shape[0] or newdata.ndim != 1:
@ -446,11 +441,6 @@ class AvStreamProcess(mp.Process):
)
outdata[:, :] = 0
# Siggen not activated
else:
logging.debug("siggen not activated")
outdata[:, :] = 0
if indata is not None:
self.sendInQueues(StreamMsg.streamData, indata)
@ -617,15 +607,7 @@ class StreamManager:
self.handleMessages()
return self.outq
def activateSiggen(self):
self.handleMessages()
logging.debug("activateSiggen()")
self.sendPipe(StreamMsg.activateSiggen, None)
def deactivateSiggen(self):
self.handleMessages()
logging.debug("deactivateSiggen()")
self.sendPipe(StreamMsg.deactivateSiggen, None)
def addMsgQueueListener(self):
"""
@ -692,6 +674,7 @@ class StreamManager:
break
def stopStream(self, avtype: AvType):
logging.debug(f'StreamManager::stopStream({avtype})')
self.handleMessages()
self.sendPipe(StreamMsg.stopStream, avtype)