playlist/Mapper: use Storage::OpenFile()
This commit is contained in:
parent
6dfdd8c1c2
commit
131dcce0a1
|
@ -26,16 +26,16 @@ class SongLoader {
|
|||
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Database *const db;
|
||||
const Storage *const storage;
|
||||
Storage *const storage;
|
||||
#endif
|
||||
|
||||
public:
|
||||
#ifdef ENABLE_DATABASE
|
||||
explicit SongLoader(const IClient &_client) noexcept;
|
||||
SongLoader(const Database *_db, const Storage *_storage) noexcept
|
||||
SongLoader(const Database *_db, Storage *_storage) noexcept
|
||||
:client(nullptr), db(_db), storage(_storage) {}
|
||||
SongLoader(const IClient &_client, const Database *_db,
|
||||
const Storage *_storage) noexcept
|
||||
Storage *_storage) noexcept
|
||||
:client(&_client), db(_db), storage(_storage) {}
|
||||
#else
|
||||
explicit SongLoader(const IClient &_client) noexcept
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
#endif
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Storage *GetStorage() const noexcept {
|
||||
Storage *GetStorage() const noexcept {
|
||||
return storage;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -99,7 +99,7 @@ Client::GetDatabaseOrThrow() const
|
|||
return partition->instance.GetDatabaseOrThrow();
|
||||
}
|
||||
|
||||
const Storage *
|
||||
Storage *
|
||||
Client::GetStorage() const noexcept
|
||||
{
|
||||
return partition->instance.storage;
|
||||
|
|
|
@ -248,7 +248,7 @@ public:
|
|||
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Database *GetDatabase() const noexcept override;
|
||||
const Storage *GetStorage() const noexcept override;
|
||||
Storage *GetStorage() const noexcept override;
|
||||
#endif // ENABLE_DATABASE
|
||||
|
||||
private:
|
||||
|
|
|
@ -34,6 +34,6 @@ public:
|
|||
virtual const Database *GetDatabase() const noexcept = 0;
|
||||
|
||||
[[gnu::pure]]
|
||||
virtual const Storage *GetStorage() const noexcept = 0;
|
||||
virtual Storage *GetStorage() const noexcept = 0;
|
||||
#endif // ENABLE_DATABASE
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
std::unique_ptr<SongEnumerator>
|
||||
playlist_open_any(const LocatedUri &located_uri,
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Storage *storage,
|
||||
Storage *storage,
|
||||
#endif
|
||||
Mutex &mutex)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,6 @@ class Storage;
|
|||
std::unique_ptr<SongEnumerator>
|
||||
playlist_open_any(const LocatedUri &located_uri,
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Storage *storage,
|
||||
Storage *storage,
|
||||
#endif
|
||||
Mutex &mutex);
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
|
||||
#include "PlaylistMapper.hxx"
|
||||
#include "PlaylistFile.hxx"
|
||||
#include "PlaylistRegistry.hxx"
|
||||
#include "PlaylistStream.hxx"
|
||||
#include "SongEnumerator.hxx"
|
||||
#include "Mapper.hxx"
|
||||
#include "input/InputStream.hxx"
|
||||
#include "input/WaitReady.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "storage/StorageInterface.hxx"
|
||||
#include "util/UriUtil.hxx"
|
||||
|
@ -33,7 +36,7 @@ playlist_open_in_playlist_dir(const char *uri, Mutex &mutex)
|
|||
* Load a playlist from the configured music directory.
|
||||
*/
|
||||
static std::unique_ptr<SongEnumerator>
|
||||
playlist_open_in_storage(const char *uri, const Storage *storage, Mutex &mutex)
|
||||
playlist_open_in_storage(const char *uri, Storage *storage, Mutex &mutex)
|
||||
{
|
||||
assert(uri_safe_local(uri));
|
||||
|
||||
|
@ -43,8 +46,9 @@ playlist_open_in_storage(const char *uri, const Storage *storage, Mutex &mutex)
|
|||
if (const auto path = storage->MapFS(uri); !path.IsNull())
|
||||
return playlist_open_path(path, mutex);
|
||||
|
||||
const auto uri2 = storage->MapUTF8(uri);
|
||||
return playlist_open_remote(uri2.c_str(), mutex);
|
||||
auto is = storage->OpenFile(uri, mutex);
|
||||
LockWaitReady(*is);
|
||||
return playlist_list_open_stream(std::move(is), uri);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -52,7 +56,7 @@ playlist_open_in_storage(const char *uri, const Storage *storage, Mutex &mutex)
|
|||
std::unique_ptr<SongEnumerator>
|
||||
playlist_mapper_open(const char *uri,
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Storage *storage,
|
||||
Storage *storage,
|
||||
#endif
|
||||
Mutex &mutex)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,6 @@ class Storage;
|
|||
std::unique_ptr<SongEnumerator>
|
||||
playlist_mapper_open(const char *uri,
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Storage *storage,
|
||||
Storage *storage,
|
||||
#endif
|
||||
Mutex &mutex);
|
||||
|
|
|
@ -123,7 +123,7 @@ public:
|
|||
return reinterpret_cast<const Database *>(this);
|
||||
}
|
||||
|
||||
const Storage *GetStorage() const noexcept override {
|
||||
Storage *GetStorage() const noexcept override {
|
||||
return ::storage;
|
||||
}
|
||||
#endif // ENABLE_DATABASE
|
||||
|
|
Loading…
Reference in New Issue