1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:08:13 +00:00

LibAudio: Implement a basic FLAC loader

This commit adds a loader for the FLAC audio codec, the Free Lossless
Audio codec by the Xiph.Org foundation. LibAudio will automatically
read and parse FLAC files, so users do not need to adjust.

This implementation is bare-bones and needs to be improved upon.
There are many bugs, verbatim subframes and any kind of seeking is
not supported. However, stereo files exported by libavcodec on
highest compression setting seem to work well.
This commit is contained in:
kleines Filmröllchen 2021-06-25 13:54:14 +02:00 committed by Ali Mohammad Pur
parent 184a9e7e67
commit 22d7e57955
5 changed files with 1069 additions and 1 deletions

View file

@ -1,9 +1,10 @@
/*
* Copyright (c) 2018-2020, the SerenityOS developers.
* Copyright (c) 2018-2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibAudio/FlacLoader.h>
#include <LibAudio/WavLoader.h>
namespace Audio {
@ -11,6 +12,9 @@ namespace Audio {
Loader::Loader(const StringView& path)
{
m_plugin = make<WavLoaderPlugin>(path);
if (m_plugin->sniff())
return;
m_plugin = make<FlacLoaderPlugin>(path);
if (m_plugin->sniff())
return;
m_plugin = nullptr;
@ -21,6 +25,11 @@ Loader::Loader(const ByteBuffer& buffer)
m_plugin = make<WavLoaderPlugin>(buffer);
if (m_plugin->sniff())
return;
m_plugin = make<FlacLoaderPlugin>(buffer);
if (m_plugin->sniff()) {
dbgln("FLAC sniff successful");
return;
}
m_plugin = nullptr;
}