summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/AlsaSoundStream.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2015-05-14 13:31:28 +1000
committerskidau <skidau@gmail.com>2015-05-14 13:31:28 +1000
commite35148fe1528e31bc991ac1dfa5622ec76d7bde4 (patch)
treeb74528e1f99a1c36aadee74dae4c9f8c4bac7a4a /Source/Core/AudioCommon/AlsaSoundStream.cpp
parent38c7021109e525f0adbdb755d3d3532c3517cecb (diff)
parentf907e5cacee4f0a6c250f0d640eb11d006475f6b (diff)
Merge pull request #2387 from lioncash/atomic
AudioCommon: Remove usages of volatile variables.
Diffstat (limited to 'Source/Core/AudioCommon/AlsaSoundStream.cpp')
-rw-r--r--Source/Core/AudioCommon/AlsaSoundStream.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/Source/Core/AudioCommon/AlsaSoundStream.cpp b/Source/Core/AudioCommon/AlsaSoundStream.cpp
index 5f76c60de7..2bcb4ddbfb 100644
--- a/Source/Core/AudioCommon/AlsaSoundStream.cpp
+++ b/Source/Core/AudioCommon/AlsaSoundStream.cpp
@@ -10,7 +10,11 @@
#define BUFFER_SIZE_MAX 8192
#define BUFFER_SIZE_BYTES (BUFFER_SIZE_MAX*2*2)
-AlsaSound::AlsaSound(CMixer *mixer) : SoundStream(mixer), thread_data(0), handle(nullptr), frames_to_deliver(FRAME_COUNT_MIN)
+AlsaSound::AlsaSound(CMixer *mixer)
+ : SoundStream(mixer)
+ , m_thread_status(ALSAThreadStatus::STOPPED)
+ , handle(nullptr)
+ , frames_to_deliver(FRAME_COUNT_MIN)
{
mix_buffer = new u8[BUFFER_SIZE_BYTES];
}
@@ -22,14 +26,14 @@ AlsaSound::~AlsaSound()
bool AlsaSound::Start()
{
+ m_thread_status.store(ALSAThreadStatus::RUNNING);
thread = std::thread(&AlsaSound::SoundLoop, this);
- thread_data = 0;
return true;
}
void AlsaSound::Stop()
{
- thread_data = 1;
+ m_thread_status.store(ALSAThreadStatus::STOPPING);
thread.join();
}
@@ -42,11 +46,11 @@ void AlsaSound::Update()
void AlsaSound::SoundLoop()
{
if (!AlsaInit()) {
- thread_data = 2;
+ m_thread_status.store(ALSAThreadStatus::STOPPED);
return;
}
Common::SetCurrentThreadName("Audio thread - alsa");
- while (!thread_data)
+ while (m_thread_status.load() == ALSAThreadStatus::RUNNING)
{
m_mixer->Mix(reinterpret_cast<short *>(mix_buffer), frames_to_deliver);
int rc = m_muted ? 1337 : snd_pcm_writei(handle, mix_buffer, frames_to_deliver);
@@ -61,7 +65,7 @@ void AlsaSound::SoundLoop()
}
}
AlsaShutdown();
- thread_data = 2;
+ m_thread_status.store(ALSAThreadStatus::STOPPED);
}
bool AlsaSound::AlsaInit()