From ad4a89d64b0d346553be473c1d877b34b896bfeb Mon Sep 17 00:00:00 2001 From: Michael M Date: Sat, 21 Oct 2017 12:49:34 -0700 Subject: [PATCH] CubebStream: implement SetRunning --- Source/Core/AudioCommon/CubebStream.cpp | 19 +++++++++++++++---- Source/Core/AudioCommon/CubebStream.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/Core/AudioCommon/CubebStream.cpp b/Source/Core/AudioCommon/CubebStream.cpp index a12f0fda4b..c2f3cc30cb 100644 --- a/Source/Core/AudioCommon/CubebStream.cpp +++ b/Source/Core/AudioCommon/CubebStream.cpp @@ -76,12 +76,23 @@ bool CubebStream::Start() return true; } +void CubebStream::SetRunning(bool running) +{ + if (running) + { + if (cubeb_stream_start(m_stream) != CUBEB_OK) + ERROR_LOG(AUDIO, "Error starting cubeb stream"); + } + else + { + if (cubeb_stream_stop(m_stream) != CUBEB_OK) + ERROR_LOG(AUDIO, "Error stopping cubeb stream"); + } +} + void CubebStream::Stop() { - if (cubeb_stream_stop(m_stream) != CUBEB_OK) - { - ERROR_LOG(AUDIO, "Error stopping cubeb stream"); - } + SetRunning(false); cubeb_stream_destroy(m_stream); m_ctx.reset(); } diff --git a/Source/Core/AudioCommon/CubebStream.h b/Source/Core/AudioCommon/CubebStream.h index eb7e915751..f558ed1b20 100644 --- a/Source/Core/AudioCommon/CubebStream.h +++ b/Source/Core/AudioCommon/CubebStream.h @@ -17,6 +17,7 @@ class CubebStream final : public SoundStream public: bool Start() override; void Stop() override; + void SetRunning(bool running) override; void SetVolume(int) override; private: