diff --git a/include/f1x/openauto/autoapp/Projection/RtAudioOutput.hpp b/include/f1x/openauto/autoapp/Projection/RtAudioOutput.hpp index 7bfba51..f3d69d5 100644 --- a/include/f1x/openauto/autoapp/Projection/RtAudioOutput.hpp +++ b/include/f1x/openauto/autoapp/Projection/RtAudioOutput.hpp @@ -45,6 +45,7 @@ public: uint32_t getSampleRate() const override; private: + void doSuspend(); static int audioBufferReadHandler(void* outputBuffer, void* inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void* userData); diff --git a/src/autoapp/Projection/RtAudioOutput.cpp b/src/autoapp/Projection/RtAudioOutput.cpp index eb0d493..416b58b 100644 --- a/src/autoapp/Projection/RtAudioOutput.cpp +++ b/src/autoapp/Projection/RtAudioOutput.cpp @@ -101,7 +101,7 @@ void RtAudioOutput::stop() { std::lock_guard lock(mutex_); - this->suspend(); + this->doSuspend(); if(dac_->isStreamOpen()) { @@ -112,18 +112,7 @@ void RtAudioOutput::stop() void RtAudioOutput::suspend() { std::lock_guard lock(mutex_); - - if(!dac_->isStreamOpen() && !dac_->isStreamRunning()) - { - try - { - dac_->stopStream(); - } - catch(const RtAudioError& e) - { - OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to suspend audio output, what: " << e.what(); - } - } + this->doSuspend(); } uint32_t RtAudioOutput::getSampleSize() const @@ -141,6 +130,21 @@ uint32_t RtAudioOutput::getSampleRate() const return sampleRate_; } +void RtAudioOutput::doSuspend() +{ + if(!dac_->isStreamOpen() && !dac_->isStreamRunning()) + { + try + { + dac_->stopStream(); + } + catch(const RtAudioError& e) + { + OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to suspend audio output, what: " << e.what(); + } + } +} + int RtAudioOutput::audioBufferReadHandler(void* outputBuffer, void* inputBuffer, unsigned int nBufferFrames, double streamTime, RtAudioStreamStatus status, void* userData) {