1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:37:44 +00:00

AudioServer: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-29 21:15:44 +01:00
parent cac3f3c81f
commit a93205199b
2 changed files with 13 additions and 26 deletions

View file

@ -16,4 +16,4 @@ set(SOURCES
) )
serenity_bin(AudioServer) serenity_bin(AudioServer)
target_link_libraries(AudioServer LibCore LibThreading LibIPC) target_link_libraries(AudioServer LibCore LibThreading LibIPC LibMain)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, kleines Filmröllchen <malu.bertsch@gmail.com> * Copyright (c) 2021, kleines Filmröllchen <malu.bertsch@gmail.com>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
@ -7,31 +7,22 @@
#include "Mixer.h" #include "Mixer.h"
#include <LibCore/ConfigFile.h> #include <LibCore/ConfigFile.h>
#include <LibCore/File.h>
#include <LibCore/LocalServer.h> #include <LibCore/LocalServer.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
int main(int, char**) ErrorOr<int> serenity_main(Main::Arguments)
{ {
if (pledge("stdio recvfd thread accept cpath rpath wpath unix", nullptr) < 0) { TRY(Core::System::pledge("stdio recvfd thread accept cpath rpath wpath unix"));
perror("pledge");
return 1;
}
auto config = Core::ConfigFile::open_for_app("Audio", Core::ConfigFile::AllowWriting::Yes); auto config = Core::ConfigFile::open_for_app("Audio", Core::ConfigFile::AllowWriting::Yes);
if (unveil(config->filename().characters(), "rwc") < 0) { TRY(Core::System::unveil(config->filename(), "rwc"));
perror("unveil"); TRY(Core::System::unveil("/dev/audio", "wc"));
return 1; TRY(Core::System::unveil(nullptr, nullptr));
}
if (unveil("/dev/audio", "wc") < 0) {
perror("unveil");
return 1;
}
unveil(nullptr, nullptr);
Core::EventLoop event_loop; Core::EventLoop event_loop;
auto mixer = AudioServer::Mixer::construct(config); auto mixer = TRY(AudioServer::Mixer::try_create(config));
auto server = TRY(Core::LocalServer::try_create());
auto server = Core::LocalServer::construct();
bool ok = server->take_over_from_system_server(); bool ok = server->take_over_from_system_server();
VERIFY(ok); VERIFY(ok);
@ -41,12 +32,8 @@ int main(int, char**)
IPC::new_client_connection<AudioServer::ClientConnection>(move(client_socket), client_id, *mixer); IPC::new_client_connection<AudioServer::ClientConnection>(move(client_socket), client_id, *mixer);
}; };
if (pledge("stdio recvfd thread accept cpath rpath wpath", nullptr) < 0) { TRY(Core::System::pledge("stdio recvfd thread accept cpath rpath wpath"));
perror("pledge"); TRY(Core::System::unveil(nullptr, nullptr));
return 1;
}
unveil(nullptr, nullptr);
return event_loop.exec(); return event_loop.exec();
} }