From 1f9279ff865af713a412d6483c30ab6b4a7c4867 Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F" Date: Wed, 16 Sep 2020 09:40:00 +0200 Subject: [PATCH] Working RtAudio backend. Small change. Now ready for hard change to UlDaq backend --- lasp/device/lasp_daqconfig.py | 13 ++++++++----- lasp/device/lasp_rtaudio.pyx | 5 ++--- lasp/lasp_avstream.py | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lasp/device/lasp_daqconfig.py b/lasp/device/lasp_daqconfig.py index ca8ba20..9bf812e 100644 --- a/lasp/device/lasp_daqconfig.py +++ b/lasp/device/lasp_daqconfig.py @@ -164,8 +164,10 @@ class DAQConfiguration: return [ch.qty for ch in self.getEnabledInputChannels()] def getEnabledInputChannelSensitivities(self): - return [float(channel.sensitivity) for channel in - self.getEnabledInputChannels()] + return [ + float(channel.sensitivity) + for channel in self.getEnabledInputChannels() + ] def getEnabledOutputChannels(self): en_channels = [] @@ -178,8 +180,10 @@ class DAQConfiguration: return [ch.qty for ch in self.getEnabledOutputChannels()] def getEnabledOutputChannelSensitivities(self): - return [float(channel.sensitivity) for channel in - self.getEnabledOutputChannels()] + return [ + float(channel.sensitivity) + for channel in self.getEnabledOutputChannels() + ] @staticmethod def loadConfigsJSON(): @@ -211,4 +215,3 @@ class DAQConfiguration: cur_configs = DAQConfiguration.loadConfigs() del cur_configs[name] sh.store('daqconfigs', cur_configs) - diff --git a/lasp/device/lasp_rtaudio.pyx b/lasp/device/lasp_rtaudio.pyx index 6232366..51ea6d8 100644 --- a/lasp/device/lasp_rtaudio.pyx +++ b/lasp/device/lasp_rtaudio.pyx @@ -714,6 +714,7 @@ cdef class RtAudio: def stop(self): if self.sd is NULL: raise RuntimeError('Stream is not running') + try: self._rtaudio.stopStream() self._rtaudio.closeStream() @@ -721,11 +722,9 @@ cdef class RtAudio: print(e) pass self.cleanupStream(self.sd) + self.sd = NULL cdef cleanupStream(self, PyStreamData* stream): - # printf('Entrance function cleanupStream...\n') - cdef: - void* ptr if stream == NULL: return diff --git a/lasp/lasp_avstream.py b/lasp/lasp_avstream.py index 03535a0..6ffdaf0 100644 --- a/lasp/lasp_avstream.py +++ b/lasp/lasp_avstream.py @@ -109,7 +109,6 @@ class AvStream: self._videothread = None self._audiobackend = RtAudio(daqconfig.api) - self.blocksize, self.samplerate = self._audiobackend.openStream(self) def nCallbacks(self): """Returns the current number of installed callbacks.""" @@ -148,7 +147,8 @@ class AvStream: self._videothread.start() else: self._video_started <<= True - self._audiobackend.start() + + self.blocksize, self.samplerate = self._audiobackend.start(self) def _videoThread(self): cap = cv.VideoCapture(self._video)