CubebAudioStream: Set paused flag on main thread

This commit is contained in:
Connor McLaughlin 2021-06-13 22:30:39 +10:00
parent e1d9f93172
commit 093904f930
1 changed files with 6 additions and 6 deletions

View File

@ -107,6 +107,8 @@ void CubebAudioStream::PauseDevice(bool paused)
Log_ErrorPrintf("cubeb_stream_%s failed: %d", paused ? "stop" : "start", rv); Log_ErrorPrintf("cubeb_stream_%s failed: %d", paused ? "stop" : "start", rv);
return; return;
} }
m_paused = paused;
} }
void CubebAudioStream::CloseDevice() void CubebAudioStream::CloseDevice()
@ -114,7 +116,10 @@ void CubebAudioStream::CloseDevice()
Assert(IsOpen()); Assert(IsOpen());
if (!m_paused) if (!m_paused)
{
cubeb_stream_stop(m_cubeb_stream); cubeb_stream_stop(m_cubeb_stream);
m_paused = true;
}
cubeb_stream_destroy(m_cubeb_stream); cubeb_stream_destroy(m_cubeb_stream);
m_cubeb_stream = nullptr; m_cubeb_stream = nullptr;
@ -130,12 +135,7 @@ long CubebAudioStream::DataCallback(cubeb_stream* stm, void* user_ptr, const voi
return nframes; return nframes;
} }
void CubebAudioStream::StateCallback(cubeb_stream* stream, void* user_ptr, cubeb_state state) void CubebAudioStream::StateCallback(cubeb_stream* stream, void* user_ptr, cubeb_state state) {}
{
CubebAudioStream* const this_ptr = static_cast<CubebAudioStream*>(user_ptr);
this_ptr->m_paused = (state != CUBEB_STATE_STARTED);
}
void CubebAudioStream::FramesAvailable() {} void CubebAudioStream::FramesAvailable() {}