diff options
author | Max Kellermann <max@duempel.org> | 2013-01-03 00:30:15 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-03 00:37:18 +0100 |
commit | b4b0b34e5a131f02f723f40cf9566cc43e37cf85 (patch) | |
tree | c2afa49fe0b8f879a4c0c393e36916fde3c8ea8a /src/QueueSave.cxx | |
parent | fa3d1156a6bdbb8fab2a90e1716a1f152f7e8104 (diff) | |
download | mpd-b4b0b34e5a131f02f723f40cf9566cc43e37cf85.tar.gz mpd-b4b0b34e5a131f02f723f40cf9566cc43e37cf85.tar.xz mpd-b4b0b34e5a131f02f723f40cf9566cc43e37cf85.zip |
database.h: eliminate db_*_song()
Use the C++ API.
Diffstat (limited to 'src/QueueSave.cxx')
-rw-r--r-- | src/QueueSave.cxx | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/QueueSave.cxx b/src/QueueSave.cxx index 96713c700..d8b698a9a 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); } |