aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-07-31 00:26:55 +0200
committerMax Kellermann <max@duempel.org>2013-07-31 00:35:05 +0200
commit7f9402bd22f02a46b32d53560094622493f33f37 (patch)
treeb96b437520be32a512943985035939b9b94e5223 /src/decoder
parentcbd38327e7f6948647768227ac4836f64e5ccd51 (diff)
downloadmpd-7f9402bd22f02a46b32d53560094622493f33f37.tar.gz
mpd-7f9402bd22f02a46b32d53560094622493f33f37.tar.xz
mpd-7f9402bd22f02a46b32d53560094622493f33f37.zip
Tag: add method Clear()
Allow reusing Tag instances.
Diffstat (limited to '')
-rw-r--r--src/decoder/FlacCommon.cxx13
-rw-r--r--src/decoder/FlacCommon.hxx3
-rw-r--r--src/decoder/FlacDecoderPlugin.cxx8
-rw-r--r--src/decoder/FlacMetadata.cxx4
-rw-r--r--src/decoder/FlacMetadata.hxx2
5 files changed, 10 insertions, 20 deletions
diff --git a/src/decoder/FlacCommon.cxx b/src/decoder/FlacCommon.cxx
index 6b6c20d3c..32917ed86 100644
--- a/src/decoder/FlacCommon.cxx
+++ b/src/decoder/FlacCommon.cxx
@@ -36,16 +36,10 @@ flac_data::flac_data(struct decoder *_decoder,
:FlacInput(_input_stream, _decoder),
initialized(false), unsupported(false),
total_frames(0), first_frame(0), next_frame(0), position(0),
- decoder(_decoder), input_stream(_input_stream),
- tag(nullptr)
+ decoder(_decoder), input_stream(_input_stream)
{
}
-flac_data::~flac_data()
-{
- delete tag;
-}
-
static enum sample_format
flac_sample_format(unsigned bits_per_sample)
{
@@ -116,9 +110,8 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
decoder_mixramp(data->decoder,
mixramp_start, mixramp_end);
- if (data->tag != nullptr)
- flac_vorbis_comments_to_tag(data->tag,
- &block->data.vorbis_comment);
+ flac_vorbis_comments_to_tag(data->tag,
+ &block->data.vorbis_comment);
default:
break;
diff --git a/src/decoder/FlacCommon.hxx b/src/decoder/FlacCommon.hxx
index e3555efba..d2e240d81 100644
--- a/src/decoder/FlacCommon.hxx
+++ b/src/decoder/FlacCommon.hxx
@@ -81,10 +81,9 @@ struct flac_data : public FlacInput {
struct decoder *decoder;
struct input_stream *input_stream;
- Tag *tag;
+ Tag tag;
flac_data(struct decoder *decoder, struct input_stream *input_stream);
- ~flac_data();
};
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
diff --git a/src/decoder/FlacDecoderPlugin.cxx b/src/decoder/FlacDecoderPlugin.cxx
index 4140d14f7..fc0925610 100644
--- a/src/decoder/FlacDecoderPlugin.cxx
+++ b/src/decoder/FlacDecoderPlugin.cxx
@@ -172,11 +172,10 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
data->first_frame = t_start;
while (true) {
- if (data->tag != nullptr && !data->tag->IsEmpty()) {
+ if (!data->tag.IsEmpty()) {
cmd = decoder_tag(data->decoder, data->input_stream,
- std::move(*data->tag));
- delete data->tag;
- data->tag = new Tag();
+ std::move(data->tag));
+ data->tag.Clear();
} else
cmd = decoder_get_command(decoder);
@@ -260,7 +259,6 @@ flac_decode_internal(struct decoder * decoder,
return;
struct flac_data data(decoder, input_stream);
- data.tag = new Tag();
FLAC__StreamDecoderInitStatus status =
stream_init(flac_dec, &data, is_ogg);
diff --git a/src/decoder/FlacMetadata.cxx b/src/decoder/FlacMetadata.cxx
index 3c0120ab4..be15092b5 100644
--- a/src/decoder/FlacMetadata.cxx
+++ b/src/decoder/FlacMetadata.cxx
@@ -228,10 +228,10 @@ flac_scan_metadata(const FLAC__StreamMetadata *block,
}
void
-flac_vorbis_comments_to_tag(Tag *tag,
+flac_vorbis_comments_to_tag(Tag &tag,
const FLAC__StreamMetadata_VorbisComment *comment)
{
- flac_scan_comments(comment, &add_tag_handler, tag);
+ flac_scan_comments(comment, &add_tag_handler, &tag);
}
void
diff --git a/src/decoder/FlacMetadata.hxx b/src/decoder/FlacMetadata.hxx
index 52c6abbce..57769672f 100644
--- a/src/decoder/FlacMetadata.hxx
+++ b/src/decoder/FlacMetadata.hxx
@@ -130,7 +130,7 @@ flac_parse_mixramp(char **mixramp_start, char **mixramp_end,
const FLAC__StreamMetadata *block);
void
-flac_vorbis_comments_to_tag(Tag *tag,
+flac_vorbis_comments_to_tag(Tag &tag,
const FLAC__StreamMetadata_VorbisComment *comment);
void