From dbe811b47aa141af3077c9370c67985cb7efa00d Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Sun, 16 Aug 2020 19:28:14 +0200 Subject: [PATCH] bruh --- src/io/audio.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/io/audio.h b/src/io/audio.h index 1913bfd2..a20964bf 100644 --- a/src/io/audio.h +++ b/src/io/audio.h @@ -181,11 +181,23 @@ namespace io { if (!running) { return; } - spdlog::warn("==> Pa_StopStream"); + if (streamType == MONO) { + _monoInput->stopReader(); + } + else { + _stereoInput->stopReader(); + } + spdlog::warn("==> Pa_AbortStream"); Pa_AbortStream(stream); spdlog::warn("==> Pa_CloseStream"); Pa_CloseStream(stream); spdlog::warn("==> Done"); + if (streamType == MONO) { + _monoInput->clearReadStop(); + } + else { + _stereoInput->clearReadStop(); + } running = false; } @@ -239,7 +251,9 @@ namespace io { PaStreamCallbackFlags statusFlags, void *userData ) { AudioSink* _this = (AudioSink*)userData; float* outbuf = (float*)output; - _this->_monoInput->read(_this->monoBuffer, frameCount); + if (_this->_monoInput->read(_this->monoBuffer, frameCount) < 0) { + return 0; + } float vol = powf(_this->_volume, 2); for (int i = 0; i < frameCount; i++) { @@ -255,7 +269,9 @@ namespace io { PaStreamCallbackFlags statusFlags, void *userData ) { AudioSink* _this = (AudioSink*)userData; dsp::StereoFloat_t* outbuf = (dsp::StereoFloat_t*)output; - _this->_stereoInput->read(_this->stereoBuffer, frameCount); + if (_this->_stereoInput->read(_this->stereoBuffer, frameCount) < 0) { + return 0; + } // Note: Calculate the power in the UI instead of here @@ -274,7 +290,9 @@ namespace io { PaStreamCallbackFlags statusFlags, void *userData ) { AudioSink* _this = (AudioSink*)userData; dsp::StereoFloat_t* outbuf = (dsp::StereoFloat_t*)output; - _this->_monoInput->read(_this->monoBuffer, frameCount); + if (_this->_monoInput->read(_this->monoBuffer, frameCount) < 0) { + return 0; + } float vol = powf(_this->_volume, 2); for (int i = 0; i < frameCount; i++) { @@ -291,7 +309,9 @@ namespace io { PaStreamCallbackFlags statusFlags, void *userData ) { AudioSink* _this = (AudioSink*)userData; float* outbuf = (float*)output; - _this->_stereoInput->read(_this->stereoBuffer, frameCount); + if (_this->_stereoInput->read(_this->stereoBuffer, frameCount) < 0) { + return 0; + } // Note: Calculate the power in the UI instead of here