decoder/Plugin: simplify compile-time initialization

Add a `constexpr` constructor and several `constexpr` methods to
construct a DecoderPlugin at compile time, in a way which allows
adding new methods later without having to edit each plugin.
This commit is contained in:
Max Kellermann
2019-06-15 14:44:37 +02:00
parent aebb1baad8
commit 527642a90b
23 changed files with 171 additions and 286 deletions

View File

@@ -1014,15 +1014,8 @@ mad_decoder_scan_stream(InputStream &is, TagHandler &handler) noexcept
static const char *const mp3_suffixes[] = { "mp3", "mp2", nullptr };
static const char *const mp3_mime_types[] = { "audio/mpeg", nullptr };
const struct DecoderPlugin mad_decoder_plugin = {
"mad",
mp3_plugin_init,
nullptr,
mp3_decode,
nullptr,
nullptr,
mad_decoder_scan_stream,
nullptr,
mp3_suffixes,
mp3_mime_types,
};
constexpr DecoderPlugin mad_decoder_plugin =
DecoderPlugin("mad", mp3_decode, mad_decoder_scan_stream)
.WithInit(mp3_plugin_init)
.WithSuffixes(mp3_suffixes)
.WithMimeTypes(mp3_mime_types);