mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 19:58:53 +00:00
Minor changes to usages of std::condition_variable.
This commit is contained in:
parent
75e74315e6
commit
d34a9afe04
3 changed files with 21 additions and 3 deletions
|
@ -19,6 +19,9 @@ AlsaSound::~AlsaSound()
|
|||
{
|
||||
m_thread_status.store(ALSAThreadStatus::STOPPING);
|
||||
|
||||
// Immediately lock and unlock mutex to prevent cv race.
|
||||
std::unique_lock<std::mutex>{cv_m};
|
||||
|
||||
// Give the opportunity to the audio thread
|
||||
// to realize we are stopping the emulation
|
||||
cv.notify_one();
|
||||
|
@ -81,7 +84,12 @@ void AlsaSound::SoundLoop()
|
|||
bool AlsaSound::SetRunning(bool running)
|
||||
{
|
||||
m_thread_status.store(running ? ALSAThreadStatus::RUNNING : ALSAThreadStatus::PAUSED);
|
||||
cv.notify_one(); // Notify thread that status has changed
|
||||
|
||||
// Immediately lock and unlock mutex to prevent cv race.
|
||||
std::unique_lock<std::mutex>{cv_m};
|
||||
|
||||
// Notify thread that status has changed
|
||||
cv.notify_one();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue