
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.
36 lines
734 B
C++
36 lines
734 B
C++
/*
|
|
* Copyright (c) 2018-2021, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibAudio/FlacLoader.h>
|
|
#include <LibAudio/WavLoader.h>
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
}
|