mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:38:13 +00:00
AudioServer: Persist audio settings with a config file
AudioServer loads its settings, currently volume and mute state, from a user config file "Audio.ini". Additionally, the current settings are stored every ten seconds, if necessary. This allows for persistent audio settings in between boots.
This commit is contained in:
parent
47bc72bcf6
commit
d1b0143ba5
3 changed files with 58 additions and 4 deletions
|
@ -1,10 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, kleines Filmröllchen <malu.bertsch@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "Mixer.h"
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/LocalServer.h>
|
||||
|
||||
int main(int, char**)
|
||||
|
@ -14,8 +17,19 @@ int main(int, char**)
|
|||
return 1;
|
||||
}
|
||||
|
||||
auto config = Core::ConfigFile::get_for_app("Audio");
|
||||
if (unveil(config->filename().characters(), "rwc") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
if (unveil("/dev/audio", "wc") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
unveil(nullptr, nullptr);
|
||||
|
||||
Core::EventLoop event_loop;
|
||||
AudioServer::Mixer mixer;
|
||||
AudioServer::Mixer mixer { config };
|
||||
|
||||
auto server = Core::LocalServer::construct();
|
||||
bool ok = server->take_over_from_system_server();
|
||||
|
@ -31,7 +45,7 @@ int main(int, char**)
|
|||
IPC::new_client_connection<AudioServer::ClientConnection>(client_socket.release_nonnull(), client_id, mixer);
|
||||
};
|
||||
|
||||
if (pledge("stdio recvfd thread accept", nullptr) < 0) {
|
||||
if (pledge("stdio recvfd thread accept cpath rpath wpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue