From 8bb35e7bb65e0303ee26b271dbc41f468dd32cd8 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Thu, 25 Oct 2018 09:09:21 +0200
Subject: [PATCH] decoder/Thread: reimplement HasRemoteTagScanner() using the
 InputPlugin list

---
 src/decoder/Thread.cxx |  9 +--------
 src/input/Registry.cxx | 11 +++++++++++
 src/input/Registry.hxx |  5 +++++
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/decoder/Thread.cxx b/src/decoder/Thread.cxx
index 7a54af3e8..c4ff4cd97 100644
--- a/src/decoder/Thread.cxx
+++ b/src/decoder/Thread.cxx
@@ -28,6 +28,7 @@
 #include "DecoderAPI.hxx"
 #include "input/InputStream.hxx"
 #include "input/LocalOpen.hxx"
+#include "input/Registry.hxx"
 #include "DecoderList.hxx"
 #include "system/Error.hxx"
 #include "util/MimeType.hxx"
@@ -432,14 +433,6 @@ try {
 						  error_uri));
 }
 
-gcc_pure
-static bool
-HasRemoteTagScanner(const char *uri) noexcept
-{
-	return StringStartsWith(uri, "tidal://") ||
-		StringStartsWith(uri, "qobuz://");
-}
-
 /**
  * Try to guess whether tags attached to the given song are
  * "volatile", e.g. if they have been received by a live stream, but
diff --git a/src/input/Registry.cxx b/src/input/Registry.cxx
index fba83515d..4a4dcff4b 100644
--- a/src/input/Registry.cxx
+++ b/src/input/Registry.cxx
@@ -83,3 +83,14 @@ const InputPlugin *const input_plugins[] = {
 };
 
 bool input_plugins_enabled[ARRAY_SIZE(input_plugins) - 1];
+
+bool
+HasRemoteTagScanner(const char *uri) noexcept
+{
+	input_plugins_for_each_enabled(plugin)
+		if (plugin->scan_tags != nullptr &&
+		    plugin->SupportsUri(uri))
+			return true;
+
+	return false;
+}
diff --git a/src/input/Registry.hxx b/src/input/Registry.hxx
index 231292be1..6b5e72fb3 100644
--- a/src/input/Registry.hxx
+++ b/src/input/Registry.hxx
@@ -21,6 +21,7 @@
 #define MPD_INPUT_REGISTRY_HXX
 
 #include "check.h"
+#include "util/Compiler.h"
 
 /**
  * NULL terminated list of all input plugins which were enabled at
@@ -40,4 +41,8 @@ extern bool input_plugins_enabled[];
 	input_plugins_for_each(plugin) \
 		if (input_plugins_enabled[input_plugin_iterator - input_plugins])
 
+gcc_pure
+bool
+HasRemoteTagScanner(const char *uri) noexcept;
+
 #endif