From 069da6c66280c5b30faa4fedba461efdca3d4b53 Mon Sep 17 00:00:00 2001 From: Raivis Dejus Date: Sat, 7 Mar 2026 06:01:21 +0200 Subject: [PATCH] Fix for errors in test --- buzz/recording.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/buzz/recording.py b/buzz/recording.py index a831823f..37402aec 100644 --- a/buzz/recording.py +++ b/buzz/recording.py @@ -22,6 +22,7 @@ class RecordingAmplitudeListener(QObject): self.input_device_index = input_device_index self.buffer = np.ndarray([], dtype=np.float32) self.accumulation_size = 0 + self._active = False def start_recording(self): try: @@ -33,16 +34,20 @@ class RecordingAmplitudeListener(QObject): ) self.stream.start() self.accumulation_size = int(self.stream.samplerate * self.ACCUMULATION_SECONDS) + self._active = True except Exception as e: self.stop_recording() logging.exception("Failed to start audio stream on device %s: %s", self.input_device_index, e) def stop_recording(self): + self._active = False if self.stream is not None: self.stream.stop() self.stream.close() def stream_callback(self, in_data: np.ndarray, frame_count, time_info, status): + if not self._active: + return chunk = in_data.ravel() self.amplitude_changed.emit(float(np.sqrt(np.mean(chunk**2))))