tag/TagBuilder: overload Commit() returning a Tag object
This commit is contained in:
parent
ac1983eae3
commit
bc23a6bb05
@ -103,8 +103,8 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
|
|||||||
|
|
||||||
decoder_mixramp(data->decoder, flac_parse_mixramp(block));
|
decoder_mixramp(data->decoder, flac_parse_mixramp(block));
|
||||||
|
|
||||||
flac_vorbis_comments_to_tag(data->tag,
|
data->tag = flac_vorbis_comments_to_tag(&block->data.vorbis_comment);
|
||||||
&block->data.vorbis_comment);
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "tag/TagHandler.hxx"
|
#include "tag/TagHandler.hxx"
|
||||||
#include "tag/TagTable.hxx"
|
#include "tag/TagTable.hxx"
|
||||||
#include "tag/TagBuilder.hxx"
|
#include "tag/TagBuilder.hxx"
|
||||||
|
#include "tag/Tag.hxx"
|
||||||
#include "ReplayGainInfo.hxx"
|
#include "ReplayGainInfo.hxx"
|
||||||
#include "util/ASCII.hxx"
|
#include "util/ASCII.hxx"
|
||||||
#include "util/SplitString.hxx"
|
#include "util/SplitString.hxx"
|
||||||
@ -199,13 +200,12 @@ flac_scan_metadata(const FLAC__StreamMetadata *block,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
Tag
|
||||||
flac_vorbis_comments_to_tag(Tag &tag,
|
flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment)
|
||||||
const FLAC__StreamMetadata_VorbisComment *comment)
|
|
||||||
{
|
{
|
||||||
TagBuilder tag_builder;
|
TagBuilder tag_builder;
|
||||||
flac_scan_comments(comment, &add_tag_handler, &tag_builder);
|
flac_scan_comments(comment, &add_tag_handler, &tag_builder);
|
||||||
tag_builder.Commit(tag);
|
return tag_builder.Commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -130,9 +130,8 @@ flac_parse_replay_gain(ReplayGainInfo &rgi,
|
|||||||
MixRampInfo
|
MixRampInfo
|
||||||
flac_parse_mixramp(const FLAC__StreamMetadata *block);
|
flac_parse_mixramp(const FLAC__StreamMetadata *block);
|
||||||
|
|
||||||
void
|
Tag
|
||||||
flac_vorbis_comments_to_tag(Tag &tag,
|
flac_vorbis_comments_to_tag(const FLAC__StreamMetadata_VorbisComment *comment);
|
||||||
const FLAC__StreamMetadata_VorbisComment *comment);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
flac_scan_metadata(const FLAC__StreamMetadata *block,
|
flac_scan_metadata(const FLAC__StreamMetadata *block,
|
||||||
|
@ -292,8 +292,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
|
|||||||
!tag_builder.IsEmpty()) {
|
!tag_builder.IsEmpty()) {
|
||||||
decoder_replay_gain(decoder, &rgi);
|
decoder_replay_gain(decoder, &rgi);
|
||||||
|
|
||||||
Tag tag;
|
Tag tag = tag_builder.Commit();
|
||||||
tag_builder.Commit(tag);
|
|
||||||
cmd = decoder_tag(decoder, input_stream, std::move(tag));
|
cmd = decoder_tag(decoder, input_stream, std::move(tag));
|
||||||
} else
|
} else
|
||||||
cmd = decoder_get_command(decoder);
|
cmd = decoder_get_command(decoder);
|
||||||
|
@ -782,7 +782,7 @@ copy_icy_tag(struct input_curl *c)
|
|||||||
if (!c->meta_name.empty() && !tag->HasType(TAG_NAME)) {
|
if (!c->meta_name.empty() && !tag->HasType(TAG_NAME)) {
|
||||||
TagBuilder tag_builder(std::move(*tag));
|
TagBuilder tag_builder(std::move(*tag));
|
||||||
tag_builder.AddItem(TAG_NAME, c->meta_name.c_str());
|
tag_builder.AddItem(TAG_NAME, c->meta_name.c_str());
|
||||||
tag_builder.Commit(*tag);
|
*tag = tag_builder.Commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
c->tag = tag;
|
c->tag = tag;
|
||||||
|
@ -133,6 +133,14 @@ TagBuilder::Commit(Tag &tag)
|
|||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tag
|
||||||
|
TagBuilder::Commit()
|
||||||
|
{
|
||||||
|
Tag tag;
|
||||||
|
Commit(tag);
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
Tag *
|
Tag *
|
||||||
TagBuilder::CommitNew()
|
TagBuilder::CommitNew()
|
||||||
{
|
{
|
||||||
|
@ -96,6 +96,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void Commit(Tag &tag);
|
void Commit(Tag &tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new #Tag instance from data in this object. This
|
||||||
|
* object is empty afterwards.
|
||||||
|
*/
|
||||||
|
Tag Commit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new #Tag instance from data in this object. The
|
* Create a new #Tag instance from data in this object. The
|
||||||
* returned object is owned by the caller. This object is
|
* returned object is owned by the caller. This object is
|
||||||
|
Loading…
Reference in New Issue
Block a user