1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:37:45 +00:00

LibAudio: Factorize stream initialisation to base class LoaderPlugin

All actual plugins follow the same logic to initialize their stream,
this commit factorizes all of this to their base class: `LoaderPlugin`.
This commit is contained in:
Lucas CHOLLET 2022-10-13 16:05:57 +02:00 committed by Linus Groh
parent 754b129f4a
commit c837a1a8de
10 changed files with 42 additions and 31 deletions

View file

@ -30,7 +30,7 @@ static constexpr unsigned const WAVE_FORMAT_EXTENSIBLE = 0xFFFE; // Determined b
class WavLoaderPlugin : public LoaderPlugin {
public:
explicit WavLoaderPlugin(StringView path);
explicit WavLoaderPlugin(Bytes const& buffer);
explicit WavLoaderPlugin(Bytes buffer);
virtual MaybeLoaderError initialize() override;
@ -56,11 +56,6 @@ private:
template<typename SampleReader>
MaybeLoaderError read_samples_from_stream(Core::Stream::Stream& stream, SampleReader read_sample, FixedArray<Sample>& samples) const;
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 const&> m_backing_memory;
u32 m_sample_rate { 0 };
u16 m_num_channels { 0 };
PcmSampleFormat m_sample_format;