archive/List: add RAII class
This commit is contained in:
parent
c0e9246a66
commit
c9ba4f3f9c
|
@ -529,7 +529,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
|
|||
initPermissions(raw_config);
|
||||
spl_global_init(raw_config);
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
archive_plugin_init_all();
|
||||
const ScopeArchivePluginsInit archive_plugins_init;
|
||||
#endif
|
||||
|
||||
pcm_convert_global_init(raw_config);
|
||||
|
@ -671,9 +671,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
|
|||
instance->FinishShutdownPartitions();
|
||||
command_finish();
|
||||
decoder_plugin_deinit_all();
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
archive_plugin_deinit_all();
|
||||
#endif
|
||||
|
||||
instance->rtio_thread.Stop();
|
||||
instance->io_thread.Stop();
|
||||
|
||||
|
|
|
@ -46,4 +46,15 @@ archive_plugin_init_all();
|
|||
void
|
||||
archive_plugin_deinit_all() noexcept;
|
||||
|
||||
class ScopeArchivePluginsInit {
|
||||
public:
|
||||
ScopeArchivePluginsInit() {
|
||||
archive_plugin_init_all();
|
||||
}
|
||||
|
||||
~ScopeArchivePluginsInit() noexcept {
|
||||
archive_plugin_deinit_all();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,21 +38,19 @@
|
|||
class GlobalInit {
|
||||
EventThread io_thread;
|
||||
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
const ScopeArchivePluginsInit archive_plugins_init;
|
||||
#endif
|
||||
|
||||
public:
|
||||
GlobalInit() {
|
||||
io_thread.Start();
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
archive_plugin_init_all();
|
||||
#endif
|
||||
input_stream_global_init(ConfigData(),
|
||||
io_thread.GetEventLoop());
|
||||
}
|
||||
|
||||
~GlobalInit() {
|
||||
input_stream_global_finish();
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
archive_plugin_deinit_all();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -106,6 +106,10 @@ class GlobalInit {
|
|||
ConfigData config;
|
||||
EventThread io_thread;
|
||||
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
const ScopeArchivePluginsInit archive_plugins_init;
|
||||
#endif
|
||||
|
||||
public:
|
||||
GlobalInit(Path config_path, bool verbose) {
|
||||
SetLogThreshold(verbose ? LogLevel::DEBUG : LogLevel::INFO);
|
||||
|
@ -117,18 +121,12 @@ public:
|
|||
|
||||
io_thread.Start();
|
||||
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
archive_plugin_init_all();
|
||||
#endif
|
||||
input_stream_global_init(config,
|
||||
io_thread.GetEventLoop());
|
||||
}
|
||||
|
||||
~GlobalInit() {
|
||||
input_stream_global_finish();
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
archive_plugin_deinit_all();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -38,21 +38,19 @@
|
|||
class GlobalInit {
|
||||
EventThread io_thread;
|
||||
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
const ScopeArchivePluginsInit archive_plugins_init;
|
||||
#endif
|
||||
|
||||
public:
|
||||
GlobalInit() {
|
||||
io_thread.Start();
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
archive_plugin_init_all();
|
||||
#endif
|
||||
input_stream_global_init(ConfigData(),
|
||||
io_thread.GetEventLoop());
|
||||
}
|
||||
|
||||
~GlobalInit() {
|
||||
input_stream_global_finish();
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
archive_plugin_deinit_all();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue