DecoderAPI: pass rvalue reference to decoder_tag()
Avoid duplicating the tag.
This commit is contained in:
parent
06f898cc12
commit
cbd38327e7
@ -471,19 +471,18 @@ decoder_data(struct decoder *decoder,
|
|||||||
|
|
||||||
enum decoder_command
|
enum decoder_command
|
||||||
decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is,
|
decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is,
|
||||||
const Tag *tag)
|
Tag &&tag)
|
||||||
{
|
{
|
||||||
G_GNUC_UNUSED const struct decoder_control *dc = decoder->dc;
|
G_GNUC_UNUSED const struct decoder_control *dc = decoder->dc;
|
||||||
enum decoder_command cmd;
|
enum decoder_command cmd;
|
||||||
|
|
||||||
assert(dc->state == DECODE_STATE_DECODE);
|
assert(dc->state == DECODE_STATE_DECODE);
|
||||||
assert(dc->pipe != NULL);
|
assert(dc->pipe != NULL);
|
||||||
assert(tag != NULL);
|
|
||||||
|
|
||||||
/* save the tag */
|
/* save the tag */
|
||||||
|
|
||||||
delete decoder->decoder_tag;
|
delete decoder->decoder_tag;
|
||||||
decoder->decoder_tag = new Tag(*tag);
|
decoder->decoder_tag = new Tag(tag);
|
||||||
|
|
||||||
/* check for a new stream tag */
|
/* check for a new stream tag */
|
||||||
|
|
||||||
@ -509,7 +508,7 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is,
|
|||||||
delete merged;
|
delete merged;
|
||||||
} else
|
} else
|
||||||
/* send only the decoder tag */
|
/* send only the decoder tag */
|
||||||
cmd = do_send_tag(decoder, *tag);
|
cmd = do_send_tag(decoder, *decoder->decoder_tag);
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,7 @@ decoder_data(struct decoder *decoder, struct input_stream *is,
|
|||||||
* command pending
|
* command pending
|
||||||
*/
|
*/
|
||||||
enum decoder_command
|
enum decoder_command
|
||||||
decoder_tag(struct decoder *decoder, struct input_stream *is,
|
decoder_tag(struct decoder *decoder, struct input_stream *is, Tag &&tag);
|
||||||
const Tag *tag);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set replay gain values for the following chunks.
|
* Set replay gain values for the following chunks.
|
||||||
|
@ -174,7 +174,7 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
|
|||||||
while (true) {
|
while (true) {
|
||||||
if (data->tag != nullptr && !data->tag->IsEmpty()) {
|
if (data->tag != nullptr && !data->tag->IsEmpty()) {
|
||||||
cmd = decoder_tag(data->decoder, data->input_stream,
|
cmd = decoder_tag(data->decoder, data->input_stream,
|
||||||
data->tag);
|
std::move(*data->tag));
|
||||||
delete data->tag;
|
delete data->tag;
|
||||||
data->tag = new Tag();
|
data->tag = new Tag();
|
||||||
} else
|
} else
|
||||||
|
@ -1084,7 +1084,8 @@ MadDecoder::Read()
|
|||||||
ret = DecodeNextFrameHeader(&tag);
|
ret = DecodeNextFrameHeader(&tag);
|
||||||
|
|
||||||
if (tag != nullptr) {
|
if (tag != nullptr) {
|
||||||
decoder_tag(decoder, input_stream, tag);
|
decoder_tag(decoder, input_stream,
|
||||||
|
std::move(*tag));
|
||||||
delete tag;
|
delete tag;
|
||||||
}
|
}
|
||||||
} while (ret == DECODE_CONT);
|
} while (ret == DECODE_CONT);
|
||||||
@ -1142,7 +1143,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
|
|||||||
data.total_time);
|
data.total_time);
|
||||||
|
|
||||||
if (tag != nullptr) {
|
if (tag != nullptr) {
|
||||||
decoder_tag(decoder, input_stream, tag);
|
decoder_tag(decoder, input_stream, std::move(*tag));
|
||||||
delete tag;
|
delete tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
|
|||||||
if (ScanOpusTags(packet.packet, packet.bytes,
|
if (ScanOpusTags(packet.packet, packet.bytes,
|
||||||
&add_tag_handler, &tag) &&
|
&add_tag_handler, &tag) &&
|
||||||
!tag.IsEmpty())
|
!tag.IsEmpty())
|
||||||
cmd = decoder_tag(decoder, input_stream, &tag);
|
cmd = decoder_tag(decoder, input_stream, std::move(tag));
|
||||||
else
|
else
|
||||||
cmd = decoder_get_command(decoder);
|
cmd = decoder_get_command(decoder);
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ vorbis_send_comments(struct decoder *decoder, struct input_stream *is,
|
|||||||
if (!tag)
|
if (!tag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
decoder_tag(decoder, is, tag);
|
decoder_tag(decoder, is, std::move(*tag));
|
||||||
delete tag;
|
delete tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ decoder_data(G_GNUC_UNUSED struct decoder *decoder,
|
|||||||
enum decoder_command
|
enum decoder_command
|
||||||
decoder_tag(G_GNUC_UNUSED struct decoder *decoder,
|
decoder_tag(G_GNUC_UNUSED struct decoder *decoder,
|
||||||
G_GNUC_UNUSED struct input_stream *is,
|
G_GNUC_UNUSED struct input_stream *is,
|
||||||
G_GNUC_UNUSED const Tag *tag)
|
G_GNUC_UNUSED Tag &&tag)
|
||||||
{
|
{
|
||||||
return DECODE_COMMAND_NONE;
|
return DECODE_COMMAND_NONE;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ decoder_data(G_GNUC_UNUSED struct decoder *decoder,
|
|||||||
enum decoder_command
|
enum decoder_command
|
||||||
decoder_tag(G_GNUC_UNUSED struct decoder *decoder,
|
decoder_tag(G_GNUC_UNUSED struct decoder *decoder,
|
||||||
G_GNUC_UNUSED struct input_stream *is,
|
G_GNUC_UNUSED struct input_stream *is,
|
||||||
G_GNUC_UNUSED const Tag *tag)
|
G_GNUC_UNUSED Tag &&tag)
|
||||||
{
|
{
|
||||||
return DECODE_COMMAND_NONE;
|
return DECODE_COMMAND_NONE;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ decoder_data(G_GNUC_UNUSED struct decoder *decoder,
|
|||||||
enum decoder_command
|
enum decoder_command
|
||||||
decoder_tag(G_GNUC_UNUSED struct decoder *decoder,
|
decoder_tag(G_GNUC_UNUSED struct decoder *decoder,
|
||||||
G_GNUC_UNUSED struct input_stream *is,
|
G_GNUC_UNUSED struct input_stream *is,
|
||||||
G_GNUC_UNUSED const Tag *tag)
|
G_GNUC_UNUSED Tag &&tag)
|
||||||
{
|
{
|
||||||
return DECODE_COMMAND_NONE;
|
return DECODE_COMMAND_NONE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user