From 763cda227fbdd74d3a80ca0e2c76136f5c3fcf01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Wed, 13 Jul 2022 10:35:35 +0200 Subject: [PATCH] LibAudio: Don't auto-start the convenience enqueuer thread This will conflict with apps that don't use this thread and it also creates unnecessary overhead for non-enqueuing clients like AudioApplet. Use the new Thread is_started info to start the thread only if necessary (on first call to async_enqueue). --- Userland/Libraries/LibAudio/ConnectionToServer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibAudio/ConnectionToServer.cpp b/Userland/Libraries/LibAudio/ConnectionToServer.cpp index 44d2ab2766..e42ba7a07a 100644 --- a/Userland/Libraries/LibAudio/ConnectionToServer.cpp +++ b/Userland/Libraries/LibAudio/ConnectionToServer.cpp @@ -33,7 +33,7 @@ ConnectionToServer::ConnectionToServer(NonnullOwnPtr return (intptr_t) nullptr; })) { - m_background_audio_enqueuer->start(); + async_pause_playback(); set_buffer(*m_buffer); } @@ -56,6 +56,9 @@ void ConnectionToServer::die() ErrorOr ConnectionToServer::async_enqueue(FixedArray&& samples) { + if (!m_background_audio_enqueuer->is_started()) + m_background_audio_enqueuer->start(); + update_good_sleep_time(); m_user_queue->append(move(samples)); // Wake the background thread to make sure it starts enqueuing audio.