diff options
Diffstat (limited to '')
-rw-r--r-- | src/playlist/PlaylistAny.cxx | 12 | ||||
-rw-r--r-- | src/playlist/PlaylistAny.hxx | 7 | ||||
-rw-r--r-- | src/playlist/PlaylistMapper.cxx | 25 | ||||
-rw-r--r-- | src/playlist/PlaylistMapper.hxx | 9 | ||||
-rw-r--r-- | src/playlist/PlaylistQueue.cxx | 10 | ||||
-rw-r--r-- | src/playlist/Print.cxx | 7 |
6 files changed, 58 insertions, 12 deletions
diff --git a/src/playlist/PlaylistAny.cxx b/src/playlist/PlaylistAny.cxx index 457de18b3..7093fb99a 100644 --- a/src/playlist/PlaylistAny.cxx +++ b/src/playlist/PlaylistAny.cxx @@ -24,9 +24,17 @@ #include "util/UriUtil.hxx" SongEnumerator * -playlist_open_any(const char *uri, Mutex &mutex, Cond &cond) +playlist_open_any(const char *uri, +#ifdef ENABLE_DATABASE + const Storage *storage, +#endif + Mutex &mutex, Cond &cond) { return uri_has_scheme(uri) ? playlist_open_remote(uri, mutex, cond) - : playlist_mapper_open(uri, mutex, cond); + : playlist_mapper_open(uri, +#ifdef ENABLE_DATABASE + storage, +#endif + mutex, cond); } diff --git a/src/playlist/PlaylistAny.hxx b/src/playlist/PlaylistAny.hxx index 6ee792993..23b0075b6 100644 --- a/src/playlist/PlaylistAny.hxx +++ b/src/playlist/PlaylistAny.hxx @@ -23,6 +23,7 @@ class Mutex; class Cond; class SongEnumerator; +class Storage; /** * Opens a playlist from the specified URI, which can be either an @@ -30,6 +31,10 @@ class SongEnumerator; * music orplaylist directory. */ SongEnumerator * -playlist_open_any(const char *uri, Mutex &mutex, Cond &cond); +playlist_open_any(const char *uri, +#ifdef ENABLE_DATABASE + const Storage *storage, +#endif + Mutex &mutex, Cond &cond); #endif diff --git a/src/playlist/PlaylistMapper.cxx b/src/playlist/PlaylistMapper.cxx index 141e0563f..bbcbaf1fe 100644 --- a/src/playlist/PlaylistMapper.cxx +++ b/src/playlist/PlaylistMapper.cxx @@ -24,6 +24,7 @@ #include "PlaylistRegistry.hxx" #include "Mapper.hxx" #include "fs/AllocatedPath.hxx" +#include "storage/StorageInterface.hxx" #include "util/UriUtil.hxx" #include <assert.h> @@ -57,21 +58,32 @@ playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond) * Load a playlist from the configured music directory. */ static SongEnumerator * -playlist_open_in_music_dir(const char *uri, Mutex &mutex, Cond &cond) +playlist_open_in_storage(const char *uri, const Storage *storage, + Mutex &mutex, Cond &cond) { assert(uri_safe_local(uri)); - const auto path = map_uri_fs(uri); - if (path.IsNull()) + if (storage == nullptr) return nullptr; - return playlist_open_path(path.c_str(), mutex, cond); + { + const auto path = storage->MapFS(uri); + if (!path.IsNull()) + return playlist_open_path(path.c_str(), mutex, cond); + } + + const auto uri2 = storage->MapUTF8(uri); + return playlist_open_remote(uri, mutex, cond); } #endif SongEnumerator * -playlist_mapper_open(const char *uri, Mutex &mutex, Cond &cond) +playlist_mapper_open(const char *uri, +#ifdef ENABLE_DATABASE + const Storage *storage, +#endif + Mutex &mutex, Cond &cond) { if (spl_valid_name(uri)) { auto playlist = playlist_open_in_playlist_dir(uri, @@ -82,7 +94,8 @@ playlist_mapper_open(const char *uri, Mutex &mutex, Cond &cond) #ifdef ENABLE_DATABASE if (uri_safe_local(uri)) { - auto playlist = playlist_open_in_music_dir(uri, mutex, cond); + auto playlist = playlist_open_in_storage(uri, storage, + mutex, cond); if (playlist != nullptr) return playlist; } diff --git a/src/playlist/PlaylistMapper.hxx b/src/playlist/PlaylistMapper.hxx index 01c982763..29ce45083 100644 --- a/src/playlist/PlaylistMapper.hxx +++ b/src/playlist/PlaylistMapper.hxx @@ -20,15 +20,22 @@ #ifndef MPD_PLAYLIST_MAPPER_HXX #define MPD_PLAYLIST_MAPPER_HXX +#include "check.h" + class Mutex; class Cond; class SongEnumerator; +class Storage; /** * Opens a playlist from an URI relative to the playlist or music * directory. */ SongEnumerator * -playlist_mapper_open(const char *uri, Mutex &mutex, Cond &cond); +playlist_mapper_open(const char *uri, +#ifdef ENABLE_DATABASE + const Storage *storage, +#endif + Mutex &mutex, Cond &cond); #endif diff --git a/src/playlist/PlaylistQueue.cxx b/src/playlist/PlaylistQueue.cxx index 85bf7ca72..80018658d 100644 --- a/src/playlist/PlaylistQueue.cxx +++ b/src/playlist/PlaylistQueue.cxx @@ -28,6 +28,10 @@ #include "thread/Cond.hxx" #include "fs/Traits.hxx" +#ifdef ENABLE_DATABASE +#include "SongLoader.hxx" +#endif + PlaylistResult playlist_load_into_queue(const char *uri, SongEnumerator &e, unsigned start_index, unsigned end_index, @@ -72,7 +76,11 @@ playlist_open_into_queue(const char *uri, Mutex mutex; Cond cond; - auto playlist = playlist_open_any(uri, mutex, cond); + auto playlist = playlist_open_any(uri, +#ifdef ENABLE_DATABASE + loader.GetStorage(), +#endif + mutex, cond); if (playlist == nullptr) return PlaylistResult::NO_SUCH_LIST; diff --git a/src/playlist/Print.cxx b/src/playlist/Print.cxx index 5031a4b94..0db2a4ab0 100644 --- a/src/playlist/Print.cxx +++ b/src/playlist/Print.cxx @@ -28,6 +28,7 @@ #include "fs/Traits.hxx" #include "thread/Mutex.hxx" #include "thread/Cond.hxx" +#include "client/Client.hxx" static void playlist_provider_print(Client &client, const char *uri, @@ -59,7 +60,11 @@ playlist_file_print(Client &client, const char *uri, bool detail) Mutex mutex; Cond cond; - SongEnumerator *playlist = playlist_open_any(uri, mutex, cond); + SongEnumerator *playlist = playlist_open_any(uri, +#ifdef ENABLE_DATABASE + client.GetStorage(), +#endif + mutex, cond); if (playlist == nullptr) return false; |