diff --git a/src/SongSave.cxx b/src/SongSave.cxx index 039be9d87..ce761e544 100644 --- a/src/SongSave.cxx +++ b/src/SongSave.cxx @@ -81,11 +81,11 @@ song_save(BufferedOutputStream &os, const DetachedSong &song) os.Format(SONG_END "\n"); } -std::unique_ptr +DetachedSong song_load(TextFile &file, const char *uri, AudioFormat *audio_format_r) { - auto song = std::make_unique(uri); + DetachedSong song(uri); TagBuilder tag; @@ -117,7 +117,7 @@ song_load(TextFile &file, const char *uri, } else if (StringIsEqual(line, "Playlist")) { tag.SetHasPlaylist(StringIsEqual(value, "yes")); } else if (StringIsEqual(line, SONG_MTIME)) { - song->SetLastModified(std::chrono::system_clock::from_time_t(atoi(value))); + song.SetLastModified(std::chrono::system_clock::from_time_t(atoi(value))); } else if (StringIsEqual(line, "Range")) { char *endptr; @@ -126,13 +126,13 @@ song_load(TextFile &file, const char *uri, ? strtoul(endptr + 1, nullptr, 10) : 0; - song->SetStartTime(SongTime::FromMS(start_ms)); - song->SetEndTime(SongTime::FromMS(end_ms)); + song.SetStartTime(SongTime::FromMS(start_ms)); + song.SetEndTime(SongTime::FromMS(end_ms)); } else { throw FormatRuntimeError("unknown line in db: %s", line); } } - song->SetTag(tag.Commit()); + song.SetTag(tag.Commit()); return song; } diff --git a/src/SongSave.hxx b/src/SongSave.hxx index 15da0e725..579ec6f30 100644 --- a/src/SongSave.hxx +++ b/src/SongSave.hxx @@ -42,7 +42,7 @@ song_save(BufferedOutputStream &os, const DetachedSong &song); * * Throws on error. */ -std::unique_ptr +DetachedSong song_load(TextFile &file, const char *uri, AudioFormat *audio_format_r=nullptr); diff --git a/src/db/plugins/simple/DirectorySave.cxx b/src/db/plugins/simple/DirectorySave.cxx index 753e0e1dc..783dcc3f0 100644 --- a/src/db/plugins/simple/DirectorySave.cxx +++ b/src/db/plugins/simple/DirectorySave.cxx @@ -165,7 +165,7 @@ directory_load(TextFile &file, Directory &directory) auto detached_song = song_load(file, name, &audio_format); - auto song = std::make_unique(std::move(*detached_song), + auto song = std::make_unique(std::move(detached_song), directory); song->audio_format = audio_format; diff --git a/src/queue/QueueSave.cxx b/src/queue/QueueSave.cxx index f759701f7..464b906ca 100644 --- a/src/queue/QueueSave.cxx +++ b/src/queue/QueueSave.cxx @@ -73,7 +73,7 @@ queue_save(BufferedOutputStream &os, const Queue &queue) } } -static std::unique_ptr +static DetachedSong LoadQueueSong(TextFile &file, const char *line) { std::unique_ptr song; @@ -89,7 +89,7 @@ LoadQueueSong(TextFile &file, const char *line) const char *uri = endptr + 1; - return std::make_unique(uri); + return DetachedSong(uri); } } @@ -112,8 +112,8 @@ queue_load_song(TextFile &file, const SongLoader &loader, auto song = LoadQueueSong(file, line); - if (!playlist_check_translate_song(*song, nullptr, loader)) + if (!playlist_check_translate_song(song, nullptr, loader)) return; - queue.Append(std::move(*song), priority); + queue.Append(std::move(song), priority); }