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

LibAudio: Allow loading sounds from memory

The Loader and WavLoaderPlugin classes now have methods for loading
from a ByteBuffer, in addition to streaming from disk.
This commit is contained in:
Julian Offenhäuser 2020-12-02 15:44:45 +01:00 committed by Andreas Kling
parent dff5983706
commit 21977a2188
5 changed files with 110 additions and 154 deletions

View file

@ -26,6 +26,8 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/MemoryStream.h>
#include <AK/OwnPtr.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
@ -40,7 +42,8 @@ class Buffer;
// Parses a WAV file and produces an Audio::Buffer.
class WavLoaderPlugin : public LoaderPlugin {
public:
explicit WavLoaderPlugin(const StringView& path);
WavLoaderPlugin(const StringView& path);
WavLoaderPlugin(const ByteBuffer& buffer);
virtual bool sniff() override;
@ -64,6 +67,7 @@ private:
bool valid { false };
RefPtr<Core::File> m_file;
OwnPtr<InputMemoryStream> m_stream;
String m_error_string;
OwnPtr<ResampleHelper> m_resampler;