1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +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,7 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/StringView.h>
@ -58,6 +59,7 @@ public:
class Loader : public RefCounted<Loader> {
public:
static NonnullRefPtr<Loader> create(const StringView& path) { return adopt(*new Loader(path)); }
static NonnullRefPtr<Loader> create(const ByteBuffer& buffer) { return adopt(*new Loader(buffer)); }
bool has_error() const { return m_plugin ? m_plugin->has_error() : true; }
const char* error_string() const { return m_plugin ? m_plugin->error_string() : "No loader plugin available"; }
@ -84,6 +86,7 @@ public:
private:
Loader(const StringView& path);
Loader(const ByteBuffer& buffer);
mutable OwnPtr<LoaderPlugin> m_plugin;
};