Selaa lähdekoodia

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).
kleines Filmröllchen 3 vuotta sitten
vanhempi
commit
763cda227f
1 muutettua tiedostoa jossa 4 lisäystä ja 1 poistoa
  1. 4 1
      Userland/Libraries/LibAudio/ConnectionToServer.cpp

+ 4 - 1
Userland/Libraries/LibAudio/ConnectionToServer.cpp

@@ -33,7 +33,7 @@ ConnectionToServer::ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket>
         return (intptr_t) nullptr;
         return (intptr_t) nullptr;
     }))
     }))
 {
 {
-    m_background_audio_enqueuer->start();
+    async_pause_playback();
     set_buffer(*m_buffer);
     set_buffer(*m_buffer);
 }
 }
 
 
@@ -56,6 +56,9 @@ void ConnectionToServer::die()
 
 
 ErrorOr<void> ConnectionToServer::async_enqueue(FixedArray<Sample>&& samples)
 ErrorOr<void> ConnectionToServer::async_enqueue(FixedArray<Sample>&& samples)
 {
 {
+    if (!m_background_audio_enqueuer->is_started())
+        m_background_audio_enqueuer->start();
+
     update_good_sleep_time();
     update_good_sleep_time();
     m_user_queue->append(move(samples));
     m_user_queue->append(move(samples));
     // Wake the background thread to make sure it starts enqueuing audio.
     // Wake the background thread to make sure it starts enqueuing audio.