mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibAudio: Detect and read FLAC metadata
FLAC uses the very simple vorbis comment metadata format, which we can now read most standard and non-standard fields from.
This commit is contained in:
parent
d8e8ddedf3
commit
a8963a270f
5 changed files with 160 additions and 1 deletions
|
@ -21,6 +21,7 @@
|
|||
#include <LibAudio/FlacTypes.h>
|
||||
#include <LibAudio/LoaderError.h>
|
||||
#include <LibAudio/Resampler.h>
|
||||
#include <LibAudio/VorbisComment.h>
|
||||
#include <LibCore/File.h>
|
||||
|
||||
namespace Audio {
|
||||
|
@ -131,6 +132,10 @@ MaybeLoaderError FlacLoaderPlugin::parse_header()
|
|||
[[fallthrough]];
|
||||
case FlacMetadataBlockType::PADDING:
|
||||
// Note: A padding block is empty and does not need any treatment.
|
||||
break;
|
||||
case FlacMetadataBlockType::VORBIS_COMMENT:
|
||||
load_vorbis_comment(block);
|
||||
break;
|
||||
default:
|
||||
// TODO: Parse the remaining metadata block types.
|
||||
break;
|
||||
|
@ -180,6 +185,17 @@ MaybeLoaderError FlacLoaderPlugin::load_picture(FlacRawMetadataBlock& block)
|
|||
return {};
|
||||
}
|
||||
|
||||
// 11.15. METADATA_BLOCK_VORBIS_COMMENT
|
||||
void FlacLoaderPlugin::load_vorbis_comment(FlacRawMetadataBlock& block)
|
||||
{
|
||||
auto metadata_or_error = Audio::load_vorbis_comment(block.data);
|
||||
if (metadata_or_error.is_error()) {
|
||||
dbgln("FLAC Warning: Vorbis comment invalid, error: {}", metadata_or_error.release_error());
|
||||
return;
|
||||
}
|
||||
m_metadata = metadata_or_error.release_value();
|
||||
}
|
||||
|
||||
// 11.13. METADATA_BLOCK_SEEKTABLE
|
||||
MaybeLoaderError FlacLoaderPlugin::load_seektable(FlacRawMetadataBlock& block)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue