summaryrefslogtreecommitdiff
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-12-20 15:24:41 +0100
committerMax Kellermann <max@musicpd.org>2017-12-20 15:24:41 +0100
commit9f33c6fe03cc1a061d7ce81603654a4a3e285ab6 (patch)
tree5e088f94828fb68fb399eddf47a05d8c7cc06077 /src/decoder
parent73e69edac3fc6960d6bf89fca420c27f83b95d8e (diff)
decoder/Bridge: use std::unique_ptr<Tag>
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/Bridge.cxx20
-rw-r--r--src/decoder/Bridge.hxx11
-rw-r--r--src/decoder/DecoderThread.cxx2
3 files changed, 13 insertions, 20 deletions
diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx
index d4038f0ac..d6138777e 100644
--- a/src/decoder/Bridge.cxx
+++ b/src/decoder/Bridge.cxx
@@ -47,10 +47,6 @@ DecoderBridge::~DecoderBridge()
convert->Close();
delete convert;
}
-
- delete song_tag;
- delete stream_tag;
- delete decoder_tag;
}
bool
@@ -222,11 +218,11 @@ DecoderBridge::DoSendTag(const Tag &tag)
bool
DecoderBridge::UpdateStreamTag(InputStream *is)
{
- auto *tag = is != nullptr
- ? is->LockReadTag().release()
+ auto tag = is != nullptr
+ ? is->LockReadTag()
: nullptr;
if (tag == nullptr) {
- tag = song_tag;
+ tag = std::move(song_tag);
if (tag == nullptr)
return false;
@@ -234,12 +230,9 @@ DecoderBridge::UpdateStreamTag(InputStream *is)
instead */
} else
/* discard the song tag; we don't need it */
- delete song_tag;
-
- song_tag = nullptr;
+ song_tag.reset();
- delete stream_tag;
- stream_tag = tag;
+ stream_tag = std::move(tag);
return true;
}
@@ -540,8 +533,7 @@ DecoderBridge::SubmitTag(InputStream *is, Tag &&tag)
/* save the tag */
- delete decoder_tag;
- decoder_tag = new Tag(std::move(tag));
+ decoder_tag = std::make_unique<Tag>(std::move(tag));
/* check for a new stream tag */
diff --git a/src/decoder/Bridge.hxx b/src/decoder/Bridge.hxx
index 3b354c063..a2f333f65 100644
--- a/src/decoder/Bridge.hxx
+++ b/src/decoder/Bridge.hxx
@@ -24,6 +24,7 @@
#include "ReplayGainInfo.hxx"
#include <exception>
+#include <memory>
class PcmConvert;
struct MusicChunk;
@@ -74,13 +75,13 @@ public:
* files, because we expect the stream server to send us a new
* tag each time we play it.
*/
- Tag *song_tag;
+ std::unique_ptr<Tag> song_tag;
/** the last tag received from the stream */
- Tag *stream_tag = nullptr;
+ std::unique_ptr<Tag> stream_tag;
/** the last tag received from the decoder plugin */
- Tag *decoder_tag = nullptr;
+ std::unique_ptr<Tag> decoder_tag;
/** the chunk currently being written to */
MusicChunk *current_chunk = nullptr;
@@ -100,10 +101,10 @@ public:
std::exception_ptr error;
DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending,
- Tag *_tag)
+ std::unique_ptr<Tag> _tag)
:dc(_dc),
initial_seek_pending(_initial_seek_pending),
- song_tag(_tag) {}
+ song_tag(std::move(_tag)) {}
~DecoderBridge();
diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx
index f09592828..39c6460a2 100644
--- a/src/decoder/DecoderThread.cxx
+++ b/src/decoder/DecoderThread.cxx
@@ -447,7 +447,7 @@ decoder_run_song(DecoderControl &dc,
file - tags on "stream" songs are just
remembered from the last time we
played it*/
- song.IsFile() ? new Tag(song.GetTag()) : nullptr);
+ song.IsFile() ? std::make_unique<Tag>(song.GetTag()) : nullptr);
dc.state = DecoderState::START;
dc.CommandFinishedLocked();