lib/xiph/FlacStreamMetadata: pass StringView to flac_scan_comment()
This commit is contained in:
parent
7a89b1656c
commit
01f86e1c25
@ -68,27 +68,16 @@ flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc)
|
|||||||
return mix_ramp;
|
return mix_ramp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the specified name matches the entry's name, and if yes,
|
|
||||||
* returns the comment value;
|
|
||||||
*/
|
|
||||||
static StringView
|
|
||||||
GetFlacCommentValue(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
|
||||||
StringView name) noexcept
|
|
||||||
{
|
|
||||||
return GetVorbisCommentValue(ToStringView(*entry), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the comment's name equals the passed name, and if so, copy
|
* Check if the comment's name equals the passed name, and if so, copy
|
||||||
* the comment value into the tag.
|
* the comment value into the tag.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
flac_copy_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
flac_copy_comment(StringView comment,
|
||||||
StringView name, TagType tag_type,
|
StringView name, TagType tag_type,
|
||||||
TagHandler &handler) noexcept
|
TagHandler &handler) noexcept
|
||||||
{
|
{
|
||||||
const auto value = GetFlacCommentValue(entry, name);
|
const auto value = GetVorbisCommentValue(comment, name);
|
||||||
if (!value.IsNull()) {
|
if (!value.IsNull()) {
|
||||||
handler.OnTag(tag_type, value);
|
handler.OnTag(tag_type, value);
|
||||||
return true;
|
return true;
|
||||||
@ -98,22 +87,20 @@ flac_copy_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flac_scan_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
flac_scan_comment(StringView comment, TagHandler &handler) noexcept
|
||||||
TagHandler &handler) noexcept
|
|
||||||
{
|
{
|
||||||
if (handler.WantPair()) {
|
if (handler.WantPair()) {
|
||||||
const auto comment = ToStringView(*entry);
|
const auto split = comment.Split('=');
|
||||||
const auto split = StringView(comment).Split('=');
|
|
||||||
if (!split.first.empty() && !split.second.IsNull())
|
if (!split.first.empty() && !split.second.IsNull())
|
||||||
handler.OnPair(split.first, split.second);
|
handler.OnPair(split.first, split.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const struct tag_table *i = xiph_tags; i->name != nullptr; ++i)
|
for (const struct tag_table *i = xiph_tags; i->name != nullptr; ++i)
|
||||||
if (flac_copy_comment(entry, i->name, i->type, handler))
|
if (flac_copy_comment(comment, i->name, i->type, handler))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
||||||
if (flac_copy_comment(entry,
|
if (flac_copy_comment(comment,
|
||||||
tag_item_names[i], (TagType)i,
|
tag_item_names[i], (TagType)i,
|
||||||
handler))
|
handler))
|
||||||
return;
|
return;
|
||||||
@ -124,8 +111,7 @@ flac_scan_comments(const FLAC__StreamMetadata_VorbisComment *comment,
|
|||||||
TagHandler &handler) noexcept
|
TagHandler &handler) noexcept
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < comment->num_comments; ++i)
|
for (unsigned i = 0; i < comment->num_comments; ++i)
|
||||||
flac_scan_comment(&comment->comments[i],
|
flac_scan_comment(ToStringView(comment->comments[i]), handler);
|
||||||
handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
|
Loading…
Reference in New Issue
Block a user