summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Main.cxx3
-rw-r--r--src/decoder/DecoderList.hxx11
2 files changed, 12 insertions, 2 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