From c0c5b1186cb91e04868d863d404c06abf7695167 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Wed, 15 Feb 2023 17:28:02 +0100 Subject: [PATCH] Fixed bug with audio sink --- sink_modules/audio_sink/src/main.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/sink_modules/audio_sink/src/main.cpp b/sink_modules/audio_sink/src/main.cpp index 5ed4cb59..c275f7f5 100644 --- a/sink_modules/audio_sink/src/main.cpp +++ b/sink_modules/audio_sink/src/main.cpp @@ -59,20 +59,16 @@ public: } ~AudioSink() { + stop(); } void start() { - if (running) { - return; - } - doStart(); - running = true; + if (running) { return; } + running = doStart(); } void stop() { - if (!running) { - return; - } + if (!running) { return; } doStop(); running = false; } @@ -157,7 +153,7 @@ public: } private: - void doStart() { + bool doStart() { RtAudio::StreamParameters parameters; parameters.deviceId = deviceIds[devId]; parameters.nChannels = 2; @@ -174,10 +170,11 @@ private: } catch (RtAudioError& e) { spdlog::error("Could not open audio device"); - return; + return false; } spdlog::info("RtAudio stream open"); + return true; } void doStop() {