From 0fd6235a666f6369322f1ea33f30156a2446ea28 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 2 Sep 2019 20:28:14 +0200 Subject: [PATCH] playlist/Registry: add FindPlaylistPluginBySuffix() --- src/playlist/PlaylistRegistry.cxx | 8 ++++---- src/playlist/PlaylistRegistry.hxx | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/playlist/PlaylistRegistry.cxx b/src/playlist/PlaylistRegistry.cxx index ed06a8408..f5b135577 100644 --- a/src/playlist/PlaylistRegistry.cxx +++ b/src/playlist/PlaylistRegistry.cxx @@ -274,15 +274,15 @@ playlist_list_open_stream(InputStreamPtr &&is, const char *uri) return nullptr; } -bool -playlist_suffix_supported(const char *suffix) noexcept +const PlaylistPlugin * +FindPlaylistPluginBySuffix(const char *suffix) noexcept { assert(suffix != nullptr); playlist_plugins_for_each_enabled(plugin) { if (plugin->SupportsSuffix(suffix)) - return true; + return plugin; } - return false; + return nullptr; } diff --git a/src/playlist/PlaylistRegistry.hxx b/src/playlist/PlaylistRegistry.hxx index b31048643..56b9ef1e5 100644 --- a/src/playlist/PlaylistRegistry.hxx +++ b/src/playlist/PlaylistRegistry.hxx @@ -78,12 +78,19 @@ playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix); std::unique_ptr playlist_list_open_stream(InputStreamPtr &&is, const char *uri); +gcc_pure +const PlaylistPlugin * +FindPlaylistPluginBySuffix(const char *suffix) noexcept; + /** * Determines if there is a playlist plugin which can handle the * specified file name suffix. */ gcc_pure -bool -playlist_suffix_supported(const char *suffix) noexcept; +inline bool +playlist_suffix_supported(const char *suffix) noexcept +{ + return FindPlaylistPluginBySuffix(suffix) != nullptr; +} #endif