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

LibAudio: Remove the last occurrence of Core::File in the Wav plugin

This commit is contained in:
Lucas CHOLLET 2022-10-13 15:19:36 +02:00 committed by Linus Groh
parent 2d6124049a
commit f028930033
2 changed files with 3 additions and 5 deletions

View file

@ -19,7 +19,7 @@ namespace Audio {
static constexpr size_t const maximum_wav_size = 1 * GiB; // FIXME: is there a more appropriate size limit? static constexpr size_t const maximum_wav_size = 1 * GiB; // FIXME: is there a more appropriate size limit?
WavLoaderPlugin::WavLoaderPlugin(StringView path) WavLoaderPlugin::WavLoaderPlugin(StringView path)
: m_file(Core::File::construct(path)) : m_path(path)
{ {
} }
@ -28,7 +28,7 @@ MaybeLoaderError WavLoaderPlugin::initialize()
if (m_backing_memory.has_value()) if (m_backing_memory.has_value())
m_stream = LOADER_TRY(Core::Stream::MemoryStream::construct(m_backing_memory.value())); m_stream = LOADER_TRY(Core::Stream::MemoryStream::construct(m_backing_memory.value()));
else else
m_stream = LOADER_TRY(Core::Stream::File::open(m_file->filename(), Core::Stream::OpenMode::Read)); m_stream = LOADER_TRY(Core::Stream::File::open(m_path, Core::Stream::OpenMode::Read));
TRY(parse_header()); TRY(parse_header());
return {}; return {};

View file

@ -48,7 +48,6 @@ public:
virtual u16 num_channels() override { return m_num_channels; } virtual u16 num_channels() override { return m_num_channels; }
virtual String format_name() override { return "RIFF WAVE (.wav)"; } virtual String format_name() override { return "RIFF WAVE (.wav)"; }
virtual PcmSampleFormat pcm_format() override { return m_sample_format; } virtual PcmSampleFormat pcm_format() override { return m_sample_format; }
virtual RefPtr<Core::File> file() override { return m_file; }
private: private:
MaybeLoaderError parse_header(); MaybeLoaderError parse_header();
@ -57,8 +56,7 @@ private:
template<typename SampleReader> template<typename SampleReader>
MaybeLoaderError read_samples_from_stream(Core::Stream::Stream& stream, SampleReader read_sample, FixedArray<Sample>& samples) const; 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. StringView m_path;
RefPtr<Core::File> m_file;
OwnPtr<Core::Stream::SeekableStream> m_stream; OwnPtr<Core::Stream::SeekableStream> m_stream;
// The constructor might set this so that we can initialize the data stream later. // The constructor might set this so that we can initialize the data stream later.
Optional<Bytes const&> m_backing_memory; Optional<Bytes const&> m_backing_memory;