db: add compile-time option to disable database
This commit is contained in:
parent
34b309b99a
commit
4465e2c46b
97
Makefile.am
97
Makefile.am
@ -17,7 +17,6 @@ noinst_LIBRARIES = \
|
||||
libtag.a \
|
||||
libinput.a \
|
||||
libfs.a \
|
||||
libdb_plugins.a \
|
||||
libplaylist_plugins.a \
|
||||
libdecoder_plugins.a \
|
||||
libfilter_plugins.a \
|
||||
@ -85,7 +84,6 @@ src_mpd_SOURCES = \
|
||||
src/command/TagCommands.cxx src/command/TagCommands.hxx \
|
||||
src/command/PlayerCommands.cxx src/command/PlayerCommands.hxx \
|
||||
src/command/PlaylistCommands.cxx src/command/PlaylistCommands.hxx \
|
||||
src/command/DatabaseCommands.cxx src/command/DatabaseCommands.hxx \
|
||||
src/command/FileCommands.cxx src/command/FileCommands.hxx \
|
||||
src/command/OutputCommands.cxx src/command/OutputCommands.hxx \
|
||||
src/command/MessageCommands.cxx src/command/MessageCommands.hxx \
|
||||
@ -103,37 +101,10 @@ src_mpd_SOURCES = \
|
||||
src/decoder/DecoderPlugin.hxx \
|
||||
src/decoder/DecoderInternal.cxx src/decoder/DecoderInternal.hxx \
|
||||
src/decoder/DecoderPrint.cxx src/decoder/DecoderPrint.hxx \
|
||||
src/db/Uri.hxx \
|
||||
src/db/Directory.cxx src/db/Directory.hxx \
|
||||
src/db/DirectorySave.cxx src/db/DirectorySave.hxx \
|
||||
src/db/DatabaseSimple.hxx \
|
||||
src/db/DatabaseGlue.cxx src/db/DatabaseGlue.hxx \
|
||||
src/db/DatabaseSong.cxx src/db/DatabaseSong.hxx \
|
||||
src/db/DatabasePrint.cxx src/db/DatabasePrint.hxx \
|
||||
src/db/DatabaseQueue.cxx src/db/DatabaseQueue.hxx \
|
||||
src/db/DatabasePlaylist.cxx src/db/DatabasePlaylist.hxx \
|
||||
src/db/DatabaseError.cxx src/db/DatabaseError.hxx \
|
||||
src/db/DatabaseLock.cxx src/db/DatabaseLock.hxx \
|
||||
src/db/DatabaseSave.cxx src/db/DatabaseSave.hxx \
|
||||
src/db/DatabasePlugin.hxx \
|
||||
src/db/DatabaseListener.hxx \
|
||||
src/db/Visitor.hxx \
|
||||
src/db/Selection.cxx src/db/Selection.hxx \
|
||||
src/filter/FilterConfig.cxx src/filter/FilterConfig.hxx \
|
||||
src/filter/FilterPlugin.cxx src/filter/FilterPlugin.hxx \
|
||||
src/filter/FilterInternal.hxx \
|
||||
src/filter/FilterRegistry.cxx src/filter/FilterRegistry.hxx \
|
||||
src/db/update/UpdateDomain.cxx src/db/update/UpdateDomain.hxx \
|
||||
src/db/update/Service.cxx src/db/update/Service.hxx \
|
||||
src/db/update/UpdateGlue.cxx \
|
||||
src/db/update/Queue.cxx src/db/update/Queue.hxx \
|
||||
src/db/update/UpdateIO.cxx src/db/update/UpdateIO.hxx \
|
||||
src/db/update/Editor.cxx src/db/update/Editor.hxx \
|
||||
src/db/update/Walk.cxx src/db/update/Walk.hxx \
|
||||
src/db/update/UpdateSong.cxx \
|
||||
src/db/update/Container.cxx \
|
||||
src/db/update/Remove.cxx src/db/update/Remove.hxx \
|
||||
src/db/update/ExcludeList.cxx src/db/update/ExcludeList.hxx \
|
||||
src/client/Client.cxx src/client/Client.hxx \
|
||||
src/client/ClientInternal.hxx \
|
||||
src/client/ClientEvent.cxx \
|
||||
@ -189,8 +160,6 @@ src_mpd_SOURCES = \
|
||||
src/playlist/Print.cxx src/playlist/Print.hxx \
|
||||
src/db/PlaylistVector.cxx src/db/PlaylistVector.hxx \
|
||||
src/db/PlaylistInfo.hxx \
|
||||
src/PlaylistDatabase.cxx src/PlaylistDatabase.hxx \
|
||||
src/PlaylistUpdate.cxx \
|
||||
src/queue/IdTable.hxx \
|
||||
src/queue/Queue.cxx src/queue/Queue.hxx \
|
||||
src/queue/QueuePrint.cxx src/queue/QueuePrint.hxx \
|
||||
@ -198,13 +167,9 @@ src_mpd_SOURCES = \
|
||||
src/ReplayGainConfig.cxx src/ReplayGainConfig.hxx \
|
||||
src/ReplayGainInfo.cxx src/ReplayGainInfo.hxx \
|
||||
src/DetachedSong.cxx src/DetachedSong.hxx \
|
||||
src/db/LightSong.cxx src/db/LightSong.hxx \
|
||||
src/db/LightDirectory.hxx \
|
||||
src/db/Song.cxx src/db/Song.hxx \
|
||||
src/SongUpdate.cxx \
|
||||
src/SongPrint.cxx src/SongPrint.hxx \
|
||||
src/SongSave.cxx src/SongSave.hxx \
|
||||
src/db/SongSort.cxx src/db/SongSort.hxx \
|
||||
src/StateFile.cxx src/StateFile.hxx \
|
||||
src/Stats.cxx src/Stats.hxx \
|
||||
src/TagPrint.cxx src/TagPrint.hxx \
|
||||
@ -216,6 +181,44 @@ src_mpd_SOURCES = \
|
||||
src/PlaylistFile.cxx src/PlaylistFile.hxx \
|
||||
src/Timer.cxx
|
||||
|
||||
if ENABLE_DATABASE
|
||||
src_mpd_SOURCES += \
|
||||
src/PlaylistUpdate.cxx \
|
||||
src/PlaylistDatabase.cxx src/PlaylistDatabase.hxx \
|
||||
src/command/DatabaseCommands.cxx src/command/DatabaseCommands.hxx \
|
||||
src/db/LightSong.cxx src/db/LightSong.hxx \
|
||||
src/db/LightDirectory.hxx \
|
||||
src/db/Song.cxx src/db/Song.hxx \
|
||||
src/db/SongSort.cxx src/db/SongSort.hxx \
|
||||
src/db/update/UpdateDomain.cxx src/db/update/UpdateDomain.hxx \
|
||||
src/db/update/Service.cxx src/db/update/Service.hxx \
|
||||
src/db/update/UpdateGlue.cxx \
|
||||
src/db/update/Queue.cxx src/db/update/Queue.hxx \
|
||||
src/db/update/UpdateIO.cxx src/db/update/UpdateIO.hxx \
|
||||
src/db/update/Editor.cxx src/db/update/Editor.hxx \
|
||||
src/db/update/Walk.cxx src/db/update/Walk.hxx \
|
||||
src/db/update/UpdateSong.cxx \
|
||||
src/db/update/Container.cxx \
|
||||
src/db/update/Remove.cxx src/db/update/Remove.hxx \
|
||||
src/db/update/ExcludeList.cxx src/db/update/ExcludeList.hxx \
|
||||
src/db/Uri.hxx \
|
||||
src/db/Directory.cxx src/db/Directory.hxx \
|
||||
src/db/DirectorySave.cxx src/db/DirectorySave.hxx \
|
||||
src/db/DatabaseSimple.hxx \
|
||||
src/db/DatabaseGlue.cxx src/db/DatabaseGlue.hxx \
|
||||
src/db/DatabaseSong.cxx src/db/DatabaseSong.hxx \
|
||||
src/db/DatabasePrint.cxx src/db/DatabasePrint.hxx \
|
||||
src/db/DatabaseQueue.cxx src/db/DatabaseQueue.hxx \
|
||||
src/db/DatabasePlaylist.cxx src/db/DatabasePlaylist.hxx \
|
||||
src/db/DatabaseError.cxx src/db/DatabaseError.hxx \
|
||||
src/db/DatabaseLock.cxx src/db/DatabaseLock.hxx \
|
||||
src/db/DatabaseSave.cxx src/db/DatabaseSave.hxx \
|
||||
src/db/DatabasePlugin.hxx \
|
||||
src/db/DatabaseListener.hxx \
|
||||
src/db/Visitor.hxx \
|
||||
src/db/Selection.cxx src/db/Selection.hxx
|
||||
endif
|
||||
|
||||
UPNP_SOURCES = \
|
||||
src/lib/upnp/Init.cxx src/lib/upnp/Init.hxx \
|
||||
src/lib/upnp/ClientInit.cxx src/lib/upnp/ClientInit.hxx \
|
||||
@ -451,6 +454,10 @@ endif
|
||||
|
||||
# database plugins
|
||||
|
||||
if ENABLE_DATABASE
|
||||
|
||||
noinst_LIBRARIES += libdb_plugins.a
|
||||
|
||||
libdb_plugins_a_SOURCES = \
|
||||
src/db/Registry.cxx src/db/Registry.hxx \
|
||||
src/db/Helpers.cxx src/db/Helpers.hxx \
|
||||
@ -479,6 +486,8 @@ DB_LIBS += \
|
||||
$(UPNP_LIBS)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# archive plugins
|
||||
|
||||
if ENABLE_ARCHIVE
|
||||
@ -1203,9 +1212,12 @@ C_TESTS = \
|
||||
test/test_mixramp \
|
||||
test/test_icy_parser \
|
||||
test/test_pcm \
|
||||
test/test_translate_song \
|
||||
test/test_queue_priority
|
||||
|
||||
if ENABLE_DATABASE
|
||||
C_TESTS += test/test_translate_song
|
||||
endif
|
||||
|
||||
if ENABLE_ARCHIVE
|
||||
C_TESTS += test/test_archive
|
||||
endif
|
||||
@ -1216,7 +1228,6 @@ noinst_PROGRAMS = \
|
||||
$(C_TESTS) \
|
||||
test/read_conf \
|
||||
test/run_resolver \
|
||||
test/DumpDatabase \
|
||||
test/run_input \
|
||||
test/dump_text_file \
|
||||
test/dump_playlist \
|
||||
@ -1228,6 +1239,10 @@ noinst_PROGRAMS = \
|
||||
test/run_normalize \
|
||||
test/software_volume
|
||||
|
||||
if ENABLE_DATABASE
|
||||
noinst_PROGRAMS += test/DumpDatabase
|
||||
endif
|
||||
|
||||
if ENABLE_NEIGHBOR_PLUGINS
|
||||
noinst_PROGRAMS += test/run_neighbor_explorer
|
||||
endif
|
||||
@ -1267,6 +1282,8 @@ test_run_resolver_SOURCES = \
|
||||
src/Log.cxx src/LogBackend.cxx \
|
||||
test/run_resolver.cxx
|
||||
|
||||
if ENABLE_DATABASE
|
||||
|
||||
test_DumpDatabase_LDADD = \
|
||||
$(DB_LIBS) \
|
||||
$(TAG_LIBS) \
|
||||
@ -1294,6 +1311,8 @@ if HAVE_LIBUPNP
|
||||
test_DumpDatabase_SOURCES += src/lib/expat/ExpatParser.cxx
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
test_run_input_LDADD = \
|
||||
$(INPUT_LIBS) \
|
||||
$(ARCHIVE_LIBS) \
|
||||
@ -1709,6 +1728,8 @@ test_test_archive_LDADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(CPPUNIT_LIBS)
|
||||
|
||||
if ENABLE_DATABASE
|
||||
|
||||
test_test_translate_song_SOURCES = \
|
||||
src/playlist/PlaylistSong.cxx \
|
||||
src/DetachedSong.cxx \
|
||||
@ -1724,6 +1745,8 @@ test_test_translate_song_LDADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(CPPUNIT_LIBS)
|
||||
|
||||
endif
|
||||
|
||||
test_test_queue_priority_SOURCES = \
|
||||
src/queue/Queue.cxx \
|
||||
src/DetachedSong.cxx \
|
||||
|
18
configure.ac
18
configure.ac
@ -239,10 +239,22 @@ dnl ---------------------------------------------------------------------------
|
||||
dnl Allow tools to be specifically built
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
AC_ARG_ENABLE(database,
|
||||
AS_HELP_STRING([--enable-database],
|
||||
[enable support for the music database]),,
|
||||
enable_database=yes)
|
||||
AM_CONDITIONAL(ENABLE_DATABASE, test x$enable_database = xyes)
|
||||
if test x$enable_database = xyes; then
|
||||
database_auto=auto
|
||||
AC_DEFINE(ENABLE_DATABASE, 1, [Define to enable the music database])
|
||||
else
|
||||
database_auto=no
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(libmpdclient,
|
||||
AS_HELP_STRING([--enable-libmpdclient],
|
||||
[enable support for the MPD client]),,
|
||||
enable_libmpdclient=auto)
|
||||
enable_libmpdclient=$database_auto)
|
||||
|
||||
AC_ARG_ENABLE(expat,
|
||||
AS_HELP_STRING([--enable-expat],
|
||||
@ -252,7 +264,7 @@ AC_ARG_ENABLE(expat,
|
||||
AC_ARG_ENABLE(upnp,
|
||||
AS_HELP_STRING([--enable-upnp],
|
||||
[enable UPnP client support (default: auto)]),,
|
||||
enable_upnp=auto)
|
||||
enable_upnp=$database_auto)
|
||||
|
||||
AC_ARG_ENABLE(adplug,
|
||||
AS_HELP_STRING([--enable-adplug],
|
||||
@ -487,7 +499,7 @@ AC_ARG_ENABLE(solaris_output,
|
||||
AC_ARG_ENABLE(sqlite,
|
||||
AS_HELP_STRING([--enable-sqlite],
|
||||
[enable support for the SQLite database]),,
|
||||
[enable_sqlite=auto])
|
||||
[enable_sqlite=$database_auto])
|
||||
|
||||
AC_ARG_ENABLE(systemd-daemon,
|
||||
AS_HELP_STRING([--enable-systemd-daemon],
|
||||
|
@ -23,8 +23,6 @@
|
||||
#include "LogInit.hxx"
|
||||
#include "Log.hxx"
|
||||
#include "config/ConfigGlobal.hxx"
|
||||
#include "db/Registry.hxx"
|
||||
#include "db/DatabasePlugin.hxx"
|
||||
#include "decoder/DecoderList.hxx"
|
||||
#include "decoder/DecoderPlugin.hxx"
|
||||
#include "output/Registry.hxx"
|
||||
@ -42,6 +40,11 @@
|
||||
#include "util/OptionDef.hxx"
|
||||
#include "util/OptionParser.hxx"
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
#include "db/Registry.hxx"
|
||||
#include "db/DatabasePlugin.hxx"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
#include "neighbor/Registry.hxx"
|
||||
#include "neighbor/NeighborPlugin.hxx"
|
||||
@ -102,12 +105,15 @@ static void version(void)
|
||||
"Copyright (C) 2003-2007 Warren Dukes <warren.dukes@gmail.com>\n"
|
||||
"Copyright (C) 2008-2014 Max Kellermann <max@duempel.org>\n"
|
||||
"This is free software; see the source for copying conditions. There is NO\n"
|
||||
"warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
|
||||
"\n"
|
||||
"warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
puts("\n"
|
||||
"Database plugins:");
|
||||
|
||||
for (auto i = database_plugins; *i != nullptr; ++i)
|
||||
printf(" %s", (*i)->name);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
puts("\n\n"
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "Idle.hxx"
|
||||
#include "Stats.hxx"
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
void
|
||||
Instance::DeleteSong(const char *uri)
|
||||
{
|
||||
@ -37,6 +39,8 @@ Instance::DatabaseModified()
|
||||
idle_add(IDLE_DATABASE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
Instance::TagModified()
|
||||
{
|
||||
@ -49,12 +53,16 @@ Instance::SyncWithPlayer()
|
||||
partition->SyncWithPlayer();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
void
|
||||
Instance::OnDatabaseModified()
|
||||
{
|
||||
DatabaseModified();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
|
||||
void
|
||||
|
@ -21,7 +21,6 @@
|
||||
#define MPD_INSTANCE_HXX
|
||||
|
||||
#include "check.h"
|
||||
#include "db/DatabaseListener.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
@ -29,26 +28,42 @@
|
||||
class NeighborGlue;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
#include "db/DatabaseListener.hxx"
|
||||
class UpdateService;
|
||||
#endif
|
||||
|
||||
class ClientList;
|
||||
struct Partition;
|
||||
|
||||
struct Instance final
|
||||
: public DatabaseListener
|
||||
#if defined(ENABLE_DATABASE) || defined(ENABLE_NEIGHBOR_PLUGINS)
|
||||
:
|
||||
#endif
|
||||
#ifdef ENABLE_DATABASE
|
||||
public DatabaseListener
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
, public NeighborListener
|
||||
,
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
public NeighborListener
|
||||
#endif
|
||||
{
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
NeighborGlue *neighbors;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
UpdateService *update;
|
||||
#endif
|
||||
|
||||
ClientList *client_list;
|
||||
|
||||
Partition *partition;
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
void DeleteSong(const char *uri);
|
||||
|
||||
/**
|
||||
@ -57,6 +72,8 @@ struct Instance final
|
||||
*/
|
||||
void DatabaseModified();
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A tag in the play queue has been modified by the player
|
||||
* thread. Propagate the change to all subsystems.
|
||||
@ -69,7 +86,9 @@ struct Instance final
|
||||
void SyncWithPlayer();
|
||||
|
||||
private:
|
||||
#ifdef ENABLE_DATABASE
|
||||
virtual void OnDatabaseModified();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
/* virtual methods from class NeighborListener */
|
||||
|
23
src/Main.cxx
23
src/Main.cxx
@ -23,13 +23,10 @@
|
||||
#include "CommandLine.hxx"
|
||||
#include "PlaylistFile.hxx"
|
||||
#include "PlaylistGlobal.hxx"
|
||||
#include "db/update/Service.hxx"
|
||||
#include "MusicChunk.hxx"
|
||||
#include "StateFile.hxx"
|
||||
#include "PlayerThread.hxx"
|
||||
#include "Mapper.hxx"
|
||||
#include "db/DatabaseGlue.hxx"
|
||||
#include "db/DatabaseSimple.hxx"
|
||||
#include "Permission.hxx"
|
||||
#include "Listen.hxx"
|
||||
#include "client/Client.hxx"
|
||||
@ -67,6 +64,12 @@
|
||||
#include "config/ConfigOption.hxx"
|
||||
#include "Stats.hxx"
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
#include "db/update/Service.hxx"
|
||||
#include "db/DatabaseGlue.hxx"
|
||||
#include "db/DatabaseSimple.hxx"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
#include "neighbor/Glue.hxx"
|
||||
#endif
|
||||
@ -150,6 +153,8 @@ glue_mapper_init(Error &error)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
/**
|
||||
* Returns the database. If this function returns false, this has not
|
||||
* succeeded, and the caller should create the database after the
|
||||
@ -202,6 +207,8 @@ glue_db_init_and_load(void)
|
||||
return !db_is_simple() || db_exists();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Configure and initialize the sticker subsystem.
|
||||
*/
|
||||
@ -449,11 +456,13 @@ int mpd_main(int argc, char *argv[])
|
||||
|
||||
decoder_plugin_init_all();
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
const bool create_db = !glue_db_init_and_load();
|
||||
|
||||
instance->update = db_is_simple()
|
||||
? new UpdateService(*main_loop)
|
||||
: nullptr;
|
||||
#endif
|
||||
|
||||
glue_sticker_init();
|
||||
|
||||
@ -490,6 +499,7 @@ int mpd_main(int argc, char *argv[])
|
||||
|
||||
player_create(instance->partition->pc);
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
if (create_db) {
|
||||
/* the database failed to load: recreate the
|
||||
database */
|
||||
@ -497,6 +507,7 @@ int mpd_main(int argc, char *argv[])
|
||||
if (job == 0)
|
||||
FatalError("directory update failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!glue_state_file_init(error)) {
|
||||
LogError(error);
|
||||
@ -562,6 +573,7 @@ int mpd_main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
delete instance->update;
|
||||
|
||||
const clock_t start = clock();
|
||||
@ -569,6 +581,7 @@ int mpd_main(int argc, char *argv[])
|
||||
FormatDebug(main_domain,
|
||||
"db_finish took %f seconds",
|
||||
((float)(clock()-start))/CLOCKS_PER_SEC);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SQLITE
|
||||
sticker_global_finish();
|
||||
@ -578,7 +591,11 @@ int mpd_main(int argc, char *argv[])
|
||||
|
||||
playlist_list_global_finish();
|
||||
input_stream_global_finish();
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
mapper_finish();
|
||||
#endif
|
||||
|
||||
delete instance->partition;
|
||||
command_finish();
|
||||
decoder_plugin_deinit_all();
|
||||
|
@ -42,6 +42,8 @@
|
||||
|
||||
static constexpr Domain mapper_domain("mapper");
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
/**
|
||||
* The absolute path of the music directory encoded in UTF-8.
|
||||
*/
|
||||
@ -54,6 +56,8 @@ static size_t music_dir_utf8_length;
|
||||
*/
|
||||
static AllocatedPath music_dir_fs = AllocatedPath::Null();
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The absolute path of the playlist directory encoded in the
|
||||
* filesystem character set.
|
||||
@ -91,6 +95,8 @@ check_directory(const char *path_utf8, const AllocatedPath &path_fs)
|
||||
"No permission to read directory: %s", path_utf8);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
static void
|
||||
mapper_set_music_dir(AllocatedPath &&path)
|
||||
{
|
||||
@ -105,6 +111,8 @@ mapper_set_music_dir(AllocatedPath &&path)
|
||||
check_directory(music_dir_utf8.c_str(), music_dir_fs);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
mapper_set_playlist_dir(AllocatedPath &&path)
|
||||
{
|
||||
@ -119,8 +127,12 @@ mapper_set_playlist_dir(AllocatedPath &&path)
|
||||
void
|
||||
mapper_init(AllocatedPath &&_music_dir, AllocatedPath &&_playlist_dir)
|
||||
{
|
||||
#ifdef ENABLE_DATABASE
|
||||
if (!_music_dir.IsNull())
|
||||
mapper_set_music_dir(std::move(_music_dir));
|
||||
#else
|
||||
(void)_music_dir;
|
||||
#endif
|
||||
|
||||
if (!_playlist_dir.IsNull())
|
||||
mapper_set_playlist_dir(std::move(_playlist_dir));
|
||||
@ -130,6 +142,8 @@ void mapper_finish(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
const char *
|
||||
mapper_get_music_directory_utf8(void)
|
||||
{
|
||||
@ -144,17 +158,25 @@ mapper_get_music_directory_fs(void)
|
||||
return music_dir_fs;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const char *
|
||||
map_to_relative_path(const char *path_utf8)
|
||||
{
|
||||
#ifdef ENABLE_DATABASE
|
||||
return !music_dir_utf8.empty() &&
|
||||
memcmp(path_utf8, music_dir_utf8.c_str(),
|
||||
music_dir_utf8_length) == 0 &&
|
||||
PathTraitsUTF8::IsSeparator(path_utf8[music_dir_utf8_length])
|
||||
? path_utf8 + music_dir_utf8_length + 1
|
||||
: path_utf8;
|
||||
#else
|
||||
return path_utf8;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
AllocatedPath
|
||||
map_uri_fs(const char *uri)
|
||||
{
|
||||
@ -240,15 +262,24 @@ map_song_fs(const Song &song)
|
||||
: map_directory_child_fs(*song.parent, song.uri);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
AllocatedPath
|
||||
map_song_fs(const DetachedSong &song)
|
||||
{
|
||||
if (song.IsAbsoluteFile())
|
||||
return AllocatedPath::FromUTF8(song.GetRealURI());
|
||||
else
|
||||
else {
|
||||
#ifdef ENABLE_DATABASE
|
||||
return map_uri_fs(song.GetURI());
|
||||
#else
|
||||
return AllocatedPath::Null();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
std::string
|
||||
map_fs_to_utf8(const char *path_fs)
|
||||
{
|
||||
@ -261,6 +292,8 @@ map_fs_to_utf8(const char *path_fs)
|
||||
return PathToUTF8(path_fs);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const AllocatedPath &
|
||||
map_spl_path(void)
|
||||
{
|
||||
|
@ -41,6 +41,8 @@ mapper_init(AllocatedPath &&music_dir, AllocatedPath &&playlist_dir);
|
||||
|
||||
void mapper_finish(void);
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
/**
|
||||
* Return the absolute path of the music directory encoded in UTF-8 or
|
||||
* nullptr if no music directory was configured.
|
||||
@ -67,6 +69,8 @@ mapper_has_music_directory(void)
|
||||
return mapper_get_music_directory_utf8() != nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* If the specified absolute path points inside the music directory,
|
||||
* this function converts it to a relative path. If not, it returns
|
||||
@ -76,6 +80,8 @@ gcc_pure
|
||||
const char *
|
||||
map_to_relative_path(const char *path_utf8);
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
/**
|
||||
* Determines the absolute file system path of a relative URI. This
|
||||
* is basically done by converting the URI to the file system charset
|
||||
@ -126,10 +132,14 @@ gcc_pure
|
||||
AllocatedPath
|
||||
map_song_fs(const Song &song);
|
||||
|
||||
#endif
|
||||
|
||||
gcc_pure
|
||||
AllocatedPath
|
||||
map_song_fs(const DetachedSong &song);
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
/**
|
||||
* Maps a file system path (relative to the music directory or
|
||||
* absolute) to a relative path in UTF-8 encoding.
|
||||
@ -142,6 +152,8 @@ gcc_pure
|
||||
std::string
|
||||
map_fs_to_utf8(const char *path_fs);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the playlist directory.
|
||||
*/
|
||||
|
@ -79,10 +79,14 @@ struct Partition {
|
||||
return playlist.DeleteRange(pc, start, end);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
void DeleteSong(const char *uri) {
|
||||
playlist.DeleteSong(pc, uri);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Shuffle(unsigned start, unsigned end) {
|
||||
playlist.Shuffle(pc, start, end);
|
||||
}
|
||||
|
@ -112,8 +112,10 @@ playlist::AppendURI(PlayerControl &pc,
|
||||
if (uri_has_scheme(uri)) {
|
||||
song = new DetachedSong(uri);
|
||||
} else {
|
||||
#ifdef ENABLE_DATABASE
|
||||
song = DatabaseDetachSong(uri, IgnoreError());
|
||||
if (song == nullptr)
|
||||
#endif
|
||||
return PlaylistResult::NO_SUCH_SONG;
|
||||
}
|
||||
|
||||
|
@ -243,6 +243,7 @@ LoadPlaylistFile(const char *utf8path, Error &error)
|
||||
std::string uri_utf8;
|
||||
|
||||
if (!uri_has_scheme(s)) {
|
||||
#ifdef ENABLE_DATABASE
|
||||
uri_utf8 = map_fs_to_utf8(s);
|
||||
if (uri_utf8.empty()) {
|
||||
if (PathTraitsFS::IsAbsolute(s)) {
|
||||
@ -254,6 +255,9 @@ LoadPlaylistFile(const char *utf8path, Error &error)
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
continue;
|
||||
#endif
|
||||
} else {
|
||||
uri_utf8 = PathToUTF8(s);
|
||||
if (uri_utf8.empty())
|
||||
@ -404,6 +408,7 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
|
||||
return spl_append_song(utf8file, DetachedSong(url),
|
||||
error);
|
||||
} else {
|
||||
#ifdef ENABLE_DATABASE
|
||||
DetachedSong *song = DatabaseDetachSong(url, error);
|
||||
if (song == nullptr)
|
||||
return false;
|
||||
@ -411,6 +416,9 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
|
||||
bool success = spl_append_song(utf8file, *song, error);
|
||||
delete song;
|
||||
return success;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,8 @@ playlist_print_changes_position(Client &client,
|
||||
queue_print_changes_position(client, playlist.queue, version);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
static bool
|
||||
PrintSongDetails(Client &client, const char *uri_utf8)
|
||||
{
|
||||
@ -126,16 +128,24 @@ PrintSongDetails(Client &client, const char *uri_utf8)
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool
|
||||
spl_print(Client &client, const char *name_utf8, bool detail,
|
||||
Error &error)
|
||||
{
|
||||
#ifndef ENABLE_DATABASE
|
||||
(void)detail;
|
||||
#endif
|
||||
|
||||
PlaylistFileContents contents = LoadPlaylistFile(name_utf8, error);
|
||||
if (contents.empty() && error.IsDefined())
|
||||
return false;
|
||||
|
||||
for (const auto &uri_utf8 : contents) {
|
||||
#ifdef ENABLE_DATABASE
|
||||
if (!detail || !PrintSongDetails(client, uri_utf8.c_str()))
|
||||
#endif
|
||||
client_printf(client, SONG_FILE "%s\n",
|
||||
uri_utf8.c_str());
|
||||
}
|
||||
|
@ -55,10 +55,14 @@ playlist_print_song(FILE *file, const DetachedSong &song)
|
||||
void
|
||||
playlist_print_uri(FILE *file, const char *uri)
|
||||
{
|
||||
auto path = playlist_saveAbsolutePaths && !uri_has_scheme(uri) &&
|
||||
auto path =
|
||||
#ifdef ENABLE_DATABASE
|
||||
playlist_saveAbsolutePaths && !uri_has_scheme(uri) &&
|
||||
!PathTraitsUTF8::IsAbsolute(uri)
|
||||
? map_uri_fs(uri)
|
||||
: AllocatedPath::FromUTF8(uri);
|
||||
:
|
||||
#endif
|
||||
AllocatedPath::FromUTF8(uri);
|
||||
|
||||
if (!path.IsNull())
|
||||
fprintf(file, "%s\n", path.c_str());
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
Song *
|
||||
Song::LoadFile(const char *path_utf8, Directory &parent)
|
||||
{
|
||||
@ -64,6 +66,8 @@ Song::LoadFile(const char *path_utf8, Directory &parent)
|
||||
return song;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Attempts to load APE or ID3 tags from the specified file.
|
||||
*/
|
||||
@ -75,6 +79,8 @@ tag_scan_fallback(Path path,
|
||||
tag_id3_scan(path, handler, handler_ctx);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
bool
|
||||
Song::UpdateFile()
|
||||
{
|
||||
@ -125,6 +131,8 @@ Song::UpdateFileInArchive()
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool
|
||||
DetachedSong::Update()
|
||||
{
|
||||
|
@ -37,6 +37,8 @@
|
||||
static unsigned start_time;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
static DatabaseStats stats;
|
||||
|
||||
enum class StatsValidity : uint8_t {
|
||||
@ -45,6 +47,8 @@ enum class StatsValidity : uint8_t {
|
||||
|
||||
static StatsValidity stats_validity = StatsValidity::INVALID;
|
||||
|
||||
#endif
|
||||
|
||||
void stats_global_init(void)
|
||||
{
|
||||
#ifndef WIN32
|
||||
@ -52,6 +56,8 @@ void stats_global_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
void
|
||||
stats_invalidate()
|
||||
{
|
||||
@ -120,6 +126,8 @@ db_stats_print(Client &client)
|
||||
(unsigned long)update_stamp);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
stats_print(Client &client)
|
||||
{
|
||||
@ -133,6 +141,8 @@ stats_print(Client &client)
|
||||
#endif
|
||||
(unsigned long)(client.player_control.GetTotalPlayTime() + 0.5));
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
if (GetDatabase() != nullptr)
|
||||
db_stats_print(client);
|
||||
#endif
|
||||
}
|
||||
|
@ -85,7 +85,9 @@ static const struct command commands[] = {
|
||||
{ "commands", PERMISSION_NONE, 0, 0, handle_commands },
|
||||
{ "config", PERMISSION_ADMIN, 0, 0, handle_config },
|
||||
{ "consume", PERMISSION_CONTROL, 1, 1, handle_consume },
|
||||
#ifdef ENABLE_DATABASE
|
||||
{ "count", PERMISSION_READ, 2, -1, handle_count },
|
||||
#endif
|
||||
{ "crossfade", PERMISSION_CONTROL, 1, 1, handle_crossfade },
|
||||
{ "currentsong", PERMISSION_READ, 0, 0, handle_currentsong },
|
||||
{ "decoders", PERMISSION_READ, 0, 0, handle_decoders },
|
||||
@ -93,13 +95,17 @@ static const struct command commands[] = {
|
||||
{ "deleteid", PERMISSION_CONTROL, 1, 1, handle_deleteid },
|
||||
{ "disableoutput", PERMISSION_ADMIN, 1, 1, handle_disableoutput },
|
||||
{ "enableoutput", PERMISSION_ADMIN, 1, 1, handle_enableoutput },
|
||||
#ifdef ENABLE_DATABASE
|
||||
{ "find", PERMISSION_READ, 2, -1, handle_find },
|
||||
{ "findadd", PERMISSION_READ, 2, -1, handle_findadd},
|
||||
#endif
|
||||
{ "idle", PERMISSION_READ, 0, -1, handle_idle },
|
||||
{ "kill", PERMISSION_ADMIN, -1, -1, handle_kill },
|
||||
#ifdef ENABLE_DATABASE
|
||||
{ "list", PERMISSION_READ, 1, -1, handle_list },
|
||||
{ "listall", PERMISSION_READ, 0, 1, handle_listall },
|
||||
{ "listallinfo", PERMISSION_READ, 0, 1, handle_listallinfo },
|
||||
#endif
|
||||
#ifdef ENABLE_NEIGHBOR_PLUGINS
|
||||
{ "listneighbors", PERMISSION_READ, 0, 0, handle_listneighbors },
|
||||
#endif
|
||||
@ -146,9 +152,11 @@ static const struct command commands[] = {
|
||||
{ "rescan", PERMISSION_CONTROL, 0, 1, handle_rescan },
|
||||
{ "rm", PERMISSION_CONTROL, 1, 1, handle_rm },
|
||||
{ "save", PERMISSION_CONTROL, 1, 1, handle_save },
|
||||
#ifdef ENABLE_DATABASE
|
||||
{ "search", PERMISSION_READ, 2, -1, handle_search },
|
||||
{ "searchadd", PERMISSION_ADD, 2, -1, handle_searchadd },
|
||||
{ "searchaddpl", PERMISSION_CONTROL, 3, -1, handle_searchaddpl },
|
||||
#endif
|
||||
{ "seek", PERMISSION_CONTROL, 2, 2, handle_seek },
|
||||
{ "seekcur", PERMISSION_CONTROL, 1, 1, handle_seekcur },
|
||||
{ "seekid", PERMISSION_CONTROL, 2, 2, handle_seekid },
|
||||
|
@ -101,6 +101,7 @@ print_error(Client &client, const Error &error)
|
||||
command_error(client, (ack)error.GetCode(),
|
||||
"%s", error.GetMessage());
|
||||
return CommandResult::ERROR;
|
||||
#ifdef ENABLE_DATABASE
|
||||
} else if (error.IsDomain(db_domain)) {
|
||||
switch ((enum db_error)error.GetCode()) {
|
||||
case DB_DISABLED:
|
||||
@ -112,6 +113,7 @@ print_error(Client &client, const Error &error)
|
||||
command_error(client, ACK_ERROR_NO_EXIST, "Not found");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
#endif
|
||||
} else if (error.IsDomain(errno_domain)) {
|
||||
command_error(client, ACK_ERROR_SYSTEM, "%s",
|
||||
strerror(error.GetCode()));
|
||||
|
@ -127,12 +127,17 @@ handle_read_comments(Client &client, gcc_unused int argc, char *argv[])
|
||||
} else if (uri_has_scheme(uri)) {
|
||||
return read_stream_comments(client, uri);
|
||||
} else if (*uri != '/') {
|
||||
#ifdef ENABLE_DATABASE
|
||||
path_fs = map_uri_fs(uri);
|
||||
if (path_fs.IsNull()) {
|
||||
command_error(client, ACK_ERROR_NO_EXIST,
|
||||
"No such file");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
#else
|
||||
command_error(client, ACK_ERROR_NO_EXIST, "No database");
|
||||
return CommandResult::ERROR;
|
||||
#endif
|
||||
} else {
|
||||
command_error(client, ACK_ERROR_NO_EXIST, "No such file");
|
||||
return CommandResult::ERROR;
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "OtherCommands.hxx"
|
||||
#include "DatabaseCommands.hxx"
|
||||
#include "db/update/Service.hxx"
|
||||
#include "CommandError.hxx"
|
||||
#include "db/Uri.hxx"
|
||||
#include "DetachedSong.hxx"
|
||||
@ -49,6 +47,11 @@
|
||||
#include "Instance.hxx"
|
||||
#include "Idle.hxx"
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
#include "DatabaseCommands.hxx"
|
||||
#include "db/update/Service.hxx"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -170,14 +173,21 @@ handle_lsinfo(Client &client, int argc, char *argv[])
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
CommandResult result = handle_lsinfo2(client, argc, argv);
|
||||
if (result != CommandResult::OK)
|
||||
return result;
|
||||
#endif
|
||||
|
||||
if (isRootDirectory(uri)) {
|
||||
Error error;
|
||||
const auto &list = ListPlaylistFiles(error);
|
||||
print_spl_list(client, list);
|
||||
} else {
|
||||
#ifndef ENABLE_DATABASE
|
||||
command_error(client, ACK_ERROR_NO_EXIST, "No database");
|
||||
return CommandResult::ERROR;
|
||||
#endif
|
||||
}
|
||||
|
||||
return CommandResult::OK;
|
||||
@ -186,6 +196,7 @@ handle_lsinfo(Client &client, int argc, char *argv[])
|
||||
static CommandResult
|
||||
handle_update(Client &client, int argc, char *argv[], bool discard)
|
||||
{
|
||||
#ifdef ENABLE_DATABASE
|
||||
const char *path = "";
|
||||
|
||||
assert(argc <= 2);
|
||||
@ -217,6 +228,15 @@ handle_update(Client &client, int argc, char *argv[], bool discard)
|
||||
"already updating");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
#else
|
||||
(void)client;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
(void)discard;
|
||||
|
||||
command_error(client, ACK_ERROR_NO_EXIST, "No database");
|
||||
return CommandResult::ERROR;
|
||||
#endif
|
||||
}
|
||||
|
||||
CommandResult
|
||||
@ -329,9 +349,11 @@ handle_config(Client &client,
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
const char *path = mapper_get_music_directory_utf8();
|
||||
if (path != nullptr)
|
||||
client_printf(client, "music_directory: %s\n", path);
|
||||
#endif
|
||||
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "CommandError.hxx"
|
||||
#include "Playlist.hxx"
|
||||
#include "PlaylistPrint.hxx"
|
||||
#include "db/update/Service.hxx"
|
||||
#include "client/Client.hxx"
|
||||
#include "mixer/Volume.hxx"
|
||||
#include "Partition.hxx"
|
||||
@ -32,6 +31,10 @@
|
||||
#include "AudioFormat.hxx"
|
||||
#include "ReplayGainConfig.hxx"
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
#include "db/update/Service.hxx"
|
||||
#endif
|
||||
|
||||
#define COMMAND_STATUS_STATE "state"
|
||||
#define COMMAND_STATUS_REPEAT "repeat"
|
||||
#define COMMAND_STATUS_SINGLE "single"
|
||||
@ -187,6 +190,7 @@ handle_status(Client &client,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
const UpdateService *update_service = client.partition.instance.update;
|
||||
unsigned updateJobId = update_service != nullptr
|
||||
? update_service->GetId()
|
||||
@ -196,6 +200,7 @@ handle_status(Client &client,
|
||||
COMMAND_STATUS_UPDATING_DB ": %i\n",
|
||||
updateJobId);
|
||||
}
|
||||
#endif
|
||||
|
||||
Error error = client.player_control.LockGetError();
|
||||
if (error.IsDefined())
|
||||
|
@ -193,9 +193,14 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[])
|
||||
}
|
||||
|
||||
success = spl_append_uri(uri, playlist, error);
|
||||
} else
|
||||
} else {
|
||||
#ifdef ENABLE_DATABASE
|
||||
success = search_add_to_playlist(uri, playlist, nullptr,
|
||||
error);
|
||||
#else
|
||||
success = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!success && !error.IsDefined()) {
|
||||
command_error(client, ACK_ERROR_NO_EXIST,
|
||||
|
@ -74,11 +74,16 @@ handle_add(Client &client, gcc_unused int argc, char *argv[])
|
||||
return print_playlist_result(client, result);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
const DatabaseSelection selection(uri, true);
|
||||
Error error;
|
||||
return AddFromDatabase(client.partition, selection, error)
|
||||
? CommandResult::OK
|
||||
: print_error(client, error);
|
||||
#else
|
||||
command_error(client, ACK_ERROR_NO_EXIST, "No database");
|
||||
return CommandResult::ERROR;
|
||||
#endif
|
||||
}
|
||||
|
||||
CommandResult
|
||||
|
@ -64,6 +64,8 @@ playlist_open_in_playlist_dir(const char *uri, Mutex &mutex, Cond &cond,
|
||||
return playlist_open_path(path_fs.c_str(), mutex, cond, is_r);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
/**
|
||||
* Load a playlist from the configured music directory.
|
||||
*/
|
||||
@ -80,6 +82,8 @@ playlist_open_in_music_dir(const char *uri, Mutex &mutex, Cond &cond,
|
||||
return playlist_open_path(path.c_str(), mutex, cond, is_r);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SongEnumerator *
|
||||
playlist_mapper_open(const char *uri, Mutex &mutex, Cond &cond,
|
||||
InputStream **is_r)
|
||||
@ -91,12 +95,14 @@ playlist_mapper_open(const char *uri, Mutex &mutex, Cond &cond,
|
||||
return playlist;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
if (uri_safe_local(uri)) {
|
||||
auto playlist = playlist_open_in_music_dir(uri, mutex, cond,
|
||||
is_r);
|
||||
if (playlist != nullptr)
|
||||
return playlist;
|
||||
}
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ playlist_check_load_song(DetachedSong &song)
|
||||
apply_song_metadata(song, tmp);
|
||||
return true;
|
||||
} else {
|
||||
#ifdef ENABLE_DATABASE
|
||||
DetachedSong *tmp = DatabaseDetachSong(uri, IgnoreError());
|
||||
if (tmp == nullptr)
|
||||
return false;
|
||||
@ -86,6 +87,9 @@ playlist_check_load_song(DetachedSong &song)
|
||||
apply_song_metadata(song, *tmp);
|
||||
delete tmp;
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,8 +110,10 @@ queue_load_song(TextFile &file, const char *line, Queue &queue)
|
||||
if (uri_has_scheme(uri)) {
|
||||
song = new DetachedSong(uri);
|
||||
} else {
|
||||
#ifdef ENABLE_DATABASE
|
||||
song = DatabaseDetachSong(uri, IgnoreError());
|
||||
if (song == nullptr)
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user