Initialize ALSA before starting the audio thread
This fixes a race condition: Before this commit, there was a race condition when starting a game: Core::EmuThread(), after having started (but not necessarily completed) the initialization of the audio thread, calls Core::SetState() which calls CCPU::EnableStepping(), which in turns calls AudioCommon::ClearAudioBuffer(). This means that SoundStream::Clear() can be called before AlsaSound::AlsaInit() has completed.
This commit is contained in:
parent
e27caf2e37
commit
a0c5247743
|
@ -26,6 +26,12 @@ AlsaSound::~AlsaSound()
|
|||
bool AlsaSound::Start()
|
||||
{
|
||||
m_thread_status.store(ALSAThreadStatus::RUNNING);
|
||||
if (!AlsaInit())
|
||||
{
|
||||
m_thread_status.store(ALSAThreadStatus::STOPPED);
|
||||
return false;
|
||||
}
|
||||
|
||||
thread = std::thread(&AlsaSound::SoundLoop, this);
|
||||
return true;
|
||||
}
|
||||
|
@ -44,10 +50,6 @@ void AlsaSound::Update()
|
|||
// Called on audio thread.
|
||||
void AlsaSound::SoundLoop()
|
||||
{
|
||||
if (!AlsaInit()) {
|
||||
m_thread_status.store(ALSAThreadStatus::STOPPED);
|
||||
return;
|
||||
}
|
||||
Common::SetCurrentThreadName("Audio thread - alsa");
|
||||
while (m_thread_status.load() == ALSAThreadStatus::RUNNING)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue