Commit 0fe0425d authored by Max Kellermann's avatar Max Kellermann

disable archive API without plugins

When there are no archive plugins, we do not need the archive API at all. Drop all its overhead.
parent 4c13a276
...@@ -217,6 +217,16 @@ if test x$enable_iso = xyes; then ...@@ -217,6 +217,16 @@ if test x$enable_iso = xyes; then
AC_DEFINE(HAVE_ISO, 1, [Define to have iso archive support]) AC_DEFINE(HAVE_ISO, 1, [Define to have iso archive support])
fi fi
dnl archive API
if test x$enable_bz2 = xyes || test x$enable_zip = xyes || test x$enable_iso = xyes; then
enable_archive=yes
AC_DEFINE(ENABLE_ARCHIVE, 1, [The archive API is available])
else
enable_archive=no
fi
AM_CONDITIONAL(ENABLE_ARCHIVE, test x$enable_archive = xyes)
dnl dnl
dnl decoder plugins dnl decoder plugins
......
...@@ -158,10 +158,7 @@ mpd_SOURCES = \ ...@@ -158,10 +158,7 @@ mpd_SOURCES = \
volume.c \ volume.c \
locate.c \ locate.c \
stored_playlist.c \ stored_playlist.c \
timer.c \ timer.c
archive_api.c \
archive_list.c \
input_archive.c
if HAVE_LIBSAMPLERATE if HAVE_LIBSAMPLERATE
mpd_SOURCES += pcm_resample_libsamplerate.c mpd_SOURCES += pcm_resample_libsamplerate.c
...@@ -187,6 +184,14 @@ if HAVE_ISO ...@@ -187,6 +184,14 @@ if HAVE_ISO
mpd_SOURCES += archive/iso_plugin.c mpd_SOURCES += archive/iso_plugin.c
endif endif
if ENABLE_ARCHIVE
mpd_SOURCES += \
archive_api.c \
archive_list.c \
input_archive.c
endif
# decoder plugins # decoder plugins
if HAVE_MAD if HAVE_MAD
......
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
#include "config.h" #include "config.h"
#include "input_file.h" #include "input_file.h"
#ifdef ENABLE_ARCHIVE
#include "input_archive.h" #include "input_archive.h"
#endif
#ifdef HAVE_CURL #ifdef HAVE_CURL
#include "input_curl.h" #include "input_curl.h"
...@@ -31,7 +34,9 @@ ...@@ -31,7 +34,9 @@
static const struct input_plugin *const input_plugins[] = { static const struct input_plugin *const input_plugins[] = {
&input_plugin_file, &input_plugin_file,
#ifdef ENABLE_ARCHIVE
&input_plugin_archive, &input_plugin_archive,
#endif
#ifdef HAVE_CURL #ifdef HAVE_CURL
&input_plugin_curl, &input_plugin_curl,
#endif #endif
......
...@@ -84,6 +84,7 @@ hasMusicSuffix(const char *utf8file, unsigned int next) ...@@ -84,6 +84,7 @@ hasMusicSuffix(const char *utf8file, unsigned int next)
return ret; return ret;
} }
#ifdef ENABLE_ARCHIVE
const struct archive_plugin * const struct archive_plugin *
get_archive_by_suffix(const char *utf8file) get_archive_by_suffix(const char *utf8file)
{ {
...@@ -98,3 +99,4 @@ get_archive_by_suffix(const char *utf8file) ...@@ -98,3 +99,4 @@ get_archive_by_suffix(const char *utf8file)
} }
return ret; return ret;
} }
#endif
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "permission.h" #include "permission.h"
#include "replay_gain.h" #include "replay_gain.h"
#include "decoder_list.h" #include "decoder_list.h"
#include "archive_list.h"
#include "audioOutput.h" #include "audioOutput.h"
#include "input_stream.h" #include "input_stream.h"
#include "state_file.h" #include "state_file.h"
...@@ -52,6 +51,10 @@ ...@@ -52,6 +51,10 @@
#include "main_notify.h" #include "main_notify.h"
#include "os_compat.h" #include "os_compat.h"
#ifdef ENABLE_ARCHIVE
#include "archive_list.h"
#endif
#include <glib.h> #include <glib.h>
#ifdef HAVE_LOCALE #ifdef HAVE_LOCALE
...@@ -147,10 +150,12 @@ static void version(void) ...@@ -147,10 +150,12 @@ static void version(void)
"Supported outputs:\n"); "Supported outputs:\n");
printAllOutputPluginTypes(stdout); printAllOutputPluginTypes(stdout);
#ifdef ENABLE_ARCHIVE
puts("\n" puts("\n"
"Supported archives:\n"); "Supported archives:\n");
archive_plugin_init_all(); archive_plugin_init_all();
archive_plugin_print_all_suffixes(stdout); archive_plugin_print_all_suffixes(stdout);
#endif
} }
static void parseOptions(int argc, char **argv, Options * options) static void parseOptions(int argc, char **argv, Options * options)
...@@ -421,7 +426,9 @@ int main(int argc, char *argv[]) ...@@ -421,7 +426,9 @@ int main(int argc, char *argv[])
mapper_init(); mapper_init();
initPermissions(); initPermissions();
initPlaylist(); initPlaylist();
#ifdef ENABLE_ARCHIVE
archive_plugin_init_all(); archive_plugin_init_all();
#endif
decoder_plugin_init_all(); decoder_plugin_init_all();
update_global_init(); update_global_init();
...@@ -507,7 +514,9 @@ int main(int argc, char *argv[]) ...@@ -507,7 +514,9 @@ int main(int argc, char *argv[])
command_finish(); command_finish();
update_global_finish(); update_global_finish();
decoder_plugin_deinit_all(); decoder_plugin_deinit_all();
#ifdef ENABLE_ARCHIVE
archive_plugin_deinit_all(); archive_plugin_deinit_all();
#endif
music_pipe_free(); music_pipe_free();
cleanUpPidFile(); cleanUpPidFile();
finishConf(); finishConf();
......
...@@ -276,6 +276,7 @@ make_subdir(struct directory *parent, const char *name) ...@@ -276,6 +276,7 @@ make_subdir(struct directory *parent, const char *name)
return directory; return directory;
} }
#ifdef ENABLE_ARCHIVE
static void static void
update_archive_tree(struct directory *directory, char *name) update_archive_tree(struct directory *directory, char *name)
{ {
...@@ -308,6 +309,7 @@ update_archive_tree(struct directory *directory, char *name) ...@@ -308,6 +309,7 @@ update_archive_tree(struct directory *directory, char *name)
} }
} }
} }
#endif
static bool static bool
updateDirectory(struct directory *directory, const struct stat *st); updateDirectory(struct directory *directory, const struct stat *st);
...@@ -316,7 +318,10 @@ static void ...@@ -316,7 +318,10 @@ static void
updateInDirectory(struct directory *directory, updateInDirectory(struct directory *directory,
const char *name, const struct stat *st) const char *name, const struct stat *st)
{ {
#ifdef ENABLE_ARCHIVE
const struct archive_plugin *archive; const struct archive_plugin *archive;
#endif
assert(strchr(name, '/') == NULL); assert(strchr(name, '/') == NULL);
if (S_ISREG(st->st_mode) && hasMusicSuffix(name, 0)) { if (S_ISREG(st->st_mode) && hasMusicSuffix(name, 0)) {
...@@ -351,6 +356,7 @@ updateInDirectory(struct directory *directory, ...@@ -351,6 +356,7 @@ updateInDirectory(struct directory *directory,
ret = updateDirectory(subdir, st); ret = updateDirectory(subdir, st);
if (!ret) if (!ret)
delete_directory(subdir); delete_directory(subdir);
#ifdef ENABLE_ARCHIVE
} else if (S_ISREG(st->st_mode) && (archive = get_archive_by_suffix(name))) { } else if (S_ISREG(st->st_mode) && (archive = get_archive_by_suffix(name))) {
struct archive_file *archfile; struct archive_file *archfile;
char pathname[MPD_PATH_MAX]; char pathname[MPD_PATH_MAX];
...@@ -380,6 +386,7 @@ updateInDirectory(struct directory *directory, ...@@ -380,6 +386,7 @@ updateInDirectory(struct directory *directory,
} else { } else {
g_warning("unable to open archive %s\n", pathname); g_warning("unable to open archive %s\n", pathname);
} }
#endif
} else { } else {
g_debug("update: %s is not a directory, archive or music\n", name); g_debug("update: %s is not a directory, archive or music\n", name);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment