mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:07:34 +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:
parent
754b129f4a
commit
c837a1a8de
10 changed files with 42 additions and 31 deletions
|
@ -26,21 +26,18 @@
|
|||
namespace Audio {
|
||||
|
||||
FlacLoaderPlugin::FlacLoaderPlugin(StringView path)
|
||||
: m_path(path)
|
||||
: LoaderPlugin(path)
|
||||
{
|
||||
}
|
||||
|
||||
FlacLoaderPlugin::FlacLoaderPlugin(Bytes& buffer)
|
||||
: m_backing_memory(buffer)
|
||||
FlacLoaderPlugin::FlacLoaderPlugin(Bytes buffer)
|
||||
: LoaderPlugin(buffer)
|
||||
{
|
||||
}
|
||||
|
||||
MaybeLoaderError FlacLoaderPlugin::initialize()
|
||||
{
|
||||
if (m_backing_memory.has_value())
|
||||
m_stream = LOADER_TRY(Core::Stream::MemoryStream::construct(m_backing_memory.value()));
|
||||
else
|
||||
m_stream = LOADER_TRY(Core::Stream::File::open(m_path, Core::Stream::OpenMode::Read));
|
||||
LOADER_TRY(LoaderPlugin::initialize());
|
||||
|
||||
TRY(parse_header());
|
||||
TRY(reset());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue