test/{visit_archive,dump_text_file}: add basic config file support (not wired yet)

This commit is contained in:
Max Kellermann 2022-02-14 16:36:55 +01:00
parent ab5b6f83fd
commit b1096a9935
3 changed files with 17 additions and 14 deletions

View File

@ -18,11 +18,11 @@
*/ */
#include "config.h" #include "config.h"
#include "ConfigGlue.hxx"
#include "event/Thread.hxx" #include "event/Thread.hxx"
#include "input/Init.hxx" #include "input/Init.hxx"
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include "input/TextInputStream.hxx" #include "input/TextInputStream.hxx"
#include "config/Data.hxx"
#include "util/PrintException.hxx" #include "util/PrintException.hxx"
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
@ -36,17 +36,19 @@
#include <stdlib.h> #include <stdlib.h>
class GlobalInit { class GlobalInit {
const ConfigData config;
EventThread io_thread; EventThread io_thread;
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
const ScopeArchivePluginsInit archive_plugins_init; const ScopeArchivePluginsInit archive_plugins_init;
#endif #endif
const ScopeInputPluginsInit input_plugins_init; const ScopeInputPluginsInit input_plugins_init{config, io_thread.GetEventLoop()};
public: public:
GlobalInit() explicit GlobalInit(Path config_path)
:input_plugins_init(ConfigData(), io_thread.GetEventLoop()) :config(AutoLoadConfigFile(config_path))
{ {
io_thread.Start(); io_thread.Start();
} }
@ -77,13 +79,13 @@ dump_input_stream(InputStreamPtr &&is)
int main(int argc, char **argv) int main(int argc, char **argv)
try { try {
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "Usage: run_input URI\n"); fprintf(stderr, "Usage: dump_text_file URI\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/* initialize MPD */ /* initialize MPD */
const GlobalInit init; const GlobalInit init{nullptr};
/* open the stream and dump it */ /* open the stream and dump it */

View File

@ -140,12 +140,11 @@ class GlobalInit {
const ScopeArchivePluginsInit archive_plugins_init; const ScopeArchivePluginsInit archive_plugins_init;
#endif #endif
const ScopeInputPluginsInit input_plugins_init; const ScopeInputPluginsInit input_plugins_init{config, io_thread.GetEventLoop()};
public: public:
explicit GlobalInit(Path config_path) explicit GlobalInit(Path config_path)
:config(AutoLoadConfigFile(config_path)), :config(AutoLoadConfigFile(config_path))
input_plugins_init(config, io_thread.GetEventLoop())
{ {
io_thread.Start(); io_thread.Start();
} }

View File

@ -19,7 +19,7 @@
#include "config.h" #include "config.h"
#include "tag/Tag.hxx" #include "tag/Tag.hxx"
#include "config/Data.hxx" #include "ConfigGlue.hxx"
#include "event/Thread.hxx" #include "event/Thread.hxx"
#include "input/Init.hxx" #include "input/Init.hxx"
#include "archive/ArchiveList.hxx" #include "archive/ArchiveList.hxx"
@ -36,17 +36,19 @@
#include <stdio.h> #include <stdio.h>
class GlobalInit { class GlobalInit {
const ConfigData config;
EventThread io_thread; EventThread io_thread;
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
const ScopeArchivePluginsInit archive_plugins_init; const ScopeArchivePluginsInit archive_plugins_init;
#endif #endif
const ScopeInputPluginsInit input_plugins_init; const ScopeInputPluginsInit input_plugins_init{config, io_thread.GetEventLoop()};
public: public:
GlobalInit() explicit GlobalInit(Path config_path)
:input_plugins_init(ConfigData(), io_thread.GetEventLoop()) :config(AutoLoadConfigFile(config_path))
{ {
io_thread.Start(); io_thread.Start();
} }
@ -72,7 +74,7 @@ try {
/* initialize MPD */ /* initialize MPD */
const GlobalInit init; const GlobalInit init{nullptr};
/* open the archive and dump it */ /* open the archive and dump it */