diff options
author | Max Kellermann <max@duempel.org> | 2014-01-08 19:21:48 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-08 19:49:27 +0100 |
commit | 2071070f39216accc02550102017e4f8abb9b5ea (patch) | |
tree | 0470aa32f02ff7b8ab27d77e015a93a0731c98e5 /src | |
parent | 89a78a5f3c4f648e9f20e83ac1d4769eff24c5b8 (diff) | |
download | mpd-2071070f39216accc02550102017e4f8abb9b5ea.tar.gz mpd-2071070f39216accc02550102017e4f8abb9b5ea.tar.xz mpd-2071070f39216accc02550102017e4f8abb9b5ea.zip |
DespotifyUtils: return Tag, not pointer
Diffstat (limited to '')
-rw-r--r-- | src/DespotifyUtils.cxx | 7 | ||||
-rw-r--r-- | src/DespotifyUtils.hxx | 4 | ||||
-rw-r--r-- | src/input/DespotifyInputPlugin.cxx | 11 | ||||
-rw-r--r-- | src/playlist/DespotifyPlaylistPlugin.cxx | 2 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/DespotifyUtils.cxx b/src/DespotifyUtils.cxx index 2a30f11f3..8a499d75d 100644 --- a/src/DespotifyUtils.cxx +++ b/src/DespotifyUtils.cxx @@ -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) diff --git a/src/DespotifyUtils.hxx b/src/DespotifyUtils.hxx index ad22acf92..c8d90afa4 100644 --- a/src/DespotifyUtils.hxx +++ b/src/DespotifyUtils.hxx @@ -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); /** diff --git a/src/input/DespotifyInputPlugin.cxx b/src/input/DespotifyInputPlugin.cxx index 787e0722e..18704bd40 100644 --- a/src/input/DespotifyInputPlugin.cxx +++ b/src/input/DespotifyInputPlugin.cxx @@ -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; } diff --git a/src/playlist/DespotifyPlaylistPlugin.cxx b/src/playlist/DespotifyPlaylistPlugin.cxx index f082778ab..67400e20a 100644 --- a/src/playlist/DespotifyPlaylistPlugin.cxx +++ b/src/playlist/DespotifyPlaylistPlugin.cxx @@ -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); } |