mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +00:00
LibAudio: Move WAV sample reading and conversion into own helpers
This completely removes WavLoader's dependency on LegacyBuffer: We directly create the result sample container and write into it. I took this opportunity to rewrite most of the sample reading functions as a single templated function, which combined with the better error handling makes this "ported" code super concise.
This commit is contained in:
parent
a32d675164
commit
f14a71eb34
2 changed files with 87 additions and 11 deletions
|
@ -7,12 +7,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Span.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibAudio/Loader.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
@ -53,6 +53,10 @@ public:
|
|||
private:
|
||||
MaybeLoaderError parse_header();
|
||||
|
||||
LoaderSamples samples_from_pcm_data(Bytes const& data, size_t samples_to_read) const;
|
||||
template<typename SampleReader>
|
||||
MaybeLoaderError read_samples_from_stream(Core::Stream::Stream& stream, SampleReader read_sample, FixedArray<Sample>& samples) const;
|
||||
|
||||
// This is only kept around for compatibility for now.
|
||||
RefPtr<Core::File> m_file;
|
||||
OwnPtr<Core::Stream::SeekableStream> m_stream;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue