decoder/Bridge: use std::unique_ptr<Tag>
This commit is contained in:
parent
73e69edac3
commit
9f33c6fe03
@ -47,10 +47,6 @@ DecoderBridge::~DecoderBridge()
|
|||||||
convert->Close();
|
convert->Close();
|
||||||
delete convert;
|
delete convert;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete song_tag;
|
|
||||||
delete stream_tag;
|
|
||||||
delete decoder_tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -222,11 +218,11 @@ DecoderBridge::DoSendTag(const Tag &tag)
|
|||||||
bool
|
bool
|
||||||
DecoderBridge::UpdateStreamTag(InputStream *is)
|
DecoderBridge::UpdateStreamTag(InputStream *is)
|
||||||
{
|
{
|
||||||
auto *tag = is != nullptr
|
auto tag = is != nullptr
|
||||||
? is->LockReadTag().release()
|
? is->LockReadTag()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (tag == nullptr) {
|
if (tag == nullptr) {
|
||||||
tag = song_tag;
|
tag = std::move(song_tag);
|
||||||
if (tag == nullptr)
|
if (tag == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -234,12 +230,9 @@ DecoderBridge::UpdateStreamTag(InputStream *is)
|
|||||||
instead */
|
instead */
|
||||||
} else
|
} else
|
||||||
/* discard the song tag; we don't need it */
|
/* discard the song tag; we don't need it */
|
||||||
delete song_tag;
|
song_tag.reset();
|
||||||
|
|
||||||
song_tag = nullptr;
|
stream_tag = std::move(tag);
|
||||||
|
|
||||||
delete stream_tag;
|
|
||||||
stream_tag = tag;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,8 +533,7 @@ DecoderBridge::SubmitTag(InputStream *is, Tag &&tag)
|
|||||||
|
|
||||||
/* save the tag */
|
/* save the tag */
|
||||||
|
|
||||||
delete decoder_tag;
|
decoder_tag = std::make_unique<Tag>(std::move(tag));
|
||||||
decoder_tag = new Tag(std::move(tag));
|
|
||||||
|
|
||||||
/* check for a new stream tag */
|
/* check for a new stream tag */
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "ReplayGainInfo.hxx"
|
#include "ReplayGainInfo.hxx"
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class PcmConvert;
|
class PcmConvert;
|
||||||
struct MusicChunk;
|
struct MusicChunk;
|
||||||
@ -74,13 +75,13 @@ public:
|
|||||||
* files, because we expect the stream server to send us a new
|
* files, because we expect the stream server to send us a new
|
||||||
* tag each time we play it.
|
* tag each time we play it.
|
||||||
*/
|
*/
|
||||||
Tag *song_tag;
|
std::unique_ptr<Tag> song_tag;
|
||||||
|
|
||||||
/** the last tag received from the stream */
|
/** 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 */
|
/** the last tag received from the decoder plugin */
|
||||||
Tag *decoder_tag = nullptr;
|
std::unique_ptr<Tag> decoder_tag;
|
||||||
|
|
||||||
/** the chunk currently being written to */
|
/** the chunk currently being written to */
|
||||||
MusicChunk *current_chunk = nullptr;
|
MusicChunk *current_chunk = nullptr;
|
||||||
@ -100,10 +101,10 @@ public:
|
|||||||
std::exception_ptr error;
|
std::exception_ptr error;
|
||||||
|
|
||||||
DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending,
|
DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending,
|
||||||
Tag *_tag)
|
std::unique_ptr<Tag> _tag)
|
||||||
:dc(_dc),
|
:dc(_dc),
|
||||||
initial_seek_pending(_initial_seek_pending),
|
initial_seek_pending(_initial_seek_pending),
|
||||||
song_tag(_tag) {}
|
song_tag(std::move(_tag)) {}
|
||||||
|
|
||||||
~DecoderBridge();
|
~DecoderBridge();
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ decoder_run_song(DecoderControl &dc,
|
|||||||
file - tags on "stream" songs are just
|
file - tags on "stream" songs are just
|
||||||
remembered from the last time we
|
remembered from the last time we
|
||||||
played it*/
|
played it*/
|
||||||
song.IsFile() ? new Tag(song.GetTag()) : nullptr);
|
song.IsFile() ? std::make_unique<Tag>(song.GetTag()) : nullptr);
|
||||||
|
|
||||||
dc.state = DecoderState::START;
|
dc.state = DecoderState::START;
|
||||||
dc.CommandFinishedLocked();
|
dc.CommandFinishedLocked();
|
||||||
|
Loading…
Reference in New Issue
Block a user