LibAudio: Remove try_ prefix from fallible LoaderPlugin methods

This commit is contained in:
Linus Groh 2023-01-28 20:12:17 +00:00 committed by Jelle Raaijmakers
parent 108ea2b921
commit ee0297d9ec
Notes: sideshowbarker 2024-07-17 16:42:19 +09:00
11 changed files with 22 additions and 22 deletions

View file

@ -11,7 +11,7 @@
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
auto flac_data = ByteBuffer::copy(data, size).release_value();
auto flac_or_error = Audio::FlacLoaderPlugin::try_create(flac_data.bytes());
auto flac_or_error = Audio::FlacLoaderPlugin::create(flac_data.bytes());
if (flac_or_error.is_error())
return 0;

View file

@ -11,7 +11,7 @@
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
auto flac_data = ByteBuffer::copy(data, size).release_value();
auto mp3_or_error = Audio::MP3LoaderPlugin::try_create(flac_data.bytes());
auto mp3_or_error = Audio::MP3LoaderPlugin::create(flac_data.bytes());
if (mp3_or_error.is_error())
return 0;

View file

@ -13,7 +13,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
if (!data)
return 0;
auto wav_data = ReadonlyBytes { data, size };
auto wav_or_error = Audio::WavLoaderPlugin::try_create(wav_data);
auto wav_or_error = Audio::WavLoaderPlugin::create(wav_data);
if (wav_or_error.is_error())
return 0;

View file

@ -21,7 +21,7 @@ struct FlacTest : Test::TestCase {
void run() const
{
auto result = Audio::FlacLoaderPlugin::try_create(m_path.string());
auto result = Audio::FlacLoaderPlugin::create(m_path.string());
if (result.is_error()) {
FAIL(DeprecatedString::formatted("{} (at {})", result.error().description, result.error().index));
return;

View file

@ -30,7 +30,7 @@ FlacLoaderPlugin::FlacLoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> s
{
}
Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::try_create(StringView path)
Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::create(StringView path)
{
auto stream = LOADER_TRY(Core::Stream::BufferedFile::create(LOADER_TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read))));
auto loader = make<FlacLoaderPlugin>(move(stream));
@ -40,7 +40,7 @@ Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::try_creat
return loader;
}
Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::try_create(Bytes buffer)
Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::create(Bytes buffer)
{
auto stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(buffer));
auto loader = make<FlacLoaderPlugin>(move(stream));

View file

@ -50,8 +50,8 @@ public:
explicit FlacLoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream);
virtual ~FlacLoaderPlugin() override = default;
static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> try_create(StringView path);
static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> try_create(Bytes buffer);
static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> create(StringView path);
static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> create(Bytes buffer);
virtual LoaderSamples get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) override;

View file

@ -24,19 +24,19 @@ Loader::Loader(NonnullOwnPtr<LoaderPlugin> plugin)
Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::try_create(StringView path)
{
{
auto plugin = WavLoaderPlugin::try_create(path);
auto plugin = WavLoaderPlugin::create(path);
if (!plugin.is_error())
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
}
{
auto plugin = FlacLoaderPlugin::try_create(path);
auto plugin = FlacLoaderPlugin::create(path);
if (!plugin.is_error())
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
}
{
auto plugin = MP3LoaderPlugin::try_create(path);
auto plugin = MP3LoaderPlugin::create(path);
if (!plugin.is_error())
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
}
@ -47,19 +47,19 @@ Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::try_create(StringView p
Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::try_create(Bytes buffer)
{
{
auto plugin = WavLoaderPlugin::try_create(buffer);
auto plugin = WavLoaderPlugin::create(buffer);
if (!plugin.is_error())
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
}
{
auto plugin = FlacLoaderPlugin::try_create(buffer);
auto plugin = FlacLoaderPlugin::create(buffer);
if (!plugin.is_error())
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
}
{
auto plugin = MP3LoaderPlugin::try_create(buffer);
auto plugin = MP3LoaderPlugin::create(buffer);
if (!plugin.is_error())
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
}

View file

@ -19,7 +19,7 @@ MP3LoaderPlugin::MP3LoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> str
{
}
Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::try_create(StringView path)
Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::create(StringView path)
{
auto stream = LOADER_TRY(Core::Stream::BufferedFile::create(LOADER_TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read))));
auto loader = make<MP3LoaderPlugin>(move(stream));
@ -29,7 +29,7 @@ Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::try_create(
return loader;
}
Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::try_create(Bytes buffer)
Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::create(Bytes buffer)
{
auto stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(buffer));
auto loader = make<MP3LoaderPlugin>(move(stream));

View file

@ -26,8 +26,8 @@ public:
explicit MP3LoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream);
virtual ~MP3LoaderPlugin() = default;
static Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> try_create(StringView path);
static Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> try_create(Bytes buffer);
static Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> create(StringView path);
static Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> create(Bytes buffer);
virtual LoaderSamples get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) override;

View file

@ -23,7 +23,7 @@ WavLoaderPlugin::WavLoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> str
{
}
Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::try_create(StringView path)
Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::create(StringView path)
{
auto stream = LOADER_TRY(Core::Stream::BufferedFile::create(LOADER_TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read))));
auto loader = make<WavLoaderPlugin>(move(stream));
@ -33,7 +33,7 @@ Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::try_create(
return loader;
}
Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::try_create(Bytes buffer)
Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::create(Bytes buffer)
{
auto stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(buffer));
auto loader = make<WavLoaderPlugin>(move(stream));

View file

@ -30,8 +30,8 @@ static constexpr unsigned const WAVE_FORMAT_EXTENSIBLE = 0xFFFE; // Determined b
class WavLoaderPlugin : public LoaderPlugin {
public:
explicit WavLoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream);
static Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> try_create(StringView path);
static Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> try_create(Bytes buffer);
static Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> create(StringView path);
static Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> create(Bytes buffer);
virtual LoaderSamples get_more_samples(size_t max_samples_to_read_from_input = 128 * KiB) override;