input/Plugin: pass EventLoop& to init()

Eliminate dependency on io_thread_get().
This commit is contained in:
Max Kellermann 2017-01-25 23:06:12 +01:00
parent 58ac72f79d
commit 3854211694
15 changed files with 21 additions and 20 deletions

View File

@ -525,7 +525,7 @@ try {
instance->partition->UpdateEffectiveReplayGainMode(); instance->partition->UpdateEffectiveReplayGainMode();
client_manager_init(); client_manager_init();
input_stream_global_init(); input_stream_global_init(io_thread_get());
playlist_list_global_init(); playlist_list_global_init();
#ifdef ENABLE_DAEMON #ifdef ENABLE_DAEMON

View File

@ -33,7 +33,7 @@
#include <assert.h> #include <assert.h>
void void
input_stream_global_init() input_stream_global_init(EventLoop &event_loop)
{ {
const ConfigBlock empty; const ConfigBlock empty;
@ -55,7 +55,7 @@ input_stream_global_init()
try { try {
if (plugin->init != nullptr) if (plugin->init != nullptr)
plugin->init(*block); plugin->init(event_loop, *block);
input_plugins_enabled[i] = true; input_plugins_enabled[i] = true;
} catch (const PluginUnavailable &e) { } catch (const PluginUnavailable &e) {
FormatError(e, FormatError(e,

View File

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

View File

@ -31,6 +31,7 @@
struct ConfigBlock; struct ConfigBlock;
class Mutex; class Mutex;
class Cond; class Cond;
class EventLoop;
class InputStream; class InputStream;
struct InputPlugin { struct InputPlugin {
@ -44,7 +45,7 @@ struct InputPlugin {
* *
* Throws std::runtime_error on (fatal) error. * Throws std::runtime_error on (fatal) error.
*/ */
void (*init)(const ConfigBlock &block); void (*init)(EventLoop &event_loop, const ConfigBlock &block);
/** /**
* Global deinitialization. Called once before MPD shuts * Global deinitialization. Called once before MPD shuts

View File

@ -106,7 +106,7 @@ static constexpr Domain cdio_domain("cdio");
static bool default_reverse_endian; static bool default_reverse_endian;
static void static void
input_cdio_init(const ConfigBlock &block) input_cdio_init(EventLoop &, const ConfigBlock &block)
{ {
const char *value = block.GetBlockValue("default_byte_order"); const char *value = block.GetBlockValue("default_byte_order");
if (value != nullptr) { if (value != nullptr) {

View File

@ -32,7 +32,6 @@
#include "tag/TagBuilder.hxx" #include "tag/TagBuilder.hxx"
#include "event/Call.hxx" #include "event/Call.hxx"
#include "event/Loop.hxx" #include "event/Loop.hxx"
#include "IOThread.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include "util/ASCII.hxx" #include "util/ASCII.hxx"
#include "util/StringUtil.hxx" #include "util/StringUtil.hxx"
@ -285,7 +284,7 @@ CurlInputStream::OnError(std::exception_ptr e)
*/ */
static void static void
input_curl_init(const ConfigBlock &block) input_curl_init(EventLoop &event_loop, const ConfigBlock &block)
{ {
CURLcode code = curl_global_init(CURL_GLOBAL_ALL); CURLcode code = curl_global_init(CURL_GLOBAL_ALL);
if (code != CURLE_OK) if (code != CURLE_OK)
@ -319,7 +318,7 @@ input_curl_init(const ConfigBlock &block)
verify_host = block.GetBlockValue("verify_host", true); verify_host = block.GetBlockValue("verify_host", true);
try { try {
curl_global = new CurlGlobal(io_thread_get()); curl_global = new CurlGlobal(event_loop);
} catch (const std::runtime_error &e) { } catch (const std::runtime_error &e) {
LogError(e); LogError(e);
curl_slist_free_all(http_200_aliases); curl_slist_free_all(http_200_aliases);

View File

@ -72,7 +72,7 @@ input_ffmpeg_supported(void)
} }
static void static void
input_ffmpeg_init(gcc_unused const ConfigBlock &block) input_ffmpeg_init(EventLoop &, const ConfigBlock &)
{ {
FfmpegInit(); FfmpegInit();

View File

@ -25,7 +25,6 @@
#include "lib/nfs/FileReader.hxx" #include "lib/nfs/FileReader.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include "util/StringCompare.hxx" #include "util/StringCompare.hxx"
#include "IOThread.hxx"
#include <string.h> #include <string.h>
@ -206,9 +205,9 @@ NfsInputStream::OnNfsFileError(std::exception_ptr &&e)
*/ */
static void static void
input_nfs_init(const ConfigBlock &) input_nfs_init(EventLoop &event_loop, const ConfigBlock &)
{ {
nfs_init(io_thread_get()); nfs_init(event_loop);
} }
static void static void

View File

@ -69,7 +69,7 @@ public:
*/ */
static void static void
input_smbclient_init(gcc_unused const ConfigBlock &block) input_smbclient_init(EventLoop &, const ConfigBlock &)
{ {
try { try {
SmbclientInit(); SmbclientInit();

View File

@ -66,7 +66,7 @@ try {
const ScopeIOThread io_thread; const ScopeIOThread io_thread;
input_stream_global_init(); input_stream_global_init(io_thread_get());
playlist_list_global_init(); playlist_list_global_init();
decoder_plugin_init_all(); decoder_plugin_init_all();

View File

@ -45,7 +45,7 @@ public:
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
archive_plugin_init_all(); archive_plugin_init_all();
#endif #endif
input_stream_global_init(); input_stream_global_init(io_thread_get());
} }
~GlobalInit() { ~GlobalInit() {

View File

@ -88,7 +88,7 @@ try {
const ScopeIOThread io_thread; const ScopeIOThread io_thread;
input_stream_global_init(); input_stream_global_init(io_thread_get());
AtScopeExit() { input_stream_global_finish(); }; AtScopeExit() { input_stream_global_finish(); };
decoder_plugin_init_all(); decoder_plugin_init_all();

View File

@ -48,7 +48,7 @@ try {
const ScopeIOThread io_thread; const ScopeIOThread io_thread;
input_stream_global_init(); input_stream_global_init(io_thread_get());
decoder_plugin_init_all(); decoder_plugin_init_all();

View File

@ -47,7 +47,7 @@ public:
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
archive_plugin_init_all(); archive_plugin_init_all();
#endif #endif
input_stream_global_init(); input_stream_global_init(io_thread_get());
} }
~GlobalInit() { ~GlobalInit() {

View File

@ -44,7 +44,7 @@ public:
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
archive_plugin_init_all(); archive_plugin_init_all();
#endif #endif
input_stream_global_init(); input_stream_global_init(io_thread_get());
} }
~GlobalInit() { ~GlobalInit() {