Skip to content

Commit de9f0dc

Browse files
committed
playlist/Plugin: convert _init() and _finish() to methods
1 parent cf5970a commit de9f0dc

File tree

2 files changed

+25
-34
lines changed

2 files changed

+25
-34
lines changed

src/playlist/PlaylistPlugin.hxx

+23-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
// Copyright The Music Player Daemon Project
33

4-
#ifndef MPD_PLAYLIST_PLUGIN_HXX
5-
#define MPD_PLAYLIST_PLUGIN_HXX
4+
#pragma once
65

76
#include "input/Ptr.hxx"
87
#include "thread/Mutex.hxx"
@@ -117,33 +116,26 @@ struct PlaylistPlugin {
117116
*/
118117
[[gnu::pure]]
119118
bool SupportsMimeType(std::string_view mime_type) const noexcept;
120-
};
121119

122-
/**
123-
* Initialize a plugin.
124-
*
125-
* @param block a configuration block for this plugin, or nullptr if none
126-
* is configured
127-
* @return true if the plugin was initialized successfully, false if
128-
* the plugin is not available
129-
*/
130-
static inline bool
131-
playlist_plugin_init(const PlaylistPlugin *plugin,
132-
const ConfigBlock &block)
133-
{
134-
return plugin->init != nullptr
135-
? plugin->init(block)
136-
: true;
137-
}
138-
139-
/**
140-
* Deinitialize a plugin which was initialized successfully.
141-
*/
142-
static inline void
143-
playlist_plugin_finish(const PlaylistPlugin *plugin) noexcept
144-
{
145-
if (plugin->finish != nullptr)
146-
plugin->finish();
147-
}
148-
149-
#endif
120+
/**
121+
* Initialize the plugin.
122+
*
123+
* @param block a configuration block for this plugin, or nullptr if none
124+
* is configured
125+
* @return true if the plugin was initialized successfully, false if
126+
* the plugin is not available
127+
*/
128+
bool Init(const ConfigBlock &block) const {
129+
return init != nullptr
130+
? init(block)
131+
: true;
132+
}
133+
134+
/**
135+
* Deinitialize the plugin which was initialized successfully.
136+
*/
137+
void Finish() const noexcept {
138+
if (finish != nullptr)
139+
finish();
140+
}
141+
};

src/playlist/PlaylistRegistry.cxx

+2-3
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ playlist_list_global_init(const ConfigData &config)
8484
if (param != nullptr)
8585
param->SetUsed();
8686

87-
playlist_plugins_enabled[i] =
88-
playlist_plugin_init(playlist_plugins[i], *param);
87+
playlist_plugins_enabled[i] = playlist_plugins[i]->Init(*param);
8988

9089
playlist_plugins_as_folder[i] =
9190
param->GetBlockValue("as_directory",
@@ -97,7 +96,7 @@ void
9796
playlist_list_global_finish() noexcept
9897
{
9998
for (const auto &plugin : GetEnabledPlaylistPlugins()) {
100-
playlist_plugin_finish(&plugin);
99+
plugin.Finish();
101100
}
102101
}
103102

0 commit comments

Comments
 (0)