mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibAudio: Restore exact audio enqueuer thread mutex behavior
This was changed with a recent move to MutexLocker, but the exact previous behavior is safer as it holds the lock for the minimum amount of time in both locations. We don't want to introduce these kinds of subtle bugs.
This commit is contained in:
parent
9d0b56b1fc
commit
3610b8dd93
1 changed files with 11 additions and 6 deletions
|
@ -27,8 +27,10 @@ ConnectionToServer::ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket>
|
|||
Core::EventLoop enqueuer_loop;
|
||||
m_enqueuer_loop = &enqueuer_loop;
|
||||
enqueuer_loop.exec();
|
||||
Threading::MutexLocker const locker(m_enqueuer_loop_destruction);
|
||||
m_enqueuer_loop = nullptr;
|
||||
{
|
||||
Threading::MutexLocker const locker(m_enqueuer_loop_destruction);
|
||||
m_enqueuer_loop = nullptr;
|
||||
}
|
||||
return (intptr_t) nullptr;
|
||||
}))
|
||||
{
|
||||
|
@ -43,10 +45,13 @@ ConnectionToServer::~ConnectionToServer()
|
|||
|
||||
void ConnectionToServer::die()
|
||||
{
|
||||
// We're sometimes getting here after the other thread has already exited and its event loop does no longer exist.
|
||||
if (Threading::MutexLocker const locker(m_enqueuer_loop_destruction); m_enqueuer_loop != nullptr) {
|
||||
m_enqueuer_loop->wake();
|
||||
m_enqueuer_loop->quit(0);
|
||||
{
|
||||
Threading::MutexLocker const locker(m_enqueuer_loop_destruction);
|
||||
// We're sometimes getting here after the other thread has already exited and its event loop does no longer exist.
|
||||
if (m_enqueuer_loop != nullptr) {
|
||||
m_enqueuer_loop->wake();
|
||||
m_enqueuer_loop->quit(0);
|
||||
}
|
||||
}
|
||||
(void)m_background_audio_enqueuer->join();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue