1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:38:12 +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

@ -30,12 +30,9 @@ using MaybeLoaderError = Result<void, LoaderError>;
class LoaderPlugin {
public:
explicit LoaderPlugin(StringView path);
explicit LoaderPlugin(Bytes buffer);
explicit LoaderPlugin(OwnPtr<Core::Stream::SeekableStream> stream);
virtual ~LoaderPlugin() = default;
virtual MaybeLoaderError initialize() = 0;
virtual LoaderSamples get_more_samples(size_t max_bytes_to_read_from_input = 128 * KiB) = 0;
virtual MaybeLoaderError reset() = 0;
@ -61,10 +58,7 @@ public:
Vector<PictureData> const& pictures() const { return m_pictures; };
protected:
StringView m_path;
OwnPtr<Core::Stream::SeekableStream> m_stream;
// The constructor might set this so that we can initialize the data stream later.
Optional<Bytes> m_backing_memory;
Vector<PictureData> m_pictures;
};