mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
LibAudio: Remove try_
prefix from fallible LoaderPlugin methods
This commit is contained in:
parent
108ea2b921
commit
ee0297d9ec
11 changed files with 22 additions and 22 deletions
|
@ -11,7 +11,7 @@
|
||||||
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
||||||
{
|
{
|
||||||
auto flac_data = ByteBuffer::copy(data, size).release_value();
|
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())
|
if (flac_or_error.is_error())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
||||||
{
|
{
|
||||||
auto flac_data = ByteBuffer::copy(data, size).release_value();
|
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())
|
if (mp3_or_error.is_error())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -13,7 +13,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
||||||
if (!data)
|
if (!data)
|
||||||
return 0;
|
return 0;
|
||||||
auto wav_data = ReadonlyBytes { data, size };
|
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())
|
if (wav_or_error.is_error())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct FlacTest : Test::TestCase {
|
||||||
|
|
||||||
void run() const
|
void run() const
|
||||||
{
|
{
|
||||||
auto result = Audio::FlacLoaderPlugin::try_create(m_path.string());
|
auto result = Audio::FlacLoaderPlugin::create(m_path.string());
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
FAIL(DeprecatedString::formatted("{} (at {})", result.error().description, result.error().index));
|
FAIL(DeprecatedString::formatted("{} (at {})", result.error().description, result.error().index));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -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 stream = LOADER_TRY(Core::Stream::BufferedFile::create(LOADER_TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read))));
|
||||||
auto loader = make<FlacLoaderPlugin>(move(stream));
|
auto loader = make<FlacLoaderPlugin>(move(stream));
|
||||||
|
@ -40,7 +40,7 @@ Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::try_creat
|
||||||
return loader;
|
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 stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(buffer));
|
||||||
auto loader = make<FlacLoaderPlugin>(move(stream));
|
auto loader = make<FlacLoaderPlugin>(move(stream));
|
||||||
|
|
|
@ -50,8 +50,8 @@ public:
|
||||||
explicit FlacLoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream);
|
explicit FlacLoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream);
|
||||||
virtual ~FlacLoaderPlugin() override = default;
|
virtual ~FlacLoaderPlugin() override = default;
|
||||||
|
|
||||||
static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> try_create(StringView path);
|
static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> create(StringView path);
|
||||||
static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> try_create(Bytes buffer);
|
static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> create(Bytes buffer);
|
||||||
|
|
||||||
virtual LoaderSamples get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) override;
|
virtual LoaderSamples get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) override;
|
||||||
|
|
||||||
|
|
|
@ -24,19 +24,19 @@ Loader::Loader(NonnullOwnPtr<LoaderPlugin> plugin)
|
||||||
Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::try_create(StringView path)
|
Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::try_create(StringView path)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto plugin = WavLoaderPlugin::try_create(path);
|
auto plugin = WavLoaderPlugin::create(path);
|
||||||
if (!plugin.is_error())
|
if (!plugin.is_error())
|
||||||
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto plugin = FlacLoaderPlugin::try_create(path);
|
auto plugin = FlacLoaderPlugin::create(path);
|
||||||
if (!plugin.is_error())
|
if (!plugin.is_error())
|
||||||
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto plugin = MP3LoaderPlugin::try_create(path);
|
auto plugin = MP3LoaderPlugin::create(path);
|
||||||
if (!plugin.is_error())
|
if (!plugin.is_error())
|
||||||
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
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)
|
Result<NonnullOwnPtr<LoaderPlugin>, LoaderError> Loader::try_create(Bytes buffer)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto plugin = WavLoaderPlugin::try_create(buffer);
|
auto plugin = WavLoaderPlugin::create(buffer);
|
||||||
if (!plugin.is_error())
|
if (!plugin.is_error())
|
||||||
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto plugin = FlacLoaderPlugin::try_create(buffer);
|
auto plugin = FlacLoaderPlugin::create(buffer);
|
||||||
if (!plugin.is_error())
|
if (!plugin.is_error())
|
||||||
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto plugin = MP3LoaderPlugin::try_create(buffer);
|
auto plugin = MP3LoaderPlugin::create(buffer);
|
||||||
if (!plugin.is_error())
|
if (!plugin.is_error())
|
||||||
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
return NonnullOwnPtr<LoaderPlugin>(plugin.release_value());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 stream = LOADER_TRY(Core::Stream::BufferedFile::create(LOADER_TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read))));
|
||||||
auto loader = make<MP3LoaderPlugin>(move(stream));
|
auto loader = make<MP3LoaderPlugin>(move(stream));
|
||||||
|
@ -29,7 +29,7 @@ Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::try_create(
|
||||||
return loader;
|
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 stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(buffer));
|
||||||
auto loader = make<MP3LoaderPlugin>(move(stream));
|
auto loader = make<MP3LoaderPlugin>(move(stream));
|
||||||
|
|
|
@ -26,8 +26,8 @@ public:
|
||||||
explicit MP3LoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream);
|
explicit MP3LoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream);
|
||||||
virtual ~MP3LoaderPlugin() = default;
|
virtual ~MP3LoaderPlugin() = default;
|
||||||
|
|
||||||
static Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> try_create(StringView path);
|
static Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> create(StringView path);
|
||||||
static Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> try_create(Bytes buffer);
|
static Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> create(Bytes buffer);
|
||||||
|
|
||||||
virtual LoaderSamples get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) override;
|
virtual LoaderSamples get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) override;
|
||||||
|
|
||||||
|
|
|
@ -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 stream = LOADER_TRY(Core::Stream::BufferedFile::create(LOADER_TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read))));
|
||||||
auto loader = make<WavLoaderPlugin>(move(stream));
|
auto loader = make<WavLoaderPlugin>(move(stream));
|
||||||
|
@ -33,7 +33,7 @@ Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::try_create(
|
||||||
return loader;
|
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 stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(buffer));
|
||||||
auto loader = make<WavLoaderPlugin>(move(stream));
|
auto loader = make<WavLoaderPlugin>(move(stream));
|
||||||
|
|
|
@ -30,8 +30,8 @@ static constexpr unsigned const WAVE_FORMAT_EXTENSIBLE = 0xFFFE; // Determined b
|
||||||
class WavLoaderPlugin : public LoaderPlugin {
|
class WavLoaderPlugin : public LoaderPlugin {
|
||||||
public:
|
public:
|
||||||
explicit WavLoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream);
|
explicit WavLoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream);
|
||||||
static Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> try_create(StringView path);
|
static Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> create(StringView path);
|
||||||
static Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> try_create(Bytes buffer);
|
static Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> create(Bytes buffer);
|
||||||
|
|
||||||
virtual LoaderSamples get_more_samples(size_t max_samples_to_read_from_input = 128 * KiB) override;
|
virtual LoaderSamples get_more_samples(size_t max_samples_to_read_from_input = 128 * KiB) override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue