input/Init: use struct ConfigData

This commit is contained in:
Max Kellermann 2018-07-17 21:49:27 +02:00
parent 7b02c0224c
commit 0ff0aca2e2
9 changed files with 20 additions and 18 deletions

View File

@ -570,7 +570,8 @@ try {
} }
client_manager_init(); client_manager_init();
input_stream_global_init(instance->io_thread.GetEventLoop()); input_stream_global_init(GetGlobalConfig(),
instance->io_thread.GetEventLoop());
playlist_list_global_init(); playlist_list_global_init();
#ifdef ENABLE_DAEMON #ifdef ENABLE_DAEMON

View File

@ -21,7 +21,7 @@
#include "Init.hxx" #include "Init.hxx"
#include "Registry.hxx" #include "Registry.hxx"
#include "InputPlugin.hxx" #include "InputPlugin.hxx"
#include "config/Global.hxx" #include "config/Data.hxx"
#include "config/Option.hxx" #include "config/Option.hxx"
#include "config/Block.hxx" #include "config/Block.hxx"
#include "Log.hxx" #include "Log.hxx"
@ -33,7 +33,7 @@
#include <assert.h> #include <assert.h>
void void
input_stream_global_init(EventLoop &event_loop) input_stream_global_init(const ConfigData &config, EventLoop &event_loop)
{ {
const ConfigBlock empty; const ConfigBlock empty;
@ -45,8 +45,8 @@ input_stream_global_init(EventLoop &event_loop)
assert(plugin->open != nullptr); assert(plugin->open != nullptr);
const auto *block = const auto *block =
config_find_block(ConfigBlockOption::INPUT, "plugin", config.FindBlock(ConfigBlockOption::INPUT, "plugin",
plugin->name); plugin->name);
if (block == nullptr) { if (block == nullptr) {
block = &empty; block = &empty;
} else if (!block->GetBlockValue("enabled", true)) } else if (!block->GetBlockValue("enabled", true))

View File

@ -20,13 +20,14 @@
#ifndef MPD_INPUT_INIT_HXX #ifndef MPD_INPUT_INIT_HXX
#define MPD_INPUT_INIT_HXX #define MPD_INPUT_INIT_HXX
struct ConfigData;
class EventLoop; class EventLoop;
/** /**
* Initializes this library and all #InputStream implementations. * Initializes this library and all #InputStream implementations.
*/ */
void void
input_stream_global_init(EventLoop &event_loop); input_stream_global_init(const ConfigData &config, EventLoop &event_loop);
/** /**
* Deinitializes this library and all #InputStream implementations. * Deinitializes this library and all #InputStream implementations.

View File

@ -67,7 +67,7 @@ try {
EventThread io_thread; EventThread io_thread;
io_thread.Start(); io_thread.Start();
input_stream_global_init(io_thread.GetEventLoop()); input_stream_global_init(GetGlobalConfig(), io_thread.GetEventLoop());
playlist_list_global_init(); playlist_list_global_init();
decoder_plugin_init_all(GetGlobalConfig()); decoder_plugin_init_all(GetGlobalConfig());

View File

@ -22,7 +22,7 @@
#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/Global.hxx" #include "config/Data.hxx"
#include "util/PrintException.hxx" #include "util/PrintException.hxx"
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
@ -41,11 +41,11 @@ class GlobalInit {
public: public:
GlobalInit() { GlobalInit() {
io_thread.Start(); io_thread.Start();
config_global_init();
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
archive_plugin_init_all(); archive_plugin_init_all();
#endif #endif
input_stream_global_init(io_thread.GetEventLoop()); input_stream_global_init(ConfigData(),
io_thread.GetEventLoop());
} }
~GlobalInit() { ~GlobalInit() {
@ -53,7 +53,6 @@ public:
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
archive_plugin_deinit_all(); archive_plugin_deinit_all();
#endif #endif
config_global_finish();
} }
}; };

View File

@ -93,7 +93,7 @@ try {
EventThread io_thread; EventThread io_thread;
io_thread.Start(); io_thread.Start();
input_stream_global_init(io_thread.GetEventLoop()); input_stream_global_init(ConfigData(), io_thread.GetEventLoop());
AtScopeExit() { input_stream_global_finish(); }; AtScopeExit() { input_stream_global_finish(); };
decoder_plugin_init_all(ConfigData()); decoder_plugin_init_all(ConfigData());

View File

@ -98,7 +98,8 @@ public:
if (!config_path.IsNull()) if (!config_path.IsNull())
ReadConfigFile(config_path); ReadConfigFile(config_path);
input_stream_global_init(io_thread.GetEventLoop()); input_stream_global_init(GetGlobalConfig(),
io_thread.GetEventLoop());
decoder_plugin_init_all(GetGlobalConfig()); decoder_plugin_init_all(GetGlobalConfig());
} }

View File

@ -116,7 +116,8 @@ public:
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
archive_plugin_init_all(); archive_plugin_init_all();
#endif #endif
input_stream_global_init(io_thread.GetEventLoop()); input_stream_global_init(GetGlobalConfig(),
io_thread.GetEventLoop());
} }
~GlobalInit() { ~GlobalInit() {

View File

@ -19,7 +19,7 @@
#include "config.h" #include "config.h"
#include "tag/Tag.hxx" #include "tag/Tag.hxx"
#include "config/Global.hxx" #include "config/Data.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"
@ -41,11 +41,11 @@ class GlobalInit {
public: public:
GlobalInit() { GlobalInit() {
io_thread.Start(); io_thread.Start();
config_global_init();
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
archive_plugin_init_all(); archive_plugin_init_all();
#endif #endif
input_stream_global_init(io_thread.GetEventLoop()); input_stream_global_init(ConfigData(),
io_thread.GetEventLoop());
} }
~GlobalInit() { ~GlobalInit() {
@ -53,7 +53,6 @@ public:
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
archive_plugin_deinit_all(); archive_plugin_deinit_all();
#endif #endif
config_global_finish();
} }
}; };