diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2018-01-02 09:58:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-02 09:58:36 +0100 |
| commit | cb168b184386f169aeb828f660ac63c5bc3e540c (patch) | |
| tree | a7e89360ae75653e46536bd77d9fd27bd44774c1 /Source/Core/AudioCommon/CubebStream.cpp | |
| parent | 26a9957285aac023ee7d35cf506b82381575df9a (diff) | |
| parent | a988a8a4587bf18d8ad8dba36653b803e3a583b4 (diff) | |
Merge pull request #6134 from ligfx/soundstreamlifecycle
SoundStream: change Start/Stop lifecycle to Init/SetRunning/destruct
Diffstat (limited to 'Source/Core/AudioCommon/CubebStream.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/CubebStream.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/Source/Core/AudioCommon/CubebStream.cpp b/Source/Core/AudioCommon/CubebStream.cpp index a12f0fda4b..754db1d957 100644 --- a/Source/Core/AudioCommon/CubebStream.cpp +++ b/Source/Core/AudioCommon/CubebStream.cpp @@ -32,7 +32,7 @@ void CubebStream::StateCallback(cubeb_stream* stream, void* user_data, cubeb_sta { } -bool CubebStream::Start() +bool CubebStream::Init() { m_ctx = CubebUtils::GetContext(); if (!m_ctx) @@ -60,28 +60,22 @@ bool CubebStream::Start() ERROR_LOG(AUDIO, "Error getting minimum latency"); INFO_LOG(AUDIO, "Minimum latency: %i frames", minimum_latency); - if (cubeb_stream_init(m_ctx.get(), &m_stream, "Dolphin Audio Output", nullptr, nullptr, nullptr, - ¶ms, std::max(BUFFER_SAMPLES, minimum_latency), DataCallback, - StateCallback, this) != CUBEB_OK) - { - ERROR_LOG(AUDIO, "Error initializing cubeb stream"); - return false; - } + return cubeb_stream_init(m_ctx.get(), &m_stream, "Dolphin Audio Output", nullptr, nullptr, + nullptr, ¶ms, std::max(BUFFER_SAMPLES, minimum_latency), + DataCallback, StateCallback, this) == CUBEB_OK; +} - if (cubeb_stream_start(m_stream) != CUBEB_OK) - { - ERROR_LOG(AUDIO, "Error starting cubeb stream"); - return false; - } - return true; +bool CubebStream::SetRunning(bool running) +{ + if (running) + return cubeb_stream_start(m_stream) == CUBEB_OK; + else + return cubeb_stream_stop(m_stream) == CUBEB_OK; } -void CubebStream::Stop() +CubebStream::~CubebStream() { - 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(); } |
