mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
aplay: Add unveil and pledge promises
This commit is contained in:
parent
2cf02c6f38
commit
5c74e66f85
1 changed files with 9 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <LibAudio/Loader.h>
|
#include <LibAudio/Loader.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
#include <LibMain/Main.h>
|
#include <LibMain/Main.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -20,6 +21,8 @@ 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"));
|
||||||
|
|
||||||
const char* path = nullptr;
|
const char* path = nullptr;
|
||||||
bool should_loop = false;
|
bool should_loop = false;
|
||||||
bool show_sample_progress = false;
|
bool show_sample_progress = false;
|
||||||
|
@ -30,6 +33,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
args_parser.add_option(show_sample_progress, "Show playback progress in samples", "sample-progress", 's');
|
args_parser.add_option(show_sample_progress, "Show playback progress in samples", "sample-progress", 's');
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
|
TRY(Core::System::unveil(Core::File::absolute_path(path), "r"));
|
||||||
|
TRY(Core::System::unveil("/tmp/portal/audio", "rw"));
|
||||||
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
||||||
Core::EventLoop loop;
|
Core::EventLoop loop;
|
||||||
|
|
||||||
auto audio_client = TRY(Audio::ClientConnection::try_create());
|
auto audio_client = TRY(Audio::ClientConnection::try_create());
|
||||||
|
@ -40,6 +47,8 @@ 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"));
|
||||||
|
|
||||||
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, {}",
|
||||||
loader->format_name(),
|
loader->format_name(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue