summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Main.cxx3
-rw-r--r--src/decoder/DecoderList.hxx11
-rw-r--r--test/ContainerScan.cxx4
-rw-r--r--test/RunChromaprint.cxx10
-rw-r--r--test/dump_playlist.cxx3
-rw-r--r--test/read_tags.cxx3
-rw-r--r--test/run_decoder.cxx10
7 files changed, 21 insertions, 23 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index 38f6efe2a..6aaada2ce 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -534,7 +534,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
pcm_convert_global_init(raw_config);
- decoder_plugin_init_all(raw_config);
+ const ScopeDecoderPluginsInit decoder_plugins_init(raw_config);
#ifdef ENABLE_DATABASE
const bool create_db = InitDatabaseAndStorage(raw_config);
@@ -669,7 +669,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
instance->FinishShutdownPartitions();
command_finish();
- decoder_plugin_deinit_all();
return EXIT_SUCCESS;
}
diff --git a/src/decoder/DecoderList.hxx b/src/decoder/DecoderList.hxx
index 7f0313bd6..f64d51378 100644
--- a/src/decoder/DecoderList.hxx
+++ b/src/decoder/DecoderList.hxx
@@ -42,6 +42,17 @@ decoder_plugin_init_all(const ConfigData &config);
void
decoder_plugin_deinit_all() noexcept;
+class ScopeDecoderPluginsInit {
+public:
+ explicit ScopeDecoderPluginsInit(const ConfigData &config) {
+ decoder_plugin_init_all(config);
+ }
+
+ ~ScopeDecoderPluginsInit() noexcept {
+ decoder_plugin_deinit_all();
+ }
+};
+
template<typename F>
static inline const DecoderPlugin *
decoder_plugins_find(F f) noexcept
diff --git a/test/ContainerScan.cxx b/test/ContainerScan.cxx
index d047ae0b7..6512ba9cb 100644
--- a/test/ContainerScan.cxx
+++ b/test/ContainerScan.cxx
@@ -65,7 +65,7 @@ try {
const Path path = Path::FromFS(argv[1]);
- decoder_plugin_init_all(ConfigData());
+ const ScopeDecoderPluginsInit decoder_plugins_init({});
const auto *plugin = FindContainerDecoderPlugin(path);
if (plugin == nullptr) {
@@ -87,8 +87,6 @@ try {
bos.Flush();
- decoder_plugin_deinit_all();
-
return EXIT_SUCCESS;
} catch (...) {
PrintException(std::current_exception());
diff --git a/test/RunChromaprint.cxx b/test/RunChromaprint.cxx
index 3da471f77..dfbca8586 100644
--- a/test/RunChromaprint.cxx
+++ b/test/RunChromaprint.cxx
@@ -91,22 +91,18 @@ class GlobalInit {
const ConfigData config;
EventThread io_thread;
const ScopeInputPluginsInit input_plugins_init;
+ const ScopeDecoderPluginsInit decoder_plugins_init;
public:
explicit GlobalInit(Path config_path)
:config(AutoLoadConfigFile(config_path)),
- input_plugins_init(config, io_thread.GetEventLoop())
+ input_plugins_init(config, io_thread.GetEventLoop()),
+ decoder_plugins_init(config)
{
io_thread.Start();
- decoder_plugin_init_all(config);
-
pcm_convert_global_init(config);
}
-
- ~GlobalInit() {
- decoder_plugin_deinit_all();
- }
};
class ChromaprintDecoderClient final : public DecoderClient {
diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx
index 699b2e930..111fbc47f 100644
--- a/test/dump_playlist.cxx
+++ b/test/dump_playlist.cxx
@@ -66,7 +66,7 @@ try {
const ScopeInputPluginsInit input_plugins_init(config, io_thread.GetEventLoop());
playlist_list_global_init(config);
- decoder_plugin_init_all(config);
+ const ScopeDecoderPluginsInit decoder_plugins_init(config);
/* open the playlist */
@@ -116,7 +116,6 @@ try {
playlist.reset();
is.reset();
- decoder_plugin_deinit_all();
playlist_list_global_finish();
return EXIT_SUCCESS;
diff --git a/test/read_tags.cxx b/test/read_tags.cxx
index 3b3a791aa..a8ab2a061 100644
--- a/test/read_tags.cxx
+++ b/test/read_tags.cxx
@@ -96,8 +96,7 @@ try {
const ScopeInputPluginsInit input_plugins_init(ConfigData(),
io_thread.GetEventLoop());
- decoder_plugin_init_all(ConfigData());
- AtScopeExit() { decoder_plugin_deinit_all(); };
+ const ScopeDecoderPluginsInit decoder_plugins_init({});
plugin = decoder_plugin_from_name(decoder_name);
if (plugin == NULL) {
diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx
index be7091498..c94b5ee07 100644
--- a/test/run_decoder.cxx
+++ b/test/run_decoder.cxx
@@ -89,19 +89,15 @@ class GlobalInit {
const ConfigData config;
EventThread io_thread;
const ScopeInputPluginsInit input_plugins_init;
+ const ScopeDecoderPluginsInit decoder_plugins_init;
public:
explicit GlobalInit(Path config_path)
:config(AutoLoadConfigFile(config_path)),
- input_plugins_init(config, io_thread.GetEventLoop())
+ input_plugins_init(config, io_thread.GetEventLoop()),
+ decoder_plugins_init(config)
{
io_thread.Start();
-
- decoder_plugin_init_all(config);
- }
-
- ~GlobalInit() {
- decoder_plugin_deinit_all();
}
};