/* * Copyright (c) 2018-2021, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include namespace Audio { LoaderPlugin::LoaderPlugin(NonnullOwnPtr stream) : m_stream(move(stream)) { } Loader::Loader(NonnullOwnPtr plugin) : m_plugin(move(plugin)) { } Result, LoaderError> Loader::create_plugin(StringView path) { { auto plugin = WavLoaderPlugin::create(path); if (!plugin.is_error()) return NonnullOwnPtr(plugin.release_value()); } { auto plugin = FlacLoaderPlugin::create(path); if (!plugin.is_error()) return NonnullOwnPtr(plugin.release_value()); } { auto plugin = MP3LoaderPlugin::create(path); if (!plugin.is_error()) return NonnullOwnPtr(plugin.release_value()); } return LoaderError { "No loader plugin available" }; } Result, LoaderError> Loader::create_plugin(Bytes buffer) { { auto plugin = WavLoaderPlugin::create(buffer); if (!plugin.is_error()) return NonnullOwnPtr(plugin.release_value()); } { auto plugin = FlacLoaderPlugin::create(buffer); if (!plugin.is_error()) return NonnullOwnPtr(plugin.release_value()); } { auto plugin = MP3LoaderPlugin::create(buffer); if (!plugin.is_error()) return NonnullOwnPtr(plugin.release_value()); } return LoaderError { "No loader plugin available" }; } }