Commit e9c45a91 authored by Max Kellermann's avatar Max Kellermann

playlist/Registry: add RAII class

parent a065c6e6
...@@ -550,7 +550,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config) ...@@ -550,7 +550,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
client_manager_init(raw_config); client_manager_init(raw_config);
const ScopeInputPluginsInit input_plugins_init(raw_config, const ScopeInputPluginsInit input_plugins_init(raw_config,
instance->io_thread.GetEventLoop()); instance->io_thread.GetEventLoop());
playlist_list_global_init(raw_config); const ScopePlaylistPluginsInit playlist_plugins_init(raw_config);
#ifdef ENABLE_DAEMON #ifdef ENABLE_DAEMON
daemonize_commit(); daemonize_commit();
...@@ -654,8 +654,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config) ...@@ -654,8 +654,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
sticker_global_finish(); sticker_global_finish();
#endif #endif
playlist_list_global_finish();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
......
...@@ -47,6 +47,17 @@ playlist_list_global_init(const ConfigData &config); ...@@ -47,6 +47,17 @@ playlist_list_global_init(const ConfigData &config);
void void
playlist_list_global_finish() noexcept; playlist_list_global_finish() noexcept;
class ScopePlaylistPluginsInit {
public:
explicit ScopePlaylistPluginsInit(const ConfigData &config) {
playlist_list_global_init(config);
}
~ScopePlaylistPluginsInit() noexcept {
playlist_list_global_finish();
}
};
/** /**
* Opens a playlist by its URI. * Opens a playlist by its URI.
*/ */
......
...@@ -65,7 +65,7 @@ try { ...@@ -65,7 +65,7 @@ try {
io_thread.Start(); io_thread.Start();
const ScopeInputPluginsInit input_plugins_init(config, io_thread.GetEventLoop()); const ScopeInputPluginsInit input_plugins_init(config, io_thread.GetEventLoop());
playlist_list_global_init(config); const ScopePlaylistPluginsInit playlist_plugins_init(config);
const ScopeDecoderPluginsInit decoder_plugins_init(config); const ScopeDecoderPluginsInit decoder_plugins_init(config);
/* open the playlist */ /* open the playlist */
...@@ -116,8 +116,6 @@ try { ...@@ -116,8 +116,6 @@ try {
playlist.reset(); playlist.reset();
is.reset(); is.reset();
playlist_list_global_finish();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} catch (...) { } catch (...) {
PrintException(std::current_exception()); PrintException(std::current_exception());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment