1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 20:47:45 +00:00

LibAudio: Set asynchronous audio enqueuer thread to maximum priority

Anything that handles audio in this way should run at maximum priority.
This commit is contained in:
kleines Filmröllchen 2022-11-23 12:54:14 +01:00 committed by Andrew Kaster
parent 4219d50a21
commit 9b819a0dc9
3 changed files with 7 additions and 4 deletions

View file

@ -26,7 +26,7 @@
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> serenity_main(Main::Arguments arguments)
{ {
TRY(Core::System::pledge("stdio thread rpath cpath wpath recvfd sendfd unix")); TRY(Core::System::pledge("stdio thread rpath cpath wpath recvfd sendfd unix proc"));
auto app = TRY(GUI::Application::try_create(arguments)); auto app = TRY(GUI::Application::try_create(arguments));

View file

@ -14,6 +14,7 @@
#include <LibAudio/UserSampleQueue.h> #include <LibAudio/UserSampleQueue.h>
#include <LibCore/Event.h> #include <LibCore/Event.h>
#include <LibThreading/Mutex.h> #include <LibThreading/Mutex.h>
#include <sched.h>
#include <time.h> #include <time.h>
namespace Audio { namespace Audio {
@ -58,8 +59,10 @@ 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()) if (!m_background_audio_enqueuer->is_started()) {
m_background_audio_enqueuer->start(); m_background_audio_enqueuer->start();
TRY(m_background_audio_enqueuer->set_priority(THREAD_PRIORITY_MAX));
}
update_good_sleep_time(); update_good_sleep_time();
m_user_queue->append(move(samples)); m_user_queue->append(move(samples));

View file

@ -23,7 +23,7 @@ constexpr size_t LOAD_CHUNK_SIZE = 128 * KiB;
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> serenity_main(Main::Arguments arguments)
{ {
TRY(Core::System::pledge("stdio rpath sendfd unix thread")); TRY(Core::System::pledge("stdio rpath sendfd unix thread proc"));
StringView path {}; StringView path {};
bool should_loop = false; bool should_loop = false;
@ -50,7 +50,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} }
auto loader = maybe_loader.release_value(); auto loader = maybe_loader.release_value();
TRY(Core::System::pledge("stdio sendfd thread")); TRY(Core::System::pledge("stdio sendfd thread proc"));
outln("\033[34;1m Playing\033[0m: {}", path); outln("\033[34;1m Playing\033[0m: {}", path);
outln("\033[34;1m Format\033[0m: {} {} Hz, {}-bit, {}", outln("\033[34;1m Format\033[0m: {} {} Hz, {}-bit, {}",