1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +00:00

LibAudio: Switch LoaderPlugin to a more traditional constructor pattern

This now prepares all the needed (fallible) components before actually
constructing a LoaderPlugin object, so we are no longer filling them in
at an arbitrary later point in time.
This commit is contained in:
Tim Schumacher 2022-12-05 00:41:23 +01:00 committed by Andreas Kling
parent 3cf93d0dd2
commit c57be0f474
12 changed files with 132 additions and 86 deletions

View file

@ -21,14 +21,16 @@ struct FlacTest : Test::TestCase {
void run() const
{
auto loader = Audio::FlacLoaderPlugin { m_path.string() };
if (auto result = loader.initialize(); result.is_error()) {
auto result = Audio::FlacLoaderPlugin::try_create(m_path.string());
if (result.is_error()) {
FAIL(String::formatted("{} (at {})", result.error().description, result.error().index));
return;
}
auto loader = result.release_value();
while (true) {
auto maybe_samples = loader.get_more_samples(2 * MiB);
auto maybe_samples = loader->get_more_samples(2 * MiB);
if (maybe_samples.is_error()) {
FAIL(String::formatted("{} (at {})", maybe_samples.error().description, maybe_samples.error().index));
return;