diff options
author | Max Kellermann <max@musicpd.org> | 2019-02-05 22:11:45 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-02-05 22:12:22 +0100 |
commit | 7a23c123c8b3b24ea61157e10b2ffd3ae44c5acf (patch) | |
tree | 1615288af12ddbe04edfed0b43f617b8e6edd2b7 /src | |
parent | e85b24bee0004f6e18c986fa718b2854fee57730 (diff) |
decoder/List: add RAII class
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.cxx | 3 | ||||
-rw-r--r-- | src/decoder/DecoderList.hxx | 11 |
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 |