Commit 2071070f authored by Max Kellermann's avatar Max Kellermann

DespotifyUtils: return Tag, not pointer

parent 89a78a5f
......@@ -83,8 +83,7 @@ void mpd_despotify_unregister_callback(void (*cb)(struct despotify_session *, in
}
}
Tag *
Tag
mpd_despotify_tag_from_track(const ds_track &track)
{
char tracknum[20];
......@@ -92,7 +91,7 @@ mpd_despotify_tag_from_track(const ds_track &track)
char date[20];
if (!track.has_meta_data)
return new Tag();
return Tag();
TagBuilder tag;
snprintf(tracknum, sizeof(tracknum), "%d", track.tracknumber);
......@@ -108,7 +107,7 @@ mpd_despotify_tag_from_track(const ds_track &track)
tag.AddItem(TAG_COMMENT, comment);
tag.SetTime(track.length / 1000);
return tag.CommitNew();
return tag.Commit();
}
struct despotify_session *mpd_despotify_get_session(void)
......
......@@ -42,9 +42,9 @@ struct despotify_session *mpd_despotify_get_session(void);
*
* @param track the track to convert
*
* @return a pointer to the filled in tags structure
* @return filled in #Tag structure
*/
Tag *
Tag
mpd_despotify_tag_from_track(const ds_track &track);
/**
......
......@@ -41,7 +41,7 @@ class DespotifyInputStream {
struct despotify_session *session;
struct ds_track *track;
Tag *tag;
Tag tag;
struct ds_pcm_data pcm;
size_t len_available;
bool eof;
......@@ -64,8 +64,6 @@ class DespotifyInputStream {
public:
~DespotifyInputStream() {
delete tag;
despotify_free_track(track);
}
......@@ -79,8 +77,11 @@ public:
size_t Read(void *ptr, size_t size, Error &error);
Tag *ReadTag() {
Tag *result = tag;
tag = nullptr;
if (tag.IsEmpty())
return nullptr;
Tag *result = new Tag(std::move(tag));
tag.Clear();
return result;
}
......
......@@ -53,7 +53,7 @@ add_song(std::forward_list<SongPointer> &songs, ds_track &track)
}
song = Song::NewRemote(uri);
song->tag = mpd_despotify_tag_from_track(track);
song->tag = new Tag(mpd_despotify_tag_from_track(track));
songs.emplace_front(song);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment