mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:34:59 +00:00
LibAudio: New error propagation API in Loader and Buffer
Previously, a libc-like out-of-line error information was used in the loader and its plugins. Now, all functions that may fail to do their job return some sort of Result. The universally-used error type ist the new LoaderError, which can contain information about the general error category (such as file format, I/O, unimplemented features), an error description, and location information, such as file index or sample index. Additionally, the loader plugins try to do as little work as possible in their constructors. Right after being constructed, a user should call initialize() and check the errors returned from there. (This is done transparently by Loader itself.) If a constructor caused an error, the call to initialize should check and return it immediately. This opportunity was used to rework a lot of the internal error propagation in both loader classes, especially FlacLoader. Therefore, a couple of other refactorings may have sneaked in as well. The adoption of LibAudio users is minimal. Piano's adoption is not important, as the code will receive major refactoring in the near future anyways. SoundPlayer's adoption is also less important, as changes to refactor it are in the works as well. aplay's adoption is the best and may serve as an example for other users. It also includes new buffering behavior. Buffer also gets some attention, making it OOM-safe and thereby also propagating its errors to the user.
This commit is contained in:
parent
ec8bd8116d
commit
96d02a3e75
19 changed files with 406 additions and 397 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
@ -41,6 +42,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_positional_argument(command_arguments, "Arguments for the command", "args", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
TRY(Core::System::pledge("stdio rpath wpath recvfd", nullptr));
|
||||
|
||||
if (command.equals_ignoring_case("get") || command == "g") {
|
||||
// Get variables
|
||||
Vector<AudioVariable> values_to_print;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue