From b4b0b34e5a131f02f723f40cf9566cc43e37cf85 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 3 Jan 2013 00:30:15 +0100 Subject: database.h: eliminate db_*_song() Use the C++ API. --- src/QueueSave.cxx | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src/QueueSave.cxx') diff --git a/src/QueueSave.cxx b/src/QueueSave.cxx index 96713c70..d8b698a9 100644 --- a/src/QueueSave.cxx +++ b/src/QueueSave.cxx @@ -21,11 +21,12 @@ #include "QueueSave.hxx" #include "song.h" #include "SongSave.hxx" +#include "DatabasePlugin.hxx" +#include "DatabaseGlue.hxx" extern "C" { #include "queue.h" #include "uri.h" -#include "database.h" #include "text_file.h" } @@ -69,20 +70,10 @@ queue_save(FILE *fp, const struct queue *queue) } } -static struct song * -get_song(const char *uri) -{ - return uri_has_scheme(uri) - ? song_remote_new(uri) - : db_get_song(uri); -} - void queue_load_song(FILE *fp, GString *buffer, const char *line, struct queue *queue) { - struct song *song; - if (queue_is_full(queue)) return; @@ -95,6 +86,9 @@ queue_load_song(FILE *fp, GString *buffer, const char *line, return; } + const Database *db = nullptr; + struct song *song; + if (g_str_has_prefix(line, SONG_BEGIN)) { const char *uri = line + sizeof(SONG_BEGIN) - 1; if (!uri_has_scheme(uri) && !g_path_is_absolute(uri)) @@ -115,15 +109,23 @@ queue_load_song(FILE *fp, GString *buffer, const char *line, return; } - line = endptr + 1; + const char *uri = endptr + 1; - song = get_song(line); - if (song == NULL) - return; + if (uri_has_scheme(uri)) { + song = song_remote_new(uri); + } else { + db = GetDatabase(nullptr); + if (db == nullptr) + return; + + song = db->GetSong(uri, nullptr); + if (song == nullptr) + return; + } } queue_append(queue, song, priority); - if (song_in_database(song)) - db_return_song(song); + if (db != nullptr) + db->ReturnSong(song); } -- cgit v1.2.3