input/Init: add RAII class
This commit is contained in:
@@ -90,15 +90,15 @@ ParseCommandLine(int argc, char **argv)
|
||||
class GlobalInit {
|
||||
const ConfigData config;
|
||||
EventThread io_thread;
|
||||
const ScopeInputPluginsInit input_plugins_init;
|
||||
|
||||
public:
|
||||
explicit GlobalInit(Path config_path)
|
||||
:config(AutoLoadConfigFile(config_path))
|
||||
:config(AutoLoadConfigFile(config_path)),
|
||||
input_plugins_init(config, io_thread.GetEventLoop())
|
||||
{
|
||||
io_thread.Start();
|
||||
|
||||
input_stream_global_init(config,
|
||||
io_thread.GetEventLoop());
|
||||
decoder_plugin_init_all(config);
|
||||
|
||||
pcm_convert_global_init(config);
|
||||
@@ -106,7 +106,6 @@ public:
|
||||
|
||||
~GlobalInit() {
|
||||
decoder_plugin_deinit_all();
|
||||
input_stream_global_finish();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -64,7 +64,7 @@ try {
|
||||
EventThread io_thread;
|
||||
io_thread.Start();
|
||||
|
||||
input_stream_global_init(config, io_thread.GetEventLoop());
|
||||
const ScopeInputPluginsInit input_plugins_init(config, io_thread.GetEventLoop());
|
||||
playlist_list_global_init(config);
|
||||
decoder_plugin_init_all(config);
|
||||
|
||||
@@ -118,7 +118,6 @@ try {
|
||||
|
||||
decoder_plugin_deinit_all();
|
||||
playlist_list_global_finish();
|
||||
input_stream_global_finish();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
} catch (...) {
|
||||
|
@@ -42,15 +42,13 @@ class GlobalInit {
|
||||
const ScopeArchivePluginsInit archive_plugins_init;
|
||||
#endif
|
||||
|
||||
public:
|
||||
GlobalInit() {
|
||||
io_thread.Start();
|
||||
input_stream_global_init(ConfigData(),
|
||||
io_thread.GetEventLoop());
|
||||
}
|
||||
const ScopeInputPluginsInit input_plugins_init;
|
||||
|
||||
~GlobalInit() {
|
||||
input_stream_global_finish();
|
||||
public:
|
||||
GlobalInit()
|
||||
:input_plugins_init(ConfigData(), io_thread.GetEventLoop())
|
||||
{
|
||||
io_thread.Start();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -93,8 +93,8 @@ try {
|
||||
EventThread io_thread;
|
||||
io_thread.Start();
|
||||
|
||||
input_stream_global_init(ConfigData(), io_thread.GetEventLoop());
|
||||
AtScopeExit() { input_stream_global_finish(); };
|
||||
const ScopeInputPluginsInit input_plugins_init(ConfigData(),
|
||||
io_thread.GetEventLoop());
|
||||
|
||||
decoder_plugin_init_all(ConfigData());
|
||||
AtScopeExit() { decoder_plugin_deinit_all(); };
|
||||
|
@@ -88,21 +88,20 @@ ParseCommandLine(int argc, char **argv)
|
||||
class GlobalInit {
|
||||
const ConfigData config;
|
||||
EventThread io_thread;
|
||||
const ScopeInputPluginsInit input_plugins_init;
|
||||
|
||||
public:
|
||||
explicit GlobalInit(Path config_path)
|
||||
:config(AutoLoadConfigFile(config_path))
|
||||
:config(AutoLoadConfigFile(config_path)),
|
||||
input_plugins_init(config, io_thread.GetEventLoop())
|
||||
{
|
||||
io_thread.Start();
|
||||
|
||||
input_stream_global_init(config,
|
||||
io_thread.GetEventLoop());
|
||||
decoder_plugin_init_all(config);
|
||||
}
|
||||
|
||||
~GlobalInit() {
|
||||
decoder_plugin_deinit_all();
|
||||
input_stream_global_finish();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -108,18 +108,14 @@ class GlobalInit {
|
||||
const ScopeArchivePluginsInit archive_plugins_init;
|
||||
#endif
|
||||
|
||||
const ScopeInputPluginsInit input_plugins_init;
|
||||
|
||||
public:
|
||||
explicit GlobalInit(Path config_path)
|
||||
:config(AutoLoadConfigFile(config_path))
|
||||
:config(AutoLoadConfigFile(config_path)),
|
||||
input_plugins_init(config, io_thread.GetEventLoop())
|
||||
{
|
||||
io_thread.Start();
|
||||
|
||||
input_stream_global_init(config,
|
||||
io_thread.GetEventLoop());
|
||||
}
|
||||
|
||||
~GlobalInit() {
|
||||
input_stream_global_finish();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -42,15 +42,13 @@ class GlobalInit {
|
||||
const ScopeArchivePluginsInit archive_plugins_init;
|
||||
#endif
|
||||
|
||||
public:
|
||||
GlobalInit() {
|
||||
io_thread.Start();
|
||||
input_stream_global_init(ConfigData(),
|
||||
io_thread.GetEventLoop());
|
||||
}
|
||||
const ScopeInputPluginsInit input_plugins_init;
|
||||
|
||||
~GlobalInit() {
|
||||
input_stream_global_finish();
|
||||
public:
|
||||
GlobalInit()
|
||||
:input_plugins_init(ConfigData(), io_thread.GetEventLoop())
|
||||
{
|
||||
io_thread.Start();
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user