diff options
author | Tim Schumacher <timschumi@gmx.de> | 2022-12-05 00:41:23 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-05 17:49:47 +0100 |
commit | c57be0f47496d2bb23da25224833f9080f9cbcc4 (patch) | |
tree | d30a8762aece6a79167c1fcf7e6ef2a1223e4038 /Userland/Libraries/LibAudio/FlacLoader.h | |
parent | 3cf93d0dd2377b3ce85362db05e47a373006a56e (diff) | |
download | serenity-c57be0f47496d2bb23da25224833f9080f9cbcc4.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibAudio/FlacLoader.h')
-rw-r--r-- | Userland/Libraries/LibAudio/FlacLoader.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibAudio/FlacLoader.h b/Userland/Libraries/LibAudio/FlacLoader.h index 6e3a6dd585..4271b43f29 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.h +++ b/Userland/Libraries/LibAudio/FlacLoader.h @@ -47,11 +47,11 @@ ALWAYS_INLINE ErrorOr<i32> decode_unsigned_exp_golomb(u8 order, BigEndianInputBi // https://datatracker.ietf.org/doc/html/draft-ietf-cellar-flac-03 (newer IETF draft that uses incompatible numberings and names) class FlacLoaderPlugin : public LoaderPlugin { public: - explicit FlacLoaderPlugin(StringView path); - explicit FlacLoaderPlugin(Bytes buffer); + explicit FlacLoaderPlugin(OwnPtr<Core::Stream::SeekableStream> stream); virtual ~FlacLoaderPlugin() override = default; - virtual MaybeLoaderError initialize() override; + static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> try_create(StringView path); + static Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> try_create(Bytes buffer); virtual LoaderSamples get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) override; @@ -69,6 +69,7 @@ public: bool sample_count_unknown() const { return m_total_samples == 0; } private: + MaybeLoaderError initialize(); MaybeLoaderError parse_header(); // Either returns the metadata block or sets error message. // Additionally, increments m_data_start_location past the read meta block. |